/libpng/png.h
C++ Header | 1498 lines | 728 code | 155 blank | 615 comment | 30 complexity | 9e2333260347f3842dbc85e48a1dd53d MD5 | raw file
Large files files are truncated, but you can click here to view the full file
1/* png.h - header file for PNG reference library 2 * 3 * libpng version 1.2.8 - December 3, 2004 4 * Copyright (c) 1998-2004 Glenn Randers-Pehrson 5 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 6 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 7 * 8 * Authors and maintainers: 9 * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat 10 * 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 * See also "Contributing Authors", below. 13 * 14 * Note about libpng version numbers: 15 * 16 * Due to various miscommunications, unforeseen code incompatibilities 17 * and occasional factors outside the authors' control, version numbering 18 * on the library has not always been consistent and straightforward. 19 * The following table summarizes matters since version 0.89c, which was 20 * the first widely used release: 21 * 22 * source png.h png.h shared-lib 23 * version string int version 24 * ------- ------ ----- ---------- 25 * 0.89c "1.0 beta 3" 0.89 89 1.0.89 26 * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] 27 * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] 28 * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] 29 * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] 30 * 0.97c 0.97 97 2.0.97 31 * 0.98 0.98 98 2.0.98 32 * 0.99 0.99 98 2.0.99 33 * 0.99a-m 0.99 99 2.0.99 34 * 1.00 1.00 100 2.1.0 [100 should be 10000] 35 * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] 36 * 1.0.1 png.h string is 10001 2.1.0 37 * 1.0.1a-e identical to the 10002 from here on, the shared library 38 * 1.0.2 source version) 10002 is 2.V where V is the source code 39 * 1.0.2a-b 10003 version, except as noted. 40 * 1.0.3 10003 41 * 1.0.3a-d 10004 42 * 1.0.4 10004 43 * 1.0.4a-f 10005 44 * 1.0.5 (+ 2 patches) 10005 45 * 1.0.5a-d 10006 46 * 1.0.5e-r 10100 (not source compatible) 47 * 1.0.5s-v 10006 (not binary compatible) 48 * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) 49 * 1.0.6d-f 10007 (still binary incompatible) 50 * 1.0.6g 10007 51 * 1.0.6h 10007 10.6h (testing xy.z so-numbering) 52 * 1.0.6i 10007 10.6i 53 * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) 54 * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) 55 * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) 56 * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) 57 * 1.0.7 1 10007 (still compatible) 58 * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 59 * 1.0.8rc1 1 10008 2.1.0.8rc1 60 * 1.0.8 1 10008 2.1.0.8 61 * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 62 * 1.0.9rc1 1 10009 2.1.0.9rc1 63 * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 64 * 1.0.9rc2 1 10009 2.1.0.9rc2 65 * 1.0.9 1 10009 2.1.0.9 66 * 1.0.10beta1 1 10010 2.1.0.10beta1 67 * 1.0.10rc1 1 10010 2.1.0.10rc1 68 * 1.0.10 1 10010 2.1.0.10 69 * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 70 * 1.0.11rc1 1 10011 2.1.0.11rc1 71 * 1.0.11 1 10011 2.1.0.11 72 * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 73 * 1.0.12rc1 2 10012 2.1.0.12rc1 74 * 1.0.12 2 10012 2.1.0.12 75 * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned) 76 * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 77 * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 78 * 1.2.0rc1 3 10200 3.1.2.0rc1 79 * 1.2.0 3 10200 3.1.2.0 80 * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4 81 * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 82 * 1.2.1 3 10201 3.1.2.1 83 * 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 84 * 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 85 * 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 86 * 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 87 * 1.0.13 10 10013 10.so.0.1.0.13 88 * 1.2.2 12 10202 12.so.0.1.2.2 89 * 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 90 * 1.2.3 12 10203 12.so.0.1.2.3 91 * 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 92 * 1.0.14rc1 13 10014 10.so.0.1.0.14rc1 93 * 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 94 * 1.0.14 10 10014 10.so.0.1.0.14 95 * 1.2.4 13 10204 12.so.0.1.2.4 96 * 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 97 * 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3 98 * 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3 99 * 1.0.15 10 10015 10.so.0.1.0.15 100 * 1.2.5 13 10205 12.so.0.1.2.5 101 * 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 102 * 1.0.16 10 10016 10.so.0.1.0.16 103 * 1.2.6 13 10206 12.so.0.1.2.6 104 * 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.2.7rc1 13 10207 12.so.0.1.2.7rc1 107 * 1.0.17 10 10017 12.so.0.1.0.17 108 * 1.2.7 13 10207 12.so.0.1.2.7 109 * 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.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.2.8 13 10208 12.so.0.1.2.8 114 * 115 * Henceforth the source version will match the shared-library major 116 * and minor numbers; the shared-library major version number will be 117 * used for changes in backward compatibility, as it is intended. The 118 * PNG_LIBPNG_VER macro, which is not used within libpng but is available 119 * for applications, is an unsigned integer of the form xyyzz corresponding 120 * to the source version x.y.z (leading zeros in y and z). Beta versions 121 * were given the previous public release number plus a letter, until 122 * version 1.0.6j; from then on they were given the upcoming public 123 * release number plus "betaNN" or "rcN". 124 * 125 * Binary incompatibility exists only when applications make direct access 126 * to the info_ptr or png_ptr members through png.h, and the compiled 127 * application is loaded with a different version of the library. 128 * 129 * DLLNUM will change each time there are forward or backward changes 130 * in binary compatibility (e.g., when a new feature is added). 131 * 132 * See libpng.txt or libpng.3 for more information. The PNG specification 133 * is available as a W3C Recommendation and as an ISO Specification, 134 * <http://www.w3.org/TR/2003/REC-PNG-20031110/ 135 */ 136 137/* 138 * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: 139 * 140 * If you modify libpng you may insert additional notices immediately following 141 * this sentence. 142 * 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 145 * distributed according to the same disclaimer and license as libpng-1.2.5 146 * with the following individual added to the list of Contributing Authors: 147 * 148 * Cosmin Truta 149 * 150 * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are 151 * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are 152 * distributed according to the same disclaimer and license as libpng-1.0.6 153 * with the following individuals added to the list of Contributing Authors: 154 * 155 * Simon-Pierre Cadieux 156 * Eric S. Raymond 157 * Gilles Vollant 158 * 159 * and with the following additions to the disclaimer: 160 * 161 * There is no warranty against interference with your enjoyment of the 162 * library or against infringement. There is no warranty that our 163 * efforts or the library will fulfill any of your particular purposes 164 * or needs. This library is provided with all faults, and the entire 165 * risk of satisfactory quality, performance, accuracy, and effort is with 166 * the user. 167 * 168 * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are 169 * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are 170 * distributed according to the same disclaimer and license as libpng-0.96, 171 * with the following individuals added to the list of Contributing Authors: 172 * 173 * Tom Lane 174 * Glenn Randers-Pehrson 175 * Willem van Schaik 176 * 177 * libpng versions 0.89, June 1996, through 0.96, May 1997, are 178 * Copyright (c) 1996, 1997 Andreas Dilger 179 * Distributed according to the same disclaimer and license as libpng-0.88, 180 * with the following individuals added to the list of Contributing Authors: 181 * 182 * John Bowler 183 * Kevin Bracey 184 * Sam Bushell 185 * Magnus Holmgren 186 * Greg Roelofs 187 * Tom Tanner 188 * 189 * libpng versions 0.5, May 1995, through 0.88, January 1996, are 190 * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. 191 * 192 * For the purposes of this copyright and license, "Contributing Authors" 193 * is defined as the following set of individuals: 194 * 195 * Andreas Dilger 196 * Dave Martindale 197 * Guy Eric Schalnat 198 * Paul Schmidt 199 * Tim Wegner 200 * 201 * The PNG Reference Library is supplied "AS IS". The Contributing Authors 202 * and Group 42, Inc. disclaim all warranties, expressed or implied, 203 * including, without limitation, the warranties of merchantability and of 204 * fitness for any purpose. The Contributing Authors and Group 42, Inc. 205 * assume no liability for direct, indirect, incidental, special, exemplary, 206 * or consequential damages, which may result from the use of the PNG 207 * Reference Library, even if advised of the possibility of such damage. 208 * 209 * Permission is hereby granted to use, copy, modify, and distribute this 210 * source code, or portions hereof, for any purpose, without fee, subject 211 * to the following restrictions: 212 * 213 * 1. The origin of this source code must not be misrepresented. 214 * 215 * 2. Altered versions must be plainly marked as such and 216 * must not be misrepresented as being the original source. 217 * 218 * 3. This Copyright notice may not be removed or altered from 219 * any source or altered source distribution. 220 * 221 * The Contributing Authors and Group 42, Inc. specifically permit, without 222 * fee, and encourage the use of this source code as a component to 223 * supporting the PNG file format in commercial products. If you use this 224 * source code in a product, acknowledgment is not required but would be 225 * appreciated. 226 */ 227 228/* 229 * A "png_get_copyright" function is available, for convenient use in "about" 230 * boxes and the like: 231 * 232 * printf("%s",png_get_copyright(NULL)); 233 * 234 * Also, the PNG logo (in PNG format, of course) is supplied in the 235 * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). 236 */ 237 238/* 239 * Libpng is OSI Certified Open Source Software. OSI Certified is a 240 * certification mark of the Open Source Initiative. 241 */ 242 243/* 244 * The contributing authors would like to thank all those who helped 245 * with testing, bug fixes, and patience. This wouldn't have been 246 * possible without all of you. 247 * 248 * Thanks to Frank J. T. Wojcik for helping with the documentation. 249 */ 250 251/* 252 * Y2K compliance in libpng: 253 * ========================= 254 * 255 * December 3, 2004 256 * 257 * Since the PNG Development group is an ad-hoc body, we can't make 258 * an official declaration. 259 * 260 * 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 262 * versions were also Y2K compliant. 263 * 264 * Libpng only has three year fields. One is a 2-byte unsigned integer 265 * that will hold years up to 65535. The other two hold the date in text 266 * format, and will hold years up to 9999. 267 * 268 * The integer is 269 * "png_uint_16 year" in png_time_struct. 270 * 271 * The strings are 272 * "png_charp time_buffer" in png_struct and 273 * "near_time_buffer", which is a local character string in png.c. 274 * 275 * There are seven time-related functions: 276 * png.c: png_convert_to_rfc_1123() in png.c 277 * (formerly png_convert_to_rfc_1152() in error) 278 * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c 279 * png_convert_from_time_t() in pngwrite.c 280 * png_get_tIME() in pngget.c 281 * png_handle_tIME() in pngrutil.c, called in pngread.c 282 * png_set_tIME() in pngset.c 283 * png_write_tIME() in pngwutil.c, called in pngwrite.c 284 * 285 * All handle dates properly in a Y2K environment. The 286 * png_convert_from_time_t() function calls gmtime() to convert from system 287 * clock time, which returns (year - 1900), which we properly convert to 288 * the full 4-digit year. There is a possibility that applications using 289 * libpng are not passing 4-digit years into the png_convert_to_rfc_1123() 290 * function, or that they are incorrectly passing only a 2-digit year 291 * instead of "year - 1900" into the png_convert_from_struct_tm() function, 292 * but this is not under our control. The libpng documentation has always 293 * stated that it works with 4-digit years, and the APIs have been 294 * documented as such. 295 * 296 * The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned 297 * integer to hold the year, and can hold years as large as 65535. 298 * 299 * zlib, upon which libpng depends, is also Y2K compliant. It contains 300 * no date-related code. 301 * 302 * Glenn Randers-Pehrson 303 * libpng maintainer 304 * PNG Development Group 305 */ 306 307#ifndef PNG_H 308#define PNG_H 309 310/* This is not the place to learn how to use libpng. The file libpng.txt 311 * describes how to use libpng, and the file example.c summarizes it 312 * with some code on which to build. This file is useful for looking 313 * at the actual function definitions and structure components. 314 */ 315 316/* Version information for png.h - this should match the version in png.c */ 317#define PNG_LIBPNG_VER_STRING "1.2.8" 318#define PNG_HEADER_VERSION_STRING \ 319 " libpng version 1.2.8 - December 3, 2004 (header)\n" 320 321#define PNG_LIBPNG_VER_SONUM 0 322#define PNG_LIBPNG_VER_DLLNUM 13 323 324/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ 325#define PNG_LIBPNG_VER_MAJOR 1 326#define PNG_LIBPNG_VER_MINOR 2 327#define PNG_LIBPNG_VER_RELEASE 8 328/* This should match the numeric part of the final component of 329 * PNG_LIBPNG_VER_STRING, omitting any leading zero: */ 330 331#define PNG_LIBPNG_VER_BUILD 0 332 333/* Release Status */ 334#define PNG_LIBPNG_BUILD_ALPHA 1 335#define PNG_LIBPNG_BUILD_BETA 2 336#define PNG_LIBPNG_BUILD_RC 3 337#define PNG_LIBPNG_BUILD_STABLE 4 338#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7 339 340/* Release-Specific Flags */ 341#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with 342 PNG_LIBPNG_BUILD_STABLE only */ 343#define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with 344 PNG_LIBPNG_BUILD_SPECIAL */ 345#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with 346 PNG_LIBPNG_BUILD_PRIVATE */ 347 348#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE 349 350/* Careful here. At one time, Guy wanted to use 082, but that would be octal. 351 * We must not include leading zeros. 352 * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only 353 * version 1.0.0 was mis-numbered 100 instead of 10000). From 354 * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ 355#define PNG_LIBPNG_VER 10208 /* 1.2.8 */ 356 357#ifndef PNG_VERSION_INFO_ONLY 358/* include the compression library's header */ 359#include "zlib.h" 360#endif 361 362/* include all user configurable info, including optional assembler routines */ 363#include "pngconf.h" 364 365/* 366 * Added at libpng-1.2.8 */ 367/* Ref MSDN: Private as priority over Special 368 * VS_FF_PRIVATEBUILD File *was not* built using standard release 369 * procedures. If this value is given, the StringFileInfo block must 370 * contain a PrivateBuild string. 371 * 372 * VS_FF_SPECIALBUILD File *was* built by the original company using 373 * standard release procedures but is a variation of the standard 374 * file of the same version number. If this value is given, the 375 * StringFileInfo block must contain a SpecialBuild string. 376 */ 377 378#if defined(PNG_USER_PRIVATEBUILD) 379# define PNG_LIBPNG_BUILD_TYPE PNG_LIBPNG_BUILD_BASE_TYPE | \ 380 PNG_LIBPNG_BUILD_PRIVATE 381#else 382# if defined(PNG_LIBPNG_SPECIALBUILD) 383# define PNG_LIBPNG_BUILD_TYPE PNG_LIBPNG_BUILD_BASE_TYPE | \ 384 PNG_LIBPNG_BUILD_SPECIAL 385# else 386# define PNG_LIBPNG_BUILD_TYPE PNG_LIBPNG_BUILD_BASE_TYPE 387# endif 388#endif 389 390#ifndef PNG_VERSION_INFO_ONLY 391 392/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ 393#ifdef __cplusplus 394extern "C" { 395#endif /* __cplusplus */ 396 397/* This file is arranged in several sections. The first section contains 398 * structure and type definitions. The second section contains the external 399 * library functions, while the third has the internal library functions, 400 * which applications aren't expected to use directly. 401 */ 402 403#ifndef PNG_NO_TYPECAST_NULL 404#define int_p_NULL (int *)NULL 405#define png_bytep_NULL (png_bytep)NULL 406#define png_bytepp_NULL (png_bytepp)NULL 407#define png_doublep_NULL (png_doublep)NULL 408#define png_error_ptr_NULL (png_error_ptr)NULL 409#define png_flush_ptr_NULL (png_flush_ptr)NULL 410#define png_free_ptr_NULL (png_free_ptr)NULL 411#define png_infopp_NULL (png_infopp)NULL 412#define png_malloc_ptr_NULL (png_malloc_ptr)NULL 413#define png_read_status_ptr_NULL (png_read_status_ptr)NULL 414#define png_rw_ptr_NULL (png_rw_ptr)NULL 415#define png_structp_NULL (png_structp)NULL 416#define png_uint_16p_NULL (png_uint_16p)NULL 417#define png_voidp_NULL (png_voidp)NULL 418#define png_write_status_ptr_NULL (png_write_status_ptr)NULL 419#else 420#define int_p_NULL NULL 421#define png_bytep_NULL NULL 422#define png_bytepp_NULL NULL 423#define png_doublep_NULL NULL 424#define png_error_ptr_NULL NULL 425#define png_flush_ptr_NULL NULL 426#define png_free_ptr_NULL NULL 427#define png_infopp_NULL NULL 428#define png_malloc_ptr_NULL NULL 429#define png_read_status_ptr_NULL NULL 430#define png_rw_ptr_NULL NULL 431#define png_structp_NULL NULL 432#define png_uint_16p_NULL NULL 433#define png_voidp_NULL NULL 434#define png_write_status_ptr_NULL NULL 435#endif 436 437/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ 438#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) 439/* Version information for C files, stored in png.c. This had better match 440 * the version above. 441 */ 442#ifdef PNG_USE_GLOBAL_ARRAYS 443PNG_EXPORT_VAR (const char) png_libpng_ver[18]; 444 /* need room for 99.99.99beta99z */ 445#else 446#define png_libpng_ver png_get_header_ver(NULL) 447#endif 448 449#ifdef PNG_USE_GLOBAL_ARRAYS 450/* This was removed in version 1.0.5c */ 451/* Structures to facilitate easy interlacing. See png.c for more details */ 452PNG_EXPORT_VAR (const int FARDATA) png_pass_start[7]; 453PNG_EXPORT_VAR (const int FARDATA) png_pass_inc[7]; 454PNG_EXPORT_VAR (const int FARDATA) png_pass_ystart[7]; 455PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7]; 456PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7]; 457PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7]; 458#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW 459PNG_EXPORT_VAR (const int FARDATA) png_pass_width[7]; 460#endif 461/* This isn't currently used. If you need it, see png.c for more details. 462PNG_EXPORT_VAR (const int FARDATA) png_pass_height[7]; 463*/ 464#endif 465 466#endif /* PNG_NO_EXTERN */ 467 468/* Three color definitions. The order of the red, green, and blue, (and the 469 * exact size) is not important, although the size of the fields need to 470 * be png_byte or png_uint_16 (as defined below). 471 */ 472typedef struct png_color_struct 473{ 474 png_byte red; 475 png_byte green; 476 png_byte blue; 477} png_color; 478typedef png_color FAR * png_colorp; 479typedef png_color FAR * FAR * png_colorpp; 480 481typedef struct png_color_16_struct 482{ 483 png_byte index; /* used for palette files */ 484 png_uint_16 red; /* for use in red green blue files */ 485 png_uint_16 green; 486 png_uint_16 blue; 487 png_uint_16 gray; /* for use in grayscale files */ 488} png_color_16; 489typedef png_color_16 FAR * png_color_16p; 490typedef png_color_16 FAR * FAR * png_color_16pp; 491 492typedef struct png_color_8_struct 493{ 494 png_byte red; /* for use in red green blue files */ 495 png_byte green; 496 png_byte blue; 497 png_byte gray; /* for use in grayscale files */ 498 png_byte alpha; /* for alpha channel files */ 499} png_color_8; 500typedef png_color_8 FAR * png_color_8p; 501typedef png_color_8 FAR * FAR * png_color_8pp; 502 503/* 504 * The following two structures are used for the in-core representation 505 * of sPLT chunks. 506 */ 507typedef struct png_sPLT_entry_struct 508{ 509 png_uint_16 red; 510 png_uint_16 green; 511 png_uint_16 blue; 512 png_uint_16 alpha; 513 png_uint_16 frequency; 514} png_sPLT_entry; 515typedef png_sPLT_entry FAR * png_sPLT_entryp; 516typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp; 517 518/* When the depth of the sPLT palette is 8 bits, the color and alpha samples 519 * occupy the LSB of their respective members, and the MSB of each member 520 * is zero-filled. The frequency member always occupies the full 16 bits. 521 */ 522 523typedef struct png_sPLT_struct 524{ 525 png_charp name; /* palette name */ 526 png_byte depth; /* depth of palette samples */ 527 png_sPLT_entryp entries; /* palette entries */ 528 png_int_32 nentries; /* number of palette entries */ 529} png_sPLT_t; 530typedef png_sPLT_t FAR * png_sPLT_tp; 531typedef png_sPLT_t FAR * FAR * png_sPLT_tpp; 532 533#ifdef PNG_TEXT_SUPPORTED 534/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, 535 * and whether that contents is compressed or not. The "key" field 536 * points to a regular zero-terminated C string. The "text", "lang", and 537 * "lang_key" fields can be regular C strings, empty strings, or NULL pointers. 538 * However, the * structure returned by png_get_text() will always contain 539 * regular zero-terminated C strings (possibly empty), never NULL pointers, 540 * so they can be safely used in printf() and other string-handling functions. 541 */ 542typedef struct png_text_struct 543{ 544 int compression; /* compression value: 545 -1: tEXt, none 546 0: zTXt, deflate 547 1: iTXt, none 548 2: iTXt, deflate */ 549 png_charp key; /* keyword, 1-79 character description of "text" */ 550 png_charp text; /* comment, may be an empty string (ie "") 551 or a NULL pointer */ 552 png_size_t text_length; /* length of the text string */ 553#ifdef PNG_iTXt_SUPPORTED 554 png_size_t itxt_length; /* length of the itxt string */ 555 png_charp lang; /* language code, 0-79 characters 556 or a NULL pointer */ 557 png_charp lang_key; /* keyword translated UTF-8 string, 0 or more 558 chars or a NULL pointer */ 559#endif 560} png_text; 561typedef png_text FAR * png_textp; 562typedef png_text FAR * FAR * png_textpp; 563#endif 564 565/* Supported compression types for text in PNG files (tEXt, and zTXt). 566 * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */ 567#define PNG_TEXT_COMPRESSION_NONE_WR -3 568#define PNG_TEXT_COMPRESSION_zTXt_WR -2 569#define PNG_TEXT_COMPRESSION_NONE -1 570#define PNG_TEXT_COMPRESSION_zTXt 0 571#define PNG_ITXT_COMPRESSION_NONE 1 572#define PNG_ITXT_COMPRESSION_zTXt 2 573#define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */ 574 575/* png_time is a way to hold the time in an machine independent way. 576 * Two conversions are provided, both from time_t and struct tm. There 577 * is no portable way to convert to either of these structures, as far 578 * as I know. If you know of a portable way, send it to me. As a side 579 * note - PNG has always been Year 2000 compliant! 580 */ 581typedef struct png_time_struct 582{ 583 png_uint_16 year; /* full year, as in, 1995 */ 584 png_byte month; /* month of year, 1 - 12 */ 585 png_byte day; /* day of month, 1 - 31 */ 586 png_byte hour; /* hour of day, 0 - 23 */ 587 png_byte minute; /* minute of hour, 0 - 59 */ 588 png_byte second; /* second of minute, 0 - 60 (for leap seconds) */ 589} png_time; 590typedef png_time FAR * png_timep; 591typedef png_time FAR * FAR * png_timepp; 592 593#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) 594/* png_unknown_chunk is a structure to hold queued chunks for which there is 595 * no specific support. The idea is that we can use this to queue 596 * up private chunks for output even though the library doesn't actually 597 * know about their semantics. 598 */ 599typedef struct png_unknown_chunk_t 600{ 601 png_byte name[5]; 602 png_byte *data; 603 png_size_t size; 604 605 /* libpng-using applications should NOT directly modify this byte. */ 606 png_byte location; /* mode of operation at read time */ 607} 608png_unknown_chunk; 609typedef png_unknown_chunk FAR * png_unknown_chunkp; 610typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp; 611#endif 612 613/* png_info is a structure that holds the information in a PNG file so 614 * that the application can find out the characteristics of the image. 615 * If you are reading the file, this structure will tell you what is 616 * in the PNG file. If you are writing the file, fill in the information 617 * you want to put into the PNG file, then call png_write_info(). 618 * The names chosen should be very close to the PNG specification, so 619 * consult that document for information about the meaning of each field. 620 * 621 * With libpng < 0.95, it was only possible to directly set and read the 622 * the values in the png_info_struct, which meant that the contents and 623 * order of the values had to remain fixed. With libpng 0.95 and later, 624 * however, there are now functions that abstract the contents of 625 * png_info_struct from the application, so this makes it easier to use 626 * libpng with dynamic libraries, and even makes it possible to use 627 * libraries that don't have all of the libpng ancillary chunk-handing 628 * functionality. 629 * 630 * In any case, the order of the parameters in png_info_struct should NOT 631 * be changed for as long as possible to keep compatibility with applications 632 * that use the old direct-access method with png_info_struct. 633 * 634 * The following members may have allocated storage attached that should be 635 * cleaned up before the structure is discarded: palette, trans, text, 636 * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, 637 * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these 638 * are automatically freed when the info structure is deallocated, if they were 639 * allocated internally by libpng. This behavior can be changed by means 640 * of the png_data_freer() function. 641 * 642 * More allocation details: all the chunk-reading functions that 643 * change these members go through the corresponding png_set_* 644 * functions. A function to clear these members is available: see 645 * png_free_data(). The png_set_* functions do not depend on being 646 * able to point info structure members to any of the storage they are 647 * passed (they make their own copies), EXCEPT that the png_set_text 648 * functions use the same storage passed to them in the text_ptr or 649 * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns 650 * functions do not make their own copies. 651 */ 652typedef struct png_info_struct 653{ 654 /* the following are necessary for every PNG file */ 655 png_uint_32 width; /* width of image in pixels (from IHDR) */ 656 png_uint_32 height; /* height of image in pixels (from IHDR) */ 657 png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ 658 png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */ 659 png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */ 660 png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */ 661 png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ 662 png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */ 663 png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */ 664 /* The following three should have been named *_method not *_type */ 665 png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */ 666 png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */ 667 png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ 668 669 /* The following is informational only on read, and not used on writes. */ 670 png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */ 671 png_byte pixel_depth; /* number of bits per pixel */ 672 png_byte spare_byte; /* to align the data, and for future use */ 673 png_byte signature[8]; /* magic bytes read by libpng from start of file */ 674 675 /* The rest of the data is optional. If you are reading, check the 676 * valid field to see if the information in these are valid. If you 677 * are writing, set the valid field to those chunks you want written, 678 * and initialize the appropriate fields below. 679 */ 680 681#if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) 682 /* The gAMA chunk describes the gamma characteristics of the system 683 * on which the image was created, normally in the range [1.0, 2.5]. 684 * Data is valid if (valid & PNG_INFO_gAMA) is non-zero. 685 */ 686 float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */ 687#endif 688 689#if defined(PNG_sRGB_SUPPORTED) 690 /* GR-P, 0.96a */ 691 /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */ 692 png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */ 693#endif 694 695#if defined(PNG_TEXT_SUPPORTED) 696 /* The tEXt, and zTXt chunks contain human-readable textual data in 697 * uncompressed, compressed, and optionally compressed forms, respectively. 698 * The data in "text" is an array of pointers to uncompressed, 699 * null-terminated C strings. Each chunk has a keyword that describes the 700 * textual data contained in that chunk. Keywords are not required to be 701 * unique, and the text string may be empty. Any number of text chunks may 702 * be in an image. 703 */ 704 int num_text; /* number of comments read/to write */ 705 int max_text; /* current size of text array */ 706 png_textp text; /* array of comments read/to write */ 707#endif /* PNG_TEXT_SUPPORTED */ 708 709#if defined(PNG_tIME_SUPPORTED) 710 /* The tIME chunk holds the last time the displayed image data was 711 * modified. See the png_time struct for the contents of this struct. 712 */ 713 png_time mod_time; 714#endif 715 716#if defined(PNG_sBIT_SUPPORTED) 717 /* The sBIT chunk specifies the number of significant high-order bits 718 * in the pixel data. Values are in the range [1, bit_depth], and are 719 * only specified for the channels in the pixel data. The contents of 720 * the low-order bits is not specified. Data is valid if 721 * (valid & PNG_INFO_sBIT) is non-zero. 722 */ 723 png_color_8 sig_bit; /* significant bits in color channels */ 724#endif 725 726#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \ 727defined(PNG_READ_BACKGROUND_SUPPORTED) 728 /* The tRNS chunk supplies transparency data for paletted images and 729 * other image types that don't need a full alpha channel. There are 730 * "num_trans" transparency values for a paletted image, stored in the 731 * same order as the palette colors, starting from index 0. Values 732 * for the data are in the range [0, 255], ranging from fully transparent 733 * to fully opaque, respectively. For non-paletted images, there is a 734 * single color specified that should be treated as fully transparent. 735 * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. 736 */ 737 png_bytep trans; /* transparent values for paletted image */ 738 png_color_16 trans_values; /* transparent color for non-palette image */ 739#endif 740 741#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) 742 /* The bKGD chunk gives the suggested image background color if the 743 * display program does not have its own background color and the image 744 * is needs to composited onto a background before display. The colors 745 * in "background" are normally in the same color space/depth as the 746 * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero. 747 */ 748 png_color_16 background; 749#endif 750 751#if defined(PNG_oFFs_SUPPORTED) 752 /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards 753 * and downwards from the top-left corner of the display, page, or other 754 * application-specific co-ordinate space. See the PNG_OFFSET_ defines 755 * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero. 756 */ 757 png_int_32 x_offset; /* x offset on page */ 758 png_int_32 y_offset; /* y offset on page */ 759 png_byte offset_unit_type; /* offset units type */ 760#endif 761 762#if defined(PNG_pHYs_SUPPORTED) 763 /* The pHYs chunk gives the physical pixel density of the image for 764 * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_ 765 * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero. 766 */ 767 png_uint_32 x_pixels_per_unit; /* horizontal pixel density */ 768 png_uint_32 y_pixels_per_unit; /* vertical pixel density */ 769 png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */ 770#endif 771 772#if defined(PNG_hIST_SUPPORTED) 773 /* The hIST chunk contains the relative frequency or importance of the 774 * various palette entries, so that a viewer can intelligently select a 775 * reduced-color palette, if required. Data is an array of "num_palette" 776 * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST) 777 * is non-zero. 778 */ 779 png_uint_16p hist; 780#endif 781 782#ifdef PNG_cHRM_SUPPORTED 783 /* The cHRM chunk describes the CIE color characteristics of the monitor 784 * on which the PNG was created. This data allows the viewer to do gamut 785 * mapping of the input image to ensure that the viewer sees the same 786 * colors in the image as the creator. Values are in the range 787 * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero. 788 */ 789#ifdef PNG_FLOATING_POINT_SUPPORTED 790 float x_white; 791 float y_white; 792 float x_red; 793 float y_red; 794 float x_green; 795 float y_green; 796 float x_blue; 797 float y_blue; 798#endif 799#endif 800 801#if defined(PNG_pCAL_SUPPORTED) 802 /* The pCAL chunk describes a transformation between the stored pixel 803 * values and original physical data values used to create the image. 804 * The integer range [0, 2^bit_depth - 1] maps to the floating-point 805 * range given by [pcal_X0, pcal_X1], and are further transformed by a 806 * (possibly non-linear) transformation function given by "pcal_type" 807 * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_ 808 * defines below, and the PNG-Group's PNG extensions document for a 809 * complete description of the transformations and how they should be 810 * implemented, and for a description of the ASCII parameter strings. 811 * Data values are valid if (valid & PNG_INFO_pCAL) non-zero. 812 */ 813 png_charp pcal_purpose; /* pCAL chunk description string */ 814 png_int_32 pcal_X0; /* minimum value */ 815 png_int_32 pcal_X1; /* maximum value */ 816 png_charp pcal_units; /* Latin-1 string giving physical units */ 817 png_charpp pcal_params; /* ASCII strings containing parameter values */ 818 png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */ 819 png_byte pcal_nparams; /* number of parameters given in pcal_params */ 820#endif 821 822/* New members added in libpng-1.0.6 */ 823#ifdef PNG_FREE_ME_SUPPORTED 824 png_uint_32 free_me; /* flags items libpng is responsible for freeing */ 825#endif 826 827#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) 828 /* storage for unknown chunks that the library doesn't recognize. */ 829 png_unknown_chunkp unknown_chunks; 830 png_size_t unknown_chunks_num; 831#endif 832 833#if defined(PNG_iCCP_SUPPORTED) 834 /* iCCP chunk data. */ 835 png_charp iccp_name; /* profile name */ 836 png_charp iccp_profile; /* International Color Consortium profile data */ 837 /* Note to maintainer: should be png_bytep */ 838 png_uint_32 iccp_proflen; /* ICC profile data length */ 839 png_byte iccp_compression; /* Always zero */ 840#endif 841 842#if defined(PNG_sPLT_SUPPORTED) 843 /* data on sPLT chunks (there may be more than one). */ 844 png_sPLT_tp splt_palettes; 845 png_uint_32 splt_palettes_num; 846#endif 847 848#if defined(PNG_sCAL_SUPPORTED) 849 /* The sCAL chunk describes the actual physical dimensions of the 850 * subject matter of the graphic. The chunk contains a unit specification 851 * a byte value, and two ASCII strings representing floating-point 852 * values. The values are width and height corresponsing to one pixel 853 * in the image. This external representation is converted to double 854 * here. Data values are valid if (valid & PNG_INFO_sCAL) is non-zero. 855 */ 856 png_byte scal_unit; /* unit of physical scale */ 857#ifdef PNG_FLOATING_POINT_SUPPORTED 858 double scal_pixel_width; /* width of one pixel */ 859 double scal_pixel_height; /* height of one pixel */ 860#endif 861#ifdef PNG_FIXED_POINT_SUPPORTED 862 png_charp scal_s_width; /* string containing height */ 863 png_charp scal_s_height; /* string containing width */ 864#endif 865#endif 866 867#if defined(PNG_INFO_IMAGE_SUPPORTED) 868 /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */ 869 /* Data valid if (valid & PNG_INFO_IDAT) non-zero */ 870 png_bytepp row_pointers; /* the image bits */ 871#endif 872 873#if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED) 874 png_fixed_point int_gamma; /* gamma of image, if (valid & PNG_INFO_gAMA) */ 875#endif 876 877#if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED) 878 png_fixed_point int_x_white; 879 png_fixed_point int_y_white; 880 png_fixed_point int_x_red; 881 png_fixed_point int_y_red; 882 png_fixed_point int_x_green; 883 png_fixed_point int_y_green; 884 png_fixed_point int_x_blue; 885 png_fixed_point int_y_blue; 886#endif 887 888} png_info; 889 890typedef png_info FAR * png_infop; 891typedef png_info FAR * FAR * png_infopp; 892 893/* Maximum positive integer used in PNG is (2^31)-1 */ 894#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL) 895#define PNG_UINT_32_MAX ((png_uint_32)(-1)) 896#define PNG_SIZE_MAX ((png_size_t)(-1)) 897/* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */ 898#define PNG_MAX_UINT PNG_UINT_31_MAX 899 900/* These describe the color_type field in png_info. */ 901/* color type masks */ 902#define PNG_COLOR_MASK_PALETTE 1 903#define PNG_COLOR_MASK_COLOR 2 904#define PNG_COLOR_MASK_ALPHA 4 905 906/* color types. Note that not all combinations are legal */ 907#define PNG_COLOR_TYPE_GRAY 0 908#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE) 909#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR) 910#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA) 911#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA) 912/* aliases */ 913#define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA 914#define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA 915 916/* This is for compression type. PNG 1.0-1.2 only define the single type. */ 917#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */ 918#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE 919 920/* This is for filter type. PNG 1.0-1.2 only define the single type. */ 921#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */ 922#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */ 923#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE 924 925/* These are for the interlacing type. These values should NOT be changed. */ 926#define PNG_INTERLACE_NONE 0 /* Non-interlaced image */ 927#define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */ 928#define PNG_INTERLACE_LAST 2 /* Not a valid value */ 929 930/* These are for the oFFs chunk. These values should NOT be changed. */ 931#define PNG_OFFSET_PIXEL 0 /* Offset in pixels */ 932#define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */ 933#define PNG_OFFSET_LAST 2 /* Not a valid value */ 934 935/* These are for the pCAL chunk. These values should NOT be changed. */ 936#define PNG_EQUATION_LINEAR 0 /* Linear transformation */ 937#define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */ 938#define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */ 939#define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */ 940#define PNG_EQUATION_LAST 4 /* Not a valid value */ 941 942/* These are for the sCAL chunk. These values should NOT be changed. */ 943#define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */ 944#define PNG_SCALE_METER 1 /* meters per pixel */ 945#define PNG_SCALE_RADIAN 2 /* radians per pixel */ 946#define PNG_SCALE_LAST 3 /* Not a valid value */ 947 948/* These are for the pHYs chunk. These values should NOT be changed. */ 949#define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */ 950#define PNG_RESOLUTION_METER 1 /* pixels/meter */ 951#define PNG_RESOLUTION_LAST 2 /* Not a valid value */ 952 953/* These are for the sRGB chunk. These values should NOT be changed. */ 954#define PNG_sRGB_INTENT_PERCEPTUAL 0 955#define PNG_sRGB_INTENT_RELATIVE 1 956#define PNG_sRGB_INTENT_SATURATION 2 957#define PNG_sRGB_INTENT_ABSOLUTE 3 958#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */ 959 960/* This is for text chunks */ 961#define PNG_KEYWORD_MAX_LENGTH 79 962 963/* Maximum number of entries in PLTE/sPLT/tRNS arrays */ 964#define PNG_MAX_PALETTE_LENGTH 256 965 966/* These determine if an ancillary chunk's data has been successfully read 967 * from the PNG header, or if the application has filled in the corresponding 968 * data in the info_struct to be written into the output file. The values 969 * of the PNG_INFO_<chunk> defines should NOT be changed. 970 */ 971#define PNG_INFO_gAMA 0x0001 972#define PNG_INFO_sBIT 0x0002 973#define PNG_INFO_cHRM 0x0004 974#define PNG_INFO_PLTE 0x0008 975#define PNG_INFO_tRNS 0x0010 976#define PNG_INFO_bKGD 0x0020 977#define PNG_INFO_hIST 0x0040 978#define PNG_INFO_pHYs 0x0080 979#define PNG_INFO_oFFs 0x0100 980#define PNG_INFO_tIME 0x0200 981#define PNG_INFO_pCAL 0x0400 982#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ 983#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ 984#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ 985#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ 986#define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */ 987 988/* This is used for the transformation routines, as some of them 989 * change these values for the row. It also should enable using 990 * the routines for other purposes. 991 */ 992typedef struct png_row_info_struct 993{ 994 png_uint_32 width; /* width of row */ 995 png_uint_32 rowbytes; /* number of bytes in row */ 996 png_byte color_type; /* color type of row */ 997 png_byte bit_depth; /* bit depth of row */ 998 png_byte channels; /* number of channels (1, 2, 3, or 4) */ 999 png_byte pixel_depth; /* bits per pixel (depth * channels) */ 1000} png_row_info; 1001 1002typedef png_row_info FAR * png_row_infop; 1003typedef png_row_info FAR * FAR * png_row_infopp; 1004 1005/* These are the function types for the I/O functions and for the functions 1006 * that allow the user to override the default I/O functions with his or her 1007 * own. The png_error_ptr type should match that of user-supplied warning 1008 * and error functions, while the png_rw_ptr type should match that of the 1009 * user read/write data functions. 1010 */ 1011typedef struct png_struct_def png_struct; 1012typedef png_struct FAR * png_structp; 1013 1014typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp)); 1015typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); 1016typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp)); 1017typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32, 1018 int)); 1019typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32, 1020 int)); 1021 1022#ifdef PNG_PROGRESSIVE_READ_SUPPORTED 1023typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop)); 1024typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop)); 1025typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep, 1026 png_uint_32, int)); 1027#endif 1028 1029#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ 1030 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ 1031 defined(PNG_LEGACY_SUPPORTED) 1032typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp, 1033 png_row_infop, png_bytep)); 1034#endif 1035 1036#if defined(PNG_USER_CHUNKS_SUPPORTED) 1037typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp)); 1038#endif 1039#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) 1040typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); 1041#endif 1042 1043/* Transform masks for the high-level interface */ 1044#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ 1045#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ 1046#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ 1047#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ 1048#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ 1049#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ 1050#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ 1051#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ 1052#define PNG_TRANSFORM_BGR 0x0080 /* read and write */ 1053#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ 1054#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ 1055#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ 1056#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */ 1057 1058/* Flags for MNG supported features */ 1059#define PNG_FLAG_MNG_EMPTY_PLTE 0x01 1060#define PNG_FLAG_MNG_FILTER_64 0x04 1061#define PNG_ALL_MNG_FEATURES 0x05 1062 1063typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); 1064typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); 1065 1066/* The structure that holds the information to read and write PNG files. 1067 * The only people who need to care about what is inside of this are the 1068 * people who will be modifying the library for their own special needs. 1069 * It should NOT be accessed directly by an application, except to store 1070 * the jmp_buf. 1071 */ 1072 1073struct png_struct_def 1074{ 1075#ifdef PNG_SETJMP_SUPPORTED 1076 jmp_buf jmpbuf; /* used in png_error */ 1077#endif 1078 png_error_ptr error_fn; /* function for printing errors and aborting */ 1079 png_error_ptr warning_fn; /* function for printing warnings */ 1080 png_voidp error_ptr; /* user supplied struct for error functions */ 1081 png_rw_ptr write_data_fn; /* function for writing output data */ 1082 png_rw_ptr read_data_fn; /* function for reading input data */ 1083 png_voidp io_ptr; /* ptr to application struct for I/O functions */ 1084 1085#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) 1086 png_user_transform_ptr read_user_transform_fn; /* user read transform */ 1087#endif 1088 1089#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) 1090 png_user_transform_ptr write_user_transform_fn; /* user write transform */ 1091#endif 1092 1093/* These were added in libpng-1.0.2 */ 1094#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) 1095#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ 1096 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) 1097 png_voidp user_transform_ptr; /* user supplied struct for user transform */ 1098 png_byte user_transform_depth; /* bit depth of user transformed pixels */ 1099 png_byte user_transform_channels; /* channels in user transformed pixels */ 1100#endif 1101#endif 1102 1103 png_uint_32 mode; /* tells us where we are in the PNG file */ 1104 png_uint_32 flags; /* flags indicating various things to libpng */ 1105 png_uint_32 transformations; /* which transformations to perform */ 1106 1107 z_stream zstream; /* pointer to decompression structure (below) */ 1108 png_bytep zbuf; /* buffer for zlib */ 1109 png_size_t zbuf_size; /* size of zbuf */ 1110 int zlib_level; /* holds zlib compression level */ 1111 int zlib_method; /* holds zlib compression method */ 1112 int zlib_window_bits; /* holds zlib compression window bits */ 1113 int zlib_mem_level; /* holds zlib compression memory level */ 1114 int zlib_strategy; /* holds zlib compression strategy */ 1115 1116 png_uint_32 width; /* width of image in pixels */ 1117 png_uint_32 height; /* height of image in pixels */ 1118 png_uint_32 num_rows; /* number of rows in current pass */ 1119 png_uint_32 usr_width; /* width of row at start of write */ 1120 png_uint_32 rowbytes; /* size of row in bytes */ 1121 png_uint_32 irowbytes; /* size of current interlaced row in bytes */ 1122 png_uint_32 iwidth; /* width of current interlaced row in pixels */ 1123 png_uint_32 row_number; /* current row in interlace pass */ 1124 png_bytep prev_row; /* buffer to save previous (unfiltered) row */ 1125 png_bytep row_buf; /* buffer to save current (unfiltered) row */ 1126 png_bytep sub_row; /* buffer to save "sub" row when filtering */ 1127 png_bytep up_row; /* buffer to save "up" row when filtering */ 1128 png_bytep avg_row; /* buffer to save "avg" row when filtering */ 1129 png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ 1130 png_row_info row_info; /* used for transformation routines */ 1131 1132 …
Large files files are truncated, but you can click here to view the full file