1 2 /* png.h - header file for PNG reference library 3 * 4 * libpng version 1.2.12 - June 27, 2006 5 * Copyright (c) 1998-2006 Glenn Randers-Pehrson 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 8 * 9 * Authors and maintainers: 10 * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat 11 * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger 12 * libpng versions 0.97, January 1998, through 1.2.12 - June 27, 2006: Glenn 13 * See also "Contributing Authors", below. 14 * 15 * Note about libpng version numbers: 16 * 17 * Due to various miscommunications, unforeseen code incompatibilities 18 * and occasional factors outside the authors' control, version numbering 19 * on the library has not always been consistent and straightforward. 20 * The following table summarizes matters since version 0.89c, which was 21 * the first widely used release: 22 * 23 * source png.h png.h shared-lib 24 * version string int version 25 * ------- ------ ----- ---------- 26 * 0.89c "1.0 beta 3" 0.89 89 1.0.89 27 * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] 28 * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] 29 * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] 30 * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] 31 * 0.97c 0.97 97 2.0.97 32 * 0.98 0.98 98 2.0.98 33 * 0.99 0.99 98 2.0.99 34 * 0.99a-m 0.99 99 2.0.99 35 * 1.00 1.00 100 2.1.0 [100 should be 10000] 36 * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] 37 * 1.0.1 png.h string is 10001 2.1.0 38 * 1.0.1a-e identical to the 10002 from here on, the shared library 39 * 1.0.2 source version) 10002 is 2.V where V is the source code 40 * 1.0.2a-b 10003 version, except as noted. 41 * 1.0.3 10003 42 * 1.0.3a-d 10004 43 * 1.0.4 10004 44 * 1.0.4a-f 10005 45 * 1.0.5 (+ 2 patches) 10005 46 * 1.0.5a-d 10006 47 * 1.0.5e-r 10100 (not source compatible) 48 * 1.0.5s-v 10006 (not binary compatible) 49 * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) 50 * 1.0.6d-f 10007 (still binary incompatible) 51 * 1.0.6g 10007 52 * 1.0.6h 10007 10.6h (testing xy.z so-numbering) 53 * 1.0.6i 10007 10.6i 54 * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) 55 * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) 56 * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) 57 * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) 58 * 1.0.7 1 10007 (still compatible) 59 * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 60 * 1.0.8rc1 1 10008 2.1.0.8rc1 61 * 1.0.8 1 10008 2.1.0.8 62 * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 63 * 1.0.9rc1 1 10009 2.1.0.9rc1 64 * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 65 * 1.0.9rc2 1 10009 2.1.0.9rc2 66 * 1.0.9 1 10009 2.1.0.9 67 * 1.0.10beta1 1 10010 2.1.0.10beta1 68 * 1.0.10rc1 1 10010 2.1.0.10rc1 69 * 1.0.10 1 10010 2.1.0.10 70 * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 71 * 1.0.11rc1 1 10011 2.1.0.11rc1 72 * 1.0.11 1 10011 2.1.0.11 73 * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 74 * 1.0.12rc1 2 10012 2.1.0.12rc1 75 * 1.0.12 2 10012 2.1.0.12 76 * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned) 77 * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 78 * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 79 * 1.2.0rc1 3 10200 3.1.2.0rc1 80 * 1.2.0 3 10200 3.1.2.0 81 * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4 82 * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 83 * 1.2.1 3 10201 3.1.2.1 84 * 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 85 * 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 86 * 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 87 * 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 88 * 1.0.13 10 10013 10.so.0.1.0.13 89 * 1.2.2 12 10202 12.so.0.1.2.2 90 * 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 91 * 1.2.3 12 10203 12.so.0.1.2.3 92 * 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 93 * 1.0.14rc1 13 10014 10.so.0.1.0.14rc1 94 * 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 95 * 1.0.14 10 10014 10.so.0.1.0.14 96 * 1.2.4 13 10204 12.so.0.1.2.4 97 * 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 98 * 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3 99 * 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3 100 * 1.0.15 10 10015 10.so.0.1.0.15 101 * 1.2.5 13 10205 12.so.0.1.2.5 102 * 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 103 * 1.0.16 10 10016 10.so.0.1.0.16 104 * 1.2.6 13 10206 12.so.0.1.2.6 105 * 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 106 * 1.0.17rc1 10 10017 10.so.0.1.0.17rc1 107 * 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 108 * 1.0.17 10 10017 10.so.0.1.0.17 109 * 1.2.7 13 10207 12.so.0.1.2.7 110 * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 111 * 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5 112 * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 113 * 1.0.18 10 10018 10.so.0.1.0.18 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 * 130 * Henceforth the source version will match the shared-library major 131 * and minor numbers; the shared-library major version number will be 132 * used for changes in backward compatibility, as it is intended. The 133 * PNG_LIBPNG_VER macro, which is not used within libpng but is available 134 * for applications, is an unsigned integer of the form xyyzz corresponding 135 * to the source version x.y.z (leading zeros in y and z). Beta versions 136 * were given the previous public release number plus a letter, until 137 * version 1.0.6j; from then on they were given the upcoming public 138 * release number plus "betaNN" or "rcN". 139 * 140 * Binary incompatibility exists only when applications make direct access 141 * to the info_ptr or png_ptr members through png.h, and the compiled 142 * application is loaded with a different version of the library. 143 * 144 * DLLNUM will change each time there are forward or backward changes 145 * in binary compatibility (e.g., when a new feature is added). 146 * 147 * See libpng.txt or libpng.3 for more information. The PNG specification 148 * is available as a W3C Recommendation and as an ISO Specification, 149 * <http://www.w3.org/TR/2003/REC-PNG-20031110/ 150 */ 151 152 /* 153 * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: 154 * 155 * If you modify libpng you may insert additional notices immediately following 156 * this sentence. 157 * 158 * libpng versions 1.2.6, August 15, 2004, through 1.2.12, June 27, 2006, are 159 * Copyright (c) 2004, 2006 Glenn Randers-Pehrson, and are 160 * distributed according to the same disclaimer and license as libpng-1.2.5 161 * with the following individual added to the list of Contributing Authors: 162 * 163 * Cosmin Truta 164 * 165 * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are 166 * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are 167 * distributed according to the same disclaimer and license as libpng-1.0.6 168 * with the following individuals added to the list of Contributing Authors: 169 * 170 * Simon-Pierre Cadieux 171 * Eric S. Raymond 172 * Gilles Vollant 173 * 174 * and with the following additions to the disclaimer: 175 * 176 * There is no warranty against interference with your enjoyment of the 177 * library or against infringement. There is no warranty that our 178 * efforts or the library will fulfill any of your particular purposes 179 * or needs. This library is provided with all faults, and the entire 180 * risk of satisfactory quality, performance, accuracy, and effort is with 181 * the user. 182 * 183 * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are 184 * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are 185 * distributed according to the same disclaimer and license as libpng-0.96, 186 * with the following individuals added to the list of Contributing Authors: 187 * 188 * Tom Lane 189 * Glenn Randers-Pehrson 190 * Willem van Schaik 191 * 192 * libpng versions 0.89, June 1996, through 0.96, May 1997, are 193 * Copyright (c) 1996, 1997 Andreas Dilger 194 * Distributed according to the same disclaimer and license as libpng-0.88, 195 * with the following individuals added to the list of Contributing Authors: 196 * 197 * John Bowler 198 * Kevin Bracey 199 * Sam Bushell 200 * Magnus Holmgren 201 * Greg Roelofs 202 * Tom Tanner 203 * 204 * libpng versions 0.5, May 1995, through 0.88, January 1996, are 205 * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. 206 * 207 * For the purposes of this copyright and license, "Contributing Authors" 208 * is defined as the following set of individuals: 209 * 210 * Andreas Dilger 211 * Dave Martindale 212 * Guy Eric Schalnat 213 * Paul Schmidt 214 * Tim Wegner 215 * 216 * The PNG Reference Library is supplied "AS IS". The Contributing Authors 217 * and Group 42, Inc. disclaim all warranties, expressed or implied, 218 * including, without limitation, the warranties of merchantability and of 219 * fitness for any purpose. The Contributing Authors and Group 42, Inc. 220 * assume no liability for direct, indirect, incidental, special, exemplary, 221 * or consequential damages, which may result from the use of the PNG 222 * Reference Library, even if advised of the possibility of such damage. 223 * 224 * Permission is hereby granted to use, copy, modify, and distribute this 225 * source code, or portions hereof, for any purpose, without fee, subject 226 * to the following restrictions: 227 * 228 * 1. The origin of this source code must not be misrepresented. 229 * 230 * 2. Altered versions must be plainly marked as such and 231 * must not be misrepresented as being the original source. 232 * 233 * 3. This Copyright notice may not be removed or altered from 234 * any source or altered source distribution. 235 * 236 * The Contributing Authors and Group 42, Inc. specifically permit, without 237 * fee, and encourage the use of this source code as a component to 238 * supporting the PNG file format in commercial products. If you use this 239 * source code in a product, acknowledgment is not required but would be 240 * appreciated. 241 */ 242 243 /* 244 * A "png_get_copyright" function is available, for convenient use in "about" 245 * boxes and the like: 246 * 247 * printf("%s",png_get_copyright(NULL)); 248 * 249 * Also, the PNG logo (in PNG format, of course) is supplied in the 250 * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). 251 */ 252 253 /* 254 * Libpng is OSI Certified Open Source Software. OSI Certified is a 255 * certification mark of the Open Source Initiative. 256 */ 257 258 /* 259 * The contributing authors would like to thank all those who helped 260 * with testing, bug fixes, and patience. This wouldn't have been 261 * possible without all of you. 262 * 263 * Thanks to Frank J. T. Wojcik for helping with the documentation. 264 */ 265 266 /* 267 * Y2K compliance in libpng: 268 * ========================= 269 * 270 * June 27, 2006 271 * 272 * Since the PNG Development group is an ad-hoc body, we can't make 273 * an official declaration. 274 * 275 * This is your unofficial assurance that libpng from version 0.71 and 276 * upward through 1.2.12 are Y2K compliant. It is my belief that earlier 277 * versions were also Y2K compliant. 278 * 279 * Libpng only has three year fields. One is a 2-byte unsigned integer 280 * that will hold years up to 65535. The other two hold the date in text 281 * format, and will hold years up to 9999. 282 * 283 * The integer is 284 * "png_uint_16 year" in png_time_struct. 285 * 286 * The strings are 287 * "png_charp time_buffer" in png_struct and 288 * "near_time_buffer", which is a local character string in png.c. 289 * 290 * There are seven time-related functions: 291 * png.c: png_convert_to_rfc_1123() in png.c 292 * (formerly png_convert_to_rfc_1152() in error) 293 * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c 294 * png_convert_from_time_t() in pngwrite.c 295 * png_get_tIME() in pngget.c 296 * png_handle_tIME() in pngrutil.c, called in pngread.c 297 * png_set_tIME() in pngset.c 298 * png_write_tIME() in pngwutil.c, called in pngwrite.c 299 * 300 * All handle dates properly in a Y2K environment. The 301 * png_convert_from_time_t() function calls gmtime() to convert from system 302 * clock time, which returns (year - 1900), which we properly convert to 303 * the full 4-digit year. There is a possibility that applications using 304 * libpng are not passing 4-digit years into the png_convert_to_rfc_1123() 305 * function, or that they are incorrectly passing only a 2-digit year 306 * instead of "year - 1900" into the png_convert_from_struct_tm() function, 307 * but this is not under our control. The libpng documentation has always 308 * stated that it works with 4-digit years, and the APIs have been 309 * documented as such. 310 * 311 * The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned 312 * integer to hold the year, and can hold years as large as 65535. 313 * 314 * zlib, upon which libpng depends, is also Y2K compliant. It contains 315 * no date-related code. 316 * 317 * Glenn Randers-Pehrson 318 * libpng maintainer 319 * PNG Development Group 320 */ 321 322 #ifndef PNG_H 323 #define PNG_H 324 325 /* This is not the place to learn how to use libpng. The file libpng.txt 326 * describes how to use libpng, and the file example.c summarizes it 327 * with some code on which to build. This file is useful for looking 328 * at the actual function definitions and structure components. 329 */ 330 331 /* Version information for png.h - this should match the version in png.c */ 332 #define PNG_LIBPNG_VER_STRING "1.2.12" 333 #define PNG_HEADER_VERSION_STRING \ 334 " libpng version 1.2.12 - June 27, 2006 (header)\n" 335 336 #define PNG_LIBPNG_VER_SONUM 0 337 #define PNG_LIBPNG_VER_DLLNUM 13 338 339 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ 340 #define PNG_LIBPNG_VER_MAJOR 1 341 #define PNG_LIBPNG_VER_MINOR 2 342 #define PNG_LIBPNG_VER_RELEASE 12 343 /* This should match the numeric part of the final component of 344 * PNG_LIBPNG_VER_STRING, omitting any leading zero: */ 345 346 #define PNG_LIBPNG_VER_BUILD 0 347 348 /* Release Status */ 349 #define PNG_LIBPNG_BUILD_ALPHA 1 350 #define PNG_LIBPNG_BUILD_BETA 2 351 #define PNG_LIBPNG_BUILD_RC 3 352 #define PNG_LIBPNG_BUILD_STABLE 4 353 #define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7 354 355 /* Release-Specific Flags */ 356 #define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with 357 PNG_LIBPNG_BUILD_STABLE only */ 358 #define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with 359 PNG_LIBPNG_BUILD_SPECIAL */ 360 #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with 361 PNG_LIBPNG_BUILD_PRIVATE */ 362 363 #define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE 364 365 /* Careful here. At one time, Guy wanted to use 082, but that would be octal. 366 * We must not include leading zeros. 367 * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only 368 * version 1.0.0 was mis-numbered 100 instead of 10000). From 369 * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ 370 #define PNG_LIBPNG_VER 10212 /* 1.2.12 */ 371 372 #ifndef PNG_VERSION_INFO_ONLY 373 /* include the compression library's header */ 374 #include "zlib.h" 375 #endif 376 377 /* include all user configurable info, including optional assembler routines */ 378 #include "pngconf.h" 379 380 /* 381 * Added at libpng-1.2.8 */ 382 /* Ref MSDN: Private as priority over Special 383 * VS_FF_PRIVATEBUILD File *was not* built using standard release 384 * procedures. If this value is given, the StringFileInfo block must 385 * contain a PrivateBuild string. 386 * 387 * VS_FF_SPECIALBUILD File *was* built by the original company using 388 * standard release procedures but is a variation of the standard 389 * file of the same version number. If this value is given, the 390 * StringFileInfo block must contain a SpecialBuild string. 391 */ 392 393 #if defined(PNG_USER_PRIVATEBUILD) 394 # define PNG_LIBPNG_BUILD_TYPE \ 395 (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE) 396 #else 397 # if defined(PNG_LIBPNG_SPECIALBUILD) 398 # define PNG_LIBPNG_BUILD_TYPE \ 399 (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL) 400 # else 401 # define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE) 402 # endif 403 #endif 404 405 #ifndef PNG_VERSION_INFO_ONLY 406 407 /* Inhibit C++ name-mangling for libpng functions but not for system calls. */ 408 #ifdef __cplusplus 409 extern "C" { 410 #endif /* __cplusplus */ 411 412 /* This file is arranged in several sections. The first section contains 413 * structure and type definitions. The second section contains the external 414 * library functions, while the third has the internal library functions, 415 * which applications aren't expected to use directly. 416 */ 417 418 #ifndef PNG_NO_TYPECAST_NULL 419 #define int_p_NULL (int *)NULL 420 #define png_bytep_NULL (png_bytep)NULL 421 #define png_bytepp_NULL (png_bytepp)NULL 422 #define png_doublep_NULL (png_doublep)NULL 423 #define png_error_ptr_NULL (png_error_ptr)NULL 424 #define png_flush_ptr_NULL (png_flush_ptr)NULL 425 #define png_free_ptr_NULL (png_free_ptr)NULL 426 #define png_infopp_NULL (png_infopp)NULL 427 #define png_malloc_ptr_NULL (png_malloc_ptr)NULL 428 #define png_read_status_ptr_NULL (png_read_status_ptr)NULL 429 #define png_rw_ptr_NULL (png_rw_ptr)NULL 430 #define png_structp_NULL (png_structp)NULL 431 #define png_uint_16p_NULL (png_uint_16p)NULL 432 #define png_voidp_NULL (png_voidp)NULL 433 #define png_write_status_ptr_NULL (png_write_status_ptr)NULL 434 #else 435 #define int_p_NULL NULL 436 #define png_bytep_NULL NULL 437 #define png_bytepp_NULL NULL 438 #define png_doublep_NULL NULL 439 #define png_error_ptr_NULL NULL 440 #define png_flush_ptr_NULL NULL 441 #define png_free_ptr_NULL NULL 442 #define png_infopp_NULL NULL 443 #define png_malloc_ptr_NULL NULL 444 #define png_read_status_ptr_NULL NULL 445 #define png_rw_ptr_NULL NULL 446 #define png_structp_NULL NULL 447 #define png_uint_16p_NULL NULL 448 #define png_voidp_NULL NULL 449 #define png_write_status_ptr_NULL NULL 450 #endif 451 452 /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ 453 #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) 454 /* Version information for C files, stored in png.c. This had better match 455 * the version above. 456 */ 457 #ifdef PNG_USE_GLOBAL_ARRAYS 458 PNG_EXPORT_VAR (const char) png_libpng_ver[18]; 459 /* need room for 99.99.99beta99z */ 460 #else 461 #define png_libpng_ver png_get_header_ver(NULL) 462 #endif 463 464 #ifdef PNG_USE_GLOBAL_ARRAYS 465 /* This was removed in version 1.0.5c */ 466 /* Structures to facilitate easy interlacing. See png.c for more details */ 467 PNG_EXPORT_VAR (const int FARDATA) png_pass_start[7]; 468 PNG_EXPORT_VAR (const int FARDATA) png_pass_inc[7]; 469 PNG_EXPORT_VAR (const int FARDATA) png_pass_ystart[7]; 470 PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7]; 471 PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7]; 472 PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7]; 473 #ifdef PNG_USE_PNGGCCRD 474 PNG_EXPORT_VAR (const int FARDATA) png_pass_width[7]; 475 #endif 476 /* This isn't currently used. If you need it, see png.c for more details. 477 PNG_EXPORT_VAR (const int FARDATA) png_pass_height[7]; 478 */ 479 #endif 480 481 #endif /* PNG_NO_EXTERN */ 482 483 /* Three color definitions. The order of the red, green, and blue, (and the 484 * exact size) is not important, although the size of the fields need to 485 * be png_byte or png_uint_16 (as defined below). 486 */ 487 typedef struct png_color_struct 488 { 489 png_byte red; 490 png_byte green; 491 png_byte blue; 492 } png_color; 493 typedef png_color FAR * png_colorp; 494 typedef png_color FAR * FAR * png_colorpp; 495 496 typedef struct png_color_16_struct 497 { 498 png_byte index; /* used for palette files */ 499 png_uint_16 red; /* for use in red green blue files */ 500 png_uint_16 green; 501 png_uint_16 blue; 502 png_uint_16 gray; /* for use in grayscale files */ 503 } png_color_16; 504 typedef png_color_16 FAR * png_color_16p; 505 typedef png_color_16 FAR * FAR * png_color_16pp; 506 507 typedef struct png_color_8_struct 508 { 509 png_byte red; /* for use in red green blue files */ 510 png_byte green; 511 png_byte blue; 512 png_byte gray; /* for use in grayscale files */ 513 png_byte alpha; /* for alpha channel files */ 514 } png_color_8; 515 typedef png_color_8 FAR * png_color_8p; 516 typedef png_color_8 FAR * FAR * png_color_8pp; 517 518 /* 519 * The following two structures are used for the in-core representation 520 * of sPLT chunks. 521 */ 522 typedef struct png_sPLT_entry_struct 523 { 524 png_uint_16 red; 525 png_uint_16 green; 526 png_uint_16 blue; 527 png_uint_16 alpha; 528 png_uint_16 frequency; 529 } png_sPLT_entry; 530 typedef png_sPLT_entry FAR * png_sPLT_entryp; 531 typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp; 532 533 /* When the depth of the sPLT palette is 8 bits, the color and alpha samples 534 * occupy the LSB of their respective members, and the MSB of each member 535 * is zero-filled. The frequency member always occupies the full 16 bits. 536 */ 537 538 typedef struct png_sPLT_struct 539 { 540 png_charp name; /* palette name */ 541 png_byte depth; /* depth of palette samples */ 542 png_sPLT_entryp entries; /* palette entries */ 543 png_int_32 nentries; /* number of palette entries */ 544 } png_sPLT_t; 545 typedef png_sPLT_t FAR * png_sPLT_tp; 546 typedef png_sPLT_t FAR * FAR * png_sPLT_tpp; 547 548 #ifdef PNG_TEXT_SUPPORTED 549 /* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, 550 * and whether that contents is compressed or not. The "key" field 551 * points to a regular zero-terminated C string. The "text", "lang", and 552 * "lang_key" fields can be regular C strings, empty strings, or NULL pointers. 553 * However, the * structure returned by png_get_text() will always contain 554 * regular zero-terminated C strings (possibly empty), never NULL pointers, 555 * so they can be safely used in printf() and other string-handling functions. 556 */ 557 typedef struct png_text_struct 558 { 559 int compression; /* compression value: 560 -1: tEXt, none 561 0: zTXt, deflate 562 1: iTXt, none 563 2: iTXt, deflate */ 564 png_charp key; /* keyword, 1-79 character description of "text" */ 565 png_charp text; /* comment, may be an empty string (ie "") 566 or a NULL pointer */ 567 png_size_t text_length; /* length of the text string */ 568 #ifdef PNG_iTXt_SUPPORTED 569 png_size_t itxt_length; /* length of the itxt string */ 570 png_charp lang; /* language code, 0-79 characters 571 or a NULL pointer */ 572 png_charp lang_key; /* keyword translated UTF-8 string, 0 or more 573 chars or a NULL pointer */ 574 #endif 575 } png_text; 576 typedef png_text FAR * png_textp; 577 typedef png_text FAR * FAR * png_textpp; 578 #endif 579 580 /* Supported compression types for text in PNG files (tEXt, and zTXt). 581 * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */ 582 #define PNG_TEXT_COMPRESSION_NONE_WR -3 583 #define PNG_TEXT_COMPRESSION_zTXt_WR -2 584 #define PNG_TEXT_COMPRESSION_NONE -1 585 #define PNG_TEXT_COMPRESSION_zTXt 0 586 #define PNG_ITXT_COMPRESSION_NONE 1 587 #define PNG_ITXT_COMPRESSION_zTXt 2 588 #define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */ 589 590 /* png_time is a way to hold the time in an machine independent way. 591 * Two conversions are provided, both from time_t and struct tm. There 592 * is no portable way to convert to either of these structures, as far 593 * as I know. If you know of a portable way, send it to me. As a side 594 * note - PNG has always been Year 2000 compliant! 595 */ 596 typedef struct png_time_struct 597 { 598 png_uint_16 year; /* full year, as in, 1995 */ 599 png_byte month; /* month of year, 1 - 12 */ 600 png_byte day; /* day of month, 1 - 31 */ 601 png_byte hour; /* hour of day, 0 - 23 */ 602 png_byte minute; /* minute of hour, 0 - 59 */ 603 png_byte second; /* second of minute, 0 - 60 (for leap seconds) */ 604 } png_time; 605 typedef png_time FAR * png_timep; 606 typedef png_time FAR * FAR * png_timepp; 607 608 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) 609 /* png_unknown_chunk is a structure to hold queued chunks for which there is 610 * no specific support. The idea is that we can use this to queue 611 * up private chunks for output even though the library doesn't actually 612 * know about their semantics. 613 */ 614 typedef struct png_unknown_chunk_t 615 { 616 png_byte name[5]; 617 png_byte *data; 618 png_size_t size; 619 620 /* libpng-using applications should NOT directly modify this byte. */ 621 png_byte location; /* mode of operation at read time */ 622 } 623 png_unknown_chunk; 624 typedef png_unknown_chunk FAR * png_unknown_chunkp; 625 typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp; 626 #endif 627 628 /* png_info is a structure that holds the information in a PNG file so 629 * that the application can find out the characteristics of the image. 630 * If you are reading the file, this structure will tell you what is 631 * in the PNG file. If you are writing the file, fill in the information 632 * you want to put into the PNG file, then call png_write_info(). 633 * The names chosen should be very close to the PNG specification, so 634 * consult that document for information about the meaning of each field. 635 * 636 * With libpng < 0.95, it was only possible to directly set and read the 637 * the values in the png_info_struct, which meant that the contents and 638 * order of the values had to remain fixed. With libpng 0.95 and later, 639 * however, there are now functions that abstract the contents of 640 * png_info_struct from the application, so this makes it easier to use 641 * libpng with dynamic libraries, and even makes it possible to use 642 * libraries that don't have all of the libpng ancillary chunk-handing 643 * functionality. 644 * 645 * In any case, the order of the parameters in png_info_struct should NOT 646 * be changed for as long as possible to keep compatibility with applications 647 * that use the old direct-access method with png_info_struct. 648 * 649 * The following members may have allocated storage attached that should be 650 * cleaned up before the structure is discarded: palette, trans, text, 651 * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, 652 * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these 653 * are automatically freed when the info structure is deallocated, if they were 654 * allocated internally by libpng. This behavior can be changed by means 655 * of the png_data_freer() function. 656 * 657 * More allocation details: all the chunk-reading functions that 658 * change these members go through the corresponding png_set_* 659 * functions. A function to clear these members is available: see 660 * png_free_data(). The png_set_* functions do not depend on being 661 * able to point info structure members to any of the storage they are 662 * passed (they make their own copies), EXCEPT that the png_set_text 663 * functions use the same storage passed to them in the text_ptr or 664 * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns 665 * functions do not make their own copies. 666 */ 667 typedef struct png_info_struct 668 { 669 /* the following are necessary for every PNG file */ 670 png_uint_32 width; /* width of image in pixels (from IHDR) */ 671 png_uint_32 height; /* height of image in pixels (from IHDR) */ 672 png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ 673 png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */ 674 png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */ 675 png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */ 676 png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ 677 png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */ 678 png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */ 679 /* The following three should have been named *_method not *_type */ 680 png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */ 681 png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */ 682 png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ 683 684 /* The following is informational only on read, and not used on writes. */ 685 png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */ 686 png_byte pixel_depth; /* number of bits per pixel */ 687 png_byte spare_byte; /* to align the data, and for future use */ 688 png_byte signature[8]; /* magic bytes read by libpng from start of file */ 689 690 /* The rest of the data is optional. If you are reading, check the 691 * valid field to see if the information in these are valid. If you 692 * are writing, set the valid field to those chunks you want written, 693 * and initialize the appropriate fields below. 694 */ 695 696 #if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) 697 /* The gAMA chunk describes the gamma characteristics of the system 698 * on which the image was created, normally in the range [1.0, 2.5]. 699 * Data is valid if (valid & PNG_INFO_gAMA) is non-zero. 700 */ 701 float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */ 702 #endif 703 704 #if defined(PNG_sRGB_SUPPORTED) 705 /* GR-P, 0.96a */ 706 /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */ 707 png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */ 708 #endif 709 710 #if defined(PNG_TEXT_SUPPORTED) 711 /* The tEXt, and zTXt chunks contain human-readable textual data in 712 * uncompressed, compressed, and optionally compressed forms, respectively. 713 * The data in "text" is an array of pointers to uncompressed, 714 * null-terminated C strings. Each chunk has a keyword that describes the 715 * textual data contained in that chunk. Keywords are not required to be 716 * unique, and the text string may be empty. Any number of text chunks may 717 * be in an image. 718 */ 719 int num_text; /* number of comments read/to write */ 720 int max_text; /* current size of text array */ 721 png_textp text; /* array of comments read/to write */ 722 #endif /* PNG_TEXT_SUPPORTED */ 723 724 #if defined(PNG_tIME_SUPPORTED) 725 /* The tIME chunk holds the last time the displayed image data was 726 * modified. See the png_time struct for the contents of this struct. 727 */ 728 png_time mod_time; 729 #endif 730 731 #if defined(PNG_sBIT_SUPPORTED) 732 /* The sBIT chunk specifies the number of significant high-order bits 733 * in the pixel data. Values are in the range [1, bit_depth], and are 734 * only specified for the channels in the pixel data. The contents of 735 * the low-order bits is not specified. Data is valid if 736 * (valid & PNG_INFO_sBIT) is non-zero. 737 */ 738 png_color_8 sig_bit; /* significant bits in color channels */ 739 #endif 740 741 #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \ 742 defined(PNG_READ_BACKGROUND_SUPPORTED) 743 /* The tRNS chunk supplies transparency data for paletted images and 744 * other image types that don't need a full alpha channel. There are 745 * "num_trans" transparency values for a paletted image, stored in the 746 * same order as the palette colors, starting from index 0. Values 747 * for the data are in the range [0, 255], ranging from fully transparent 748 * to fully opaque, respectively. For non-paletted images, there is a 749 * single color specified that should be treated as fully transparent. 750 * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. 751 */ 752 png_bytep trans; /* transparent values for paletted image */ 753 png_color_16 trans_values; /* transparent color for non-palette image */ 754 #endif 755 756 #if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) 757 /* The bKGD chunk gives the suggested image background color if the 758 * display program does not have its own background color and the image 759 * is needs to composited onto a background before display. The colors 760 * in "background" are normally in the same color space/depth as the 761 * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero. 762 */ 763 png_color_16 background; 764 #endif 765 766 #if defined(PNG_oFFs_SUPPORTED) 767 /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards 768 * and downwards from the top-left corner of the display, page, or other 769 * application-specific co-ordinate space. See the PNG_OFFSET_ defines 770 * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero. 771 */ 772 png_int_32 x_offset; /* x offset on page */ 773 png_int_32 y_offset; /* y offset on page */ 774 png_byte offset_unit_type; /* offset units type */ 775 #endif 776 777 #if defined(PNG_pHYs_SUPPORTED) 778 /* The pHYs chunk gives the physical pixel density of the image for 779 * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_ 780 * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero. 781 */ 782 png_uint_32 x_pixels_per_unit; /* horizontal pixel density */ 783 png_uint_32 y_pixels_per_unit; /* vertical pixel density */ 784 png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */ 785 #endif 786 787 #if defined(PNG_hIST_SUPPORTED) 788 /* The hIST chunk contains the relative frequency or importance of the 789 * various palette entries, so that a viewer can intelligently select a 790 * reduced-color palette, if required. Data is an array of "num_palette" 791 * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST) 792 * is non-zero. 793 */ 794 png_uint_16p hist; 795 #endif 796 797 #ifdef PNG_cHRM_SUPPORTED 798 /* The cHRM chunk describes the CIE color characteristics of the monitor 799 * on which the PNG was created. This data allows the viewer to do gamut 800 * mapping of the input image to ensure that the viewer sees the same 801 * colors in the image as the creator. Values are in the range 802 * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero. 803 */ 804 #ifdef PNG_FLOATING_POINT_SUPPORTED 805 float x_white; 806 float y_white; 807 float x_red; 808 float y_red; 809 float x_green; 810 float y_green; 811 float x_blue; 812 float y_blue; 813 #endif 814 #endif 815 816 #if defined(PNG_pCAL_SUPPORTED) 817 /* The pCAL chunk describes a transformation between the stored pixel 818 * values and original physical data values used to create the image. 819 * The integer range [0, 2^bit_depth - 1] maps to the floating-point 820 * range given by [pcal_X0, pcal_X1], and are further transformed by a 821 * (possibly non-linear) transformation function given by "pcal_type" 822 * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_ 823 * defines below, and the PNG-Group's PNG extensions document for a 824 * complete description of the transformations and how they should be 825 * implemented, and for a description of the ASCII parameter strings. 826 * Data values are valid if (valid & PNG_INFO_pCAL) non-zero. 827 */ 828 png_charp pcal_purpose; /* pCAL chunk description string */ 829 png_int_32 pcal_X0; /* minimum value */ 830 png_int_32 pcal_X1; /* maximum value */ 831 png_charp pcal_units; /* Latin-1 string giving physical units */ 832 png_charpp pcal_params; /* ASCII strings containing parameter values */ 833 png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */ 834 png_byte pcal_nparams; /* number of parameters given in pcal_params */ 835 #endif 836 837 /* New members added in libpng-1.0.6 */ 838 #ifdef PNG_FREE_ME_SUPPORTED 839 png_uint_32 free_me; /* flags items libpng is responsible for freeing */ 840 #endif 841 842 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) 843 /* storage for unknown chunks that the library doesn't recognize. */ 844 png_unknown_chunkp unknown_chunks; 845 png_size_t unknown_chunks_num; 846 #endif 847 848 #if defined(PNG_iCCP_SUPPORTED) 849 /* iCCP chunk data. */ 850 png_charp iccp_name; /* profile name */ 851 png_charp iccp_profile; /* International Color Consortium profile data */ 852 /* Note to maintainer: should be png_bytep */ 853 png_uint_32 iccp_proflen; /* ICC profile data length */ 854 png_byte iccp_compression; /* Always zero */ 855 #endif 856 857 #if defined(PNG_sPLT_SUPPORTED) 858 /* data on sPLT chunks (there may be more than one). */ 859 png_sPLT_tp splt_palettes; 860 png_uint_32 splt_palettes_num; 861 #endif 862 863 #if defined(PNG_sCAL_SUPPORTED) 864 /* The sCAL chunk describes the actual physical dimensions of the 865 * subject matter of the graphic. The chunk contains a unit specification 866 * a byte value, and two ASCII strings representing floating-point 867 * values. The values are width and height corresponsing to one pixel 868 * in the image. This external representation is converted to double 869 * here. Data values are valid if (valid & PNG_INFO_sCAL) is non-zero. 870 */ 871 png_byte scal_unit; /* unit of physical scale */ 872 #ifdef PNG_FLOATING_POINT_SUPPORTED 873 double scal_pixel_width; /* width of one pixel */ 874 double scal_pixel_height; /* height of one pixel */ 875 #endif 876 #ifdef PNG_FIXED_POINT_SUPPORTED 877 png_charp scal_s_width; /* string containing height */ 878 png_charp scal_s_height; /* string containing width */ 879 #endif 880 #endif 881 882 #if defined(PNG_INFO_IMAGE_SUPPORTED) 883 /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */ 884 /* Data valid if (valid & PNG_INFO_IDAT) non-zero */ 885 png_bytepp row_pointers; /* the image bits */ 886 #endif 887 888 #if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED) 889 png_fixed_point int_gamma; /* gamma of image, if (valid & PNG_INFO_gAMA) */ 890 #endif 891 892 #if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED) 893 png_fixed_point int_x_white; 894 png_fixed_point int_y_white; 895 png_fixed_point int_x_red; 896 png_fixed_point int_y_red; 897 png_fixed_point int_x_green; 898 png_fixed_point int_y_green; 899 png_fixed_point int_x_blue; 900 png_fixed_point int_y_blue; 901 #endif 902 903 } png_info; 904 905 typedef png_info FAR * png_infop; 906 typedef png_info FAR * FAR * png_infopp; 907 908 /* Maximum positive integer used in PNG is (2^31)-1 */ 909 #define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL) 910 #define PNG_UINT_32_MAX ((png_uint_32)(-1)) 911 #define PNG_SIZE_MAX ((png_size_t)(-1)) 912 #if defined(PNG_1_0_X) || defined (PNG_1_2_X) 913 /* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */ 914 #define PNG_MAX_UINT PNG_UINT_31_MAX 915 #endif 916 917 /* These describe the color_type field in png_info. */ 918 /* color type masks */ 919 #define PNG_COLOR_MASK_PALETTE 1 920 #define PNG_COLOR_MASK_COLOR 2 921 #define PNG_COLOR_MASK_ALPHA 4 922 923 /* color types. Note that not all combinations are legal */ 924 #define PNG_COLOR_TYPE_GRAY 0 925 #define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE) 926 #define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR) 927 #define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA) 928 #define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA) 929 /* aliases */ 930 #define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA 931 #define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA 932 933 /* This is for compression type. PNG 1.0-1.2 only define the single type. */ 934 #define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */ 935 #define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE 936 937 /* This is for filter type. PNG 1.0-1.2 only define the single type. */ 938 #define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */ 939 #define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */ 940 #define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE 941 942 /* These are for the interlacing type. These values should NOT be changed. */ 943 #define PNG_INTERLACE_NONE 0 /* Non-interlaced image */ 944 #define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */ 945 #define PNG_INTERLACE_LAST 2 /* Not a valid value */ 946 947 /* These are for the oFFs chunk. These values should NOT be changed. */ 948 #define PNG_OFFSET_PIXEL 0 /* Offset in pixels */ 949 #define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */ 950 #define PNG_OFFSET_LAST 2 /* Not a valid value */ 951 952 /* These are for the pCAL chunk. These values should NOT be changed. */ 953 #define PNG_EQUATION_LINEAR 0 /* Linear transformation */ 954 #define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */ 955 #define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */ 956 #define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */ 957 #define PNG_EQUATION_LAST 4 /* Not a valid value */ 958 959 /* These are for the sCAL chunk. These values should NOT be changed. */ 960 #define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */ 961 #define PNG_SCALE_METER 1 /* meters per pixel */ 962 #define PNG_SCALE_RADIAN 2 /* radians per pixel */ 963 #define PNG_SCALE_LAST 3 /* Not a valid value */ 964 965 /* These are for the pHYs chunk. These values should NOT be changed. */ 966 #define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */ 967 #define PNG_RESOLUTION_METER 1 /* pixels/meter */ 968 #define PNG_RESOLUTION_LAST 2 /* Not a valid value */ 969 970 /* These are for the sRGB chunk. These values should NOT be changed. */ 971 #define PNG_sRGB_INTENT_PERCEPTUAL 0 972 #define PNG_sRGB_INTENT_RELATIVE 1 973 #define PNG_sRGB_INTENT_SATURATION 2 974 #define PNG_sRGB_INTENT_ABSOLUTE 3 975 #define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */ 976 977 /* This is for text chunks */ 978 #define PNG_KEYWORD_MAX_LENGTH 79 979 980 /* Maximum number of entries in PLTE/sPLT/tRNS arrays */ 981 #define PNG_MAX_PALETTE_LENGTH 256 982 983 /* These determine if an ancillary chunk's data has been successfully read 984 * from the PNG header, or if the application has filled in the corresponding 985 * data in the info_struct to be written into the output file. The values 986 * of the PNG_INFO_<chunk> defines should NOT be changed. 987 */ 988 #define PNG_INFO_gAMA 0x0001 989 #define PNG_INFO_sBIT 0x0002 990 #define PNG_INFO_cHRM 0x0004 991 #define PNG_INFO_PLTE 0x0008 992 #define PNG_INFO_tRNS 0x0010 993 #define PNG_INFO_bKGD 0x0020 994 #define PNG_INFO_hIST 0x0040 995 #define PNG_INFO_pHYs 0x0080 996 #define PNG_INFO_oFFs 0x0100 997 #define PNG_INFO_tIME 0x0200 998 #define PNG_INFO_pCAL 0x0400 999 #define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ 1000 #define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ 1001 #define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ 1002 #define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ 1003 #define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */ 1004 1005 /* This is used for the transformation routines, as some of them 1006 * change these values for the row. It also should enable using 1007 * the routines for other purposes. 1008 */ 1009 typedef struct png_row_info_struct 1010 { 1011 png_uint_32 width; /* width of row */ 1012 png_uint_32 rowbytes; /* number of bytes in row */ 1013 png_byte color_type; /* color type of row */ 1014 png_byte bit_depth; /* bit depth of row */ 1015 png_byte channels; /* number of channels (1, 2, 3, or 4) */ 1016 png_byte pixel_depth; /* bits per pixel (depth * channels) */ 1017 } png_row_info; 1018 1019 typedef png_row_info FAR * png_row_infop; 1020 typedef png_row_info FAR * FAR * png_row_infopp; 1021 1022 /* These are the function types for the I/O functions and for the functions 1023 * that allow the user to override the default I/O functions with his or her 1024 * own. The png_error_ptr type should match that of user-supplied warning 1025 * and error functions, while the png_rw_ptr type should match that of the 1026 * user read/write data functions. 1027 */ 1028 typedef struct png_struct_def png_struct; 1029 typedef png_struct FAR * png_structp; 1030 1031 typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp)); 1032 typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); 1033 typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp)); 1034 typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32, 1035 int)); 1036 typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32, 1037 int)); 1038 1039 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED 1040 typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop)); 1041 typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop)); 1042 typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep, 1043 png_uint_32, int)); 1044 #endif 1045 1046 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ 1047 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ 1048 defined(PNG_LEGACY_SUPPORTED) 1049 typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp, 1050 png_row_infop, png_bytep)); 1051 #endif 1052 1053 #if defined(PNG_USER_CHUNKS_SUPPORTED) 1054 typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp)); 1055 #endif 1056 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) 1057 typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); 1058 #endif 1059 1060 /* Transform masks for the high-level interface */ 1061 #define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ 1062 #define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ 1063 #define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ 1064 #define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ 1065 #define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ 1066 #define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ 1067 #define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ 1068 #define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ 1069 #define PNG_TRANSFORM_BGR 0x0080 /* read and write */ 1070 #define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ 1071 #define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ 1072 #define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ 1073 #define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */ 1074 1075 /* Flags for MNG supported features */ 1076 #define PNG_FLAG_MNG_EMPTY_PLTE 0x01 1077 #define PNG_FLAG_MNG_FILTER_64 0x04 1078 #define PNG_ALL_MNG_FEATURES 0x05 1079 1080 typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); 1081 typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); 1082 1083 /* The structure that holds the information to read and write PNG files. 1084 * The only people who need to care about what is inside of this are the 1085 * people who will be modifying the library for their own special needs. 1086 * It should NOT be accessed directly by an application, except to store 1087 * the jmp_buf. 1088 */ 1089 1090 struct png_struct_def 1091 { 1092 #ifdef PNG_SETJMP_SUPPORTED 1093 jmp_buf jmpbuf; /* used in png_error */ 1094 #endif 1095 png_error_ptr error_fn; /* function for printing errors and aborting */ 1096 png_error_ptr warning_fn; /* function for printing warnings */ 1097 png_voidp error_ptr; /* user supplied struct for error functions */ 1098 png_rw_ptr write_data_fn; /* function for writing output data */ 1099 png_rw_ptr read_data_fn; /* function for reading input data */ 1100 png_voidp io_ptr; /* ptr to application struct for I/O functions */ 1101 1102 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) 1103 png_user_transform_ptr read_user_transform_fn; /* user read transform */ 1104 #endif 1105 1106 #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) 1107 png_user_transform_ptr write_user_transform_fn; /* user write transform */ 1108 #endif 1109 1110 /* These were added in libpng-1.0.2 */ 1111 #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) 1112 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ 1113 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) 1114 png_voidp user_transform_ptr; /* user supplied struct for user transform */ 1115 png_byte user_transform_depth; /* bit depth of user transformed pixels */ 1116 png_byte user_transform_channels; /* channels in user transformed pixels */ 1117 #endif 1118 #endif 1119 1120 png_uint_32 mode; /* tells us where we are in the PNG file */ 1121 png_uint_32 flags; /* flags indicating various things to libpng */ 1122 png_uint_32 transformations; /* which transformations to perform */ 1123 1124 z_stream zstream; /* pointer to decompression structure (below) */ 1125 png_bytep zbuf; /* buffer for zlib */ 1126 png_size_t zbuf_size; /* size of zbuf */ 1127 int zlib_level; /* holds zlib compression level */ 1128 int zlib_method; /* holds zlib compression method */ 1129 int zlib_window_bits; /* holds zlib compression window bits */ 1130 int zlib_mem_level; /* holds zlib compression memory level */ 1131 int zlib_strategy; /* holds zlib compression strategy */ 1132 1133 png_uint_32 width; /* width of image in pixels */ 1134 png_uint_32 height; /* height of image in pixels */ 1135 png_uint_32 num_rows; /* number of rows in current pass */ 1136 png_uint_32 usr_width; /* width of row at start of write */ 1137 png_uint_32 rowbytes; /* size of row in bytes */ 1138 png_uint_32 irowbytes; /* size of current interlaced row in bytes */ 1139 png_uint_32 iwidth; /* width of current interlaced row in pixels */ 1140 png_uint_32 row_number; /* current row in interlace pass */ 1141 png_bytep prev_row; /* buffer to save previous (unfiltered) row */ 1142 png_bytep row_buf; /* buffer to save current (unfiltered) row */ 1143 png_bytep sub_row; /* buffer to save "sub" row when filtering */ 1144 png_bytep up_row; /* buffer to save "up" row when filtering */ 1145 png_bytep avg_row; /* buffer to save "avg" row when filtering */ 1146 png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ 1147 png_row_info row_info; /* used for transformation routines */ 1148 1149 png_uint_32 idat_size; /* current IDAT size for read */ 1150 png_uint_32 crc; /* current chunk CRC value */ 1151 png_colorp palette; /* palette from the input file */ 1152 png_uint_16 num_palette; /* number of color entries in palette */ 1153 png_uint_16 num_trans; /* number of transparency values */ 1154 png_byte chunk_name[5]; /* null-terminated name of current chunk */ 1155 png_byte compression; /* file compression type (always 0) */ 1156 png_byte filter; /* file filter type (always 0) */ 1157 png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ 1158 png_byte pass; /* current interlace pass (0 - 6) */ 1159 png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ 1160 png_byte color_type; /* color type of file */ 1161 png_byte bit_depth; /* bit depth of file */ 1162 png_byte usr_bit_depth; /* bit depth of users row */ 1163 png_byte pixel_depth; /* number of bits per pixel */ 1164 png_byte channels; /* number of channels in file */ 1165 png_byte usr_channels; /* channels at start of write */ 1166 png_byte sig_bytes; /* magic bytes read/written from start of file */ 1167 1168 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) 1169 #ifdef PNG_LEGACY_SUPPORTED 1170 png_byte filler; /* filler byte for pixel expansion */ 1171 #else 1172 png_uint_16 filler; /* filler bytes for pixel expansion */ 1173 #endif 1174 #endif 1175 1176 #if defined(PNG_bKGD_SUPPORTED) 1177 png_byte background_gamma_type; 1178 # ifdef PNG_FLOATING_POINT_SUPPORTED 1179 float background_gamma; 1180 # endif 1181 png_color_16 background; /* background color in screen gamma space */ 1182 #if defined(PNG_READ_GAMMA_SUPPORTED) 1183 png_color_16 background_1; /* background normalized to gamma 1.0 */ 1184 #endif 1185 #endif /* PNG_bKGD_SUPPORTED */ 1186 1187 #if defined(PNG_WRITE_FLUSH_SUPPORTED) 1188 png_flush_ptr output_flush_fn;/* Function for flushing output */ 1189 png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ 1190 png_uint_32 flush_rows; /* number of rows written since last flush */ 1191 #endif 1192 1193 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) 1194 int gamma_shift; /* number of "insignificant" bits 16-bit gamma */ 1195 #ifdef PNG_FLOATING_POINT_SUPPORTED 1196 float gamma; /* file gamma value */ 1197 float screen_gamma; /* screen gamma value (display_exponent) */ 1198 #endif 1199 #endif 1200 1201 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) 1202 png_bytep gamma_table; /* gamma table for 8-bit depth files */ 1203 png_bytep gamma_from_1; /* converts from 1.0 to screen */ 1204 png_bytep gamma_to_1; /* converts from file to 1.0 */ 1205 png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ 1206 png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ 1207 png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ 1208 #endif 1209 1210 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) 1211 png_color_8 sig_bit; /* significant bits in each available channel */ 1212 #endif 1213 1214 #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) 1215 png_color_8 shift; /* shift for significant bit tranformation */ 1216 #endif 1217 1218 #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ 1219 || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) 1220 png_bytep trans; /* transparency values for paletted files */ 1221 png_color_16 trans_values; /* transparency values for non-paletted files */ 1222 #endif 1223 1224 png_read_status_ptr read_row_fn; /* called after each row is decoded */ 1225 png_write_status_ptr write_row_fn; /* called after each row is encoded */ 1226 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED 1227 png_progressive_info_ptr info_fn; /* called after header data fully read */ 1228 png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */ 1229 png_progressive_end_ptr end_fn; /* called after image is complete */ 1230 png_bytep save_buffer_ptr; /* current location in save_buffer */ 1231 png_bytep save_buffer; /* buffer for previously read data */ 1232 png_bytep current_buffer_ptr; /* current location in current_buffer */ 1233 png_bytep current_buffer; /* buffer for recently used data */ 1234 png_uint_32 push_length; /* size of current input chunk */ 1235 png_uint_32 skip_length; /* bytes to skip in input data */ 1236 png_size_t save_buffer_size; /* amount of data now in save_buffer */ 1237 png_size_t save_buffer_max; /* total size of save_buffer */ 1238 png_size_t buffer_size; /* total amount of available input data */ 1239 png_size_t current_buffer_size; /* amount of data now in current_buffer */ 1240 int process_mode; /* what push library is currently doing */ 1241 int cur_palette; /* current push library palette index */ 1242 1243 # if defined(PNG_TEXT_SUPPORTED) 1244 png_size_t current_text_size; /* current size of text input data */ 1245 png_size_t current_text_left; /* how much text left to read in input */ 1246 png_charp current_text; /* current text chunk buffer */ 1247 png_charp current_text_ptr; /* current location in current_text */ 1248 # endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */ 1249 1250 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ 1251 1252 #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) 1253 /* for the Borland special 64K segment handler */ 1254 png_bytepp offset_table_ptr; 1255 png_bytep offset_table; 1256 png_uint_16 offset_table_number; 1257 png_uint_16 offset_table_count; 1258 png_uint_16 offset_table_count_free; 1259 #endif 1260 1261 #if defined(PNG_READ_DITHER_SUPPORTED) 1262 png_bytep palette_lookup; /* lookup table for dithering */ 1263 png_bytep dither_index; /* index translation for palette files */ 1264 #endif 1265 1266 #if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED) 1267 png_uint_16p hist; /* histogram */ 1268 #endif 1269 1270 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) 1271 png_byte heuristic_method; /* heuristic for row filter selection */ 1272 png_byte num_prev_filters; /* number of weights for previous rows */ 1273 png_bytep prev_filters; /* filter type(s) of previous row(s) */ 1274 png_uint_16p filter_weights; /* weight(s) for previous line(s) */ 1275 png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ 1276 png_uint_16p filter_costs; /* relative filter calculation cost */ 1277 png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ 1278 #endif 1279 1280 #if defined(PNG_TIME_RFC1123_SUPPORTED) 1281 png_charp time_buffer; /* String to hold RFC 1123 time text */ 1282 #endif 1283 1284 /* New members added in libpng-1.0.6 */ 1285 1286 #ifdef PNG_FREE_ME_SUPPORTED 1287 png_uint_32 free_me; /* flags items libpng is responsible for freeing */ 1288 #endif 1289 1290 #if defined(PNG_USER_CHUNKS_SUPPORTED) 1291 png_voidp user_chunk_ptr; 1292 png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ 1293 #endif 1294 1295 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) 1296 int num_chunk_list; 1297 png_bytep chunk_list; 1298 #endif 1299 1300 /* New members added in libpng-1.0.3 */ 1301 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) 1302 png_byte rgb_to_gray_status; 1303 /* These were changed from png_byte in libpng-1.0.6 */ 1304 png_uint_16 rgb_to_gray_red_coeff; 1305 png_uint_16 rgb_to_gray_green_coeff; 1306 png_uint_16 rgb_to_gray_blue_coeff; 1307 #endif 1308 1309 /* New member added in libpng-1.0.4 (renamed in 1.0.9) */ 1310 #if defined(PNG_MNG_FEATURES_SUPPORTED) || \ 1311 defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ 1312 defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) 1313 /* changed from png_byte to png_uint_32 at version 1.2.0 */ 1314 #ifdef PNG_1_0_X 1315 png_byte mng_features_permitted; 1316 #else 1317 png_uint_32 mng_features_permitted; 1318 #endif /* PNG_1_0_X */ 1319 #endif 1320 1321 /* New member added in libpng-1.0.7 */ 1322 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) 1323 png_fixed_point int_gamma; 1324 #endif 1325 1326 /* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ 1327 #if defined(PNG_MNG_FEATURES_SUPPORTED) 1328 png_byte filter_type; 1329 #endif 1330 1331 #if defined(PNG_1_0_X) || (defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD)) 1332 /* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */ 1333 png_uint_32 row_buf_size; 1334 #endif 1335 1336 /* New members added in libpng-1.2.0 */ 1337 #if !defined(PNG_1_0_X) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) 1338 png_byte mmx_bitdepth_threshold; 1339 png_uint_32 mmx_rowbytes_threshold; 1340 png_uint_32 asm_flags; 1341 #endif 1342 1343 /* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ 1344 #ifdef PNG_USER_MEM_SUPPORTED 1345 png_voidp mem_ptr; /* user supplied struct for mem functions */ 1346 png_malloc_ptr malloc_fn; /* function for allocating memory */ 1347 png_free_ptr free_fn; /* function for freeing memory */ 1348 #endif 1349 1350 /* New member added in libpng-1.0.13 and 1.2.0 */ 1351 png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ 1352 1353 #if defined(PNG_READ_DITHER_SUPPORTED) 1354 /* The following three members were added at version 1.0.14 and 1.2.4 */ 1355 png_bytep dither_sort; /* working sort array */ 1356 png_bytep index_to_palette; /* where the original index currently is */ 1357 /* in the palette */ 1358 png_bytep palette_to_index; /* which original index points to this */ 1359 /* palette color */ 1360 #endif 1361 1362 /* New members added in libpng-1.0.16 and 1.2.6 */ 1363 png_byte compression_type; 1364 1365 #ifdef PNG_SET_USER_LIMITS_SUPPORTED 1366 png_uint_32 user_width_max; 1367 png_uint_32 user_height_max; 1368 #endif 1369 1370 }; 1371 1372 1373 /* This triggers a compiler error in png.c, if png.c and png.h 1374 * do not agree upon the version number. 1375 */ 1376 typedef png_structp version_1_2_12; 1377 1378 typedef png_struct FAR * FAR * png_structpp; 1379 1380 /* Here are the function definitions most commonly used. This is not 1381 * the place to find out how to use libpng. See libpng.txt for the 1382 * full explanation, see example.c for the summary. This just provides 1383 * a simple one line description of the use of each function. 1384 */ 1385 1386 /* Returns the version number of the library */ 1387 extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void)); 1388 1389 /* Tell lib we have already handled the first <num_bytes> magic bytes. 1390 * Handling more than 8 bytes from the beginning of the file is an error. 1391 */ 1392 extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr, 1393 int num_bytes)); 1394 1395 /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a 1396 * PNG file. Returns zero if the supplied bytes match the 8-byte PNG 1397 * signature, and non-zero otherwise. Having num_to_check == 0 or 1398 * start > 7 will always fail (ie return non-zero). 1399 */ 1400 extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start, 1401 png_size_t num_to_check)); 1402 1403 /* Simple signature checking function. This is the same as calling 1404 * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). 1405 */ 1406 extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num)); 1407 1408 /* Allocate and initialize png_ptr struct for reading, and any other memory. */ 1409 extern PNG_EXPORT(png_structp,png_create_read_struct) 1410 PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, 1411 png_error_ptr error_fn, png_error_ptr warn_fn)); 1412 1413 /* Allocate and initialize png_ptr struct for writing, and any other memory */ 1414 extern PNG_EXPORT(png_structp,png_create_write_struct) 1415 PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, 1416 png_error_ptr error_fn, png_error_ptr warn_fn)); 1417 1418 #ifdef PNG_WRITE_SUPPORTED 1419 extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size) 1420 PNGARG((png_structp png_ptr)); 1421 #endif 1422 1423 #ifdef PNG_WRITE_SUPPORTED 1424 extern PNG_EXPORT(void,png_set_compression_buffer_size) 1425 PNGARG((png_structp png_ptr, png_uint_32 size)); 1426 #endif 1427 1428 /* Reset the compression stream */ 1429 extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); 1430 1431 /* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ 1432 #ifdef PNG_USER_MEM_SUPPORTED 1433 extern PNG_EXPORT(png_structp,png_create_read_struct_2) 1434 PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, 1435 png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, 1436 png_malloc_ptr malloc_fn, png_free_ptr free_fn)); 1437 extern PNG_EXPORT(png_structp,png_create_write_struct_2) 1438 PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, 1439 png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, 1440 png_malloc_ptr malloc_fn, png_free_ptr free_fn)); 1441 #endif 1442 1443 /* Write a PNG chunk - size, type, (optional) data, CRC. */ 1444 extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr, 1445 png_bytep chunk_name, png_bytep data, png_size_t length)); 1446 1447 /* Write the start of a PNG chunk - length and chunk name. */ 1448 extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr, 1449 png_bytep chunk_name, png_uint_32 length)); 1450 1451 /* Write the data of a PNG chunk started with png_write_chunk_start(). */ 1452 extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr, 1453 png_bytep data, png_size_t length)); 1454 1455 /* Finish a chunk started with png_write_chunk_start() (includes CRC). */ 1456 extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr)); 1457 1458 /* Allocate and initialize the info structure */ 1459 extern PNG_EXPORT(png_infop,png_create_info_struct) 1460 PNGARG((png_structp png_ptr)); 1461 1462 #if defined(PNG_1_0_X) || defined (PNG_1_2_X) 1463 /* Initialize the info structure (old interface - DEPRECATED) */ 1464 extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr)); 1465 #undef png_info_init 1466 #define png_info_init(info_ptr) png_info_init_3(&info_ptr,\ 1467 png_sizeof(png_info)); 1468 #endif 1469 1470 extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr, 1471 png_size_t png_info_struct_size)); 1472 1473 /* Writes all the PNG information before the image. */ 1474 extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, 1475 png_infop info_ptr)); 1476 extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr, 1477 png_infop info_ptr)); 1478 1479 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED 1480 /* read the information before the actual image data. */ 1481 extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr, 1482 png_infop info_ptr)); 1483 #endif 1484 1485 #if defined(PNG_TIME_RFC1123_SUPPORTED) 1486 extern PNG_EXPORT(png_charp,png_convert_to_rfc1123) 1487 PNGARG((png_structp png_ptr, png_timep ptime)); 1488 #endif 1489 1490 #if !defined(_WIN32_WCE) 1491 /* "time.h" functions are not supported on WindowsCE */ 1492 #if defined(PNG_WRITE_tIME_SUPPORTED) 1493 /* convert from a struct tm to png_time */ 1494 extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, 1495 struct tm FAR * ttime)); 1496 1497 /* convert from time_t to png_time. Uses gmtime() */ 1498 extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, 1499 time_t ttime)); 1500 #endif /* PNG_WRITE_tIME_SUPPORTED */ 1501 #endif /* _WIN32_WCE */ 1502 1503 #if defined(PNG_READ_EXPAND_SUPPORTED) 1504 /* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ 1505 extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr)); 1506 #if !defined(PNG_1_0_X) 1507 extern PNG_EXPORT(void,png_set_expand_gray_1_2_4_to_8) PNGARG((png_structp 1508 png_ptr)); 1509 #endif 1510 extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr)); 1511 extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr)); 1512 #if defined(PNG_1_0_X) || defined (PNG_1_2_X) 1513 /* Deprecated */ 1514 extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr)); 1515 #endif 1516 #endif 1517 1518 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) 1519 /* Use blue, green, red order for pixels. */ 1520 extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr)); 1521 #endif 1522 1523 #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) 1524 /* Expand the grayscale to 24-bit RGB if necessary. */ 1525 extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr)); 1526 #endif 1527 1528 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) 1529 /* Reduce RGB to grayscale. */ 1530 #ifdef PNG_FLOATING_POINT_SUPPORTED 1531 extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr, 1532 int error_action, double red, double green )); 1533 #endif 1534 extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr, 1535 int error_action, png_fixed_point red, png_fixed_point green )); 1536 extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp 1537 png_ptr)); 1538 #endif 1539 1540 extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth, 1541 png_colorp palette)); 1542 1543 #if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) 1544 extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr)); 1545 #endif 1546 1547 #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ 1548 defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) 1549 extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr)); 1550 #endif 1551 1552 #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ 1553 defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) 1554 extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr)); 1555 #endif 1556 1557 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) 1558 /* Add a filler byte to 8-bit Gray or 24-bit RGB images. */ 1559 extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr, 1560 png_uint_32 filler, int flags)); 1561 /* The values of the PNG_FILLER_ defines should NOT be changed */ 1562 #define PNG_FILLER_BEFORE 0 1563 #define PNG_FILLER_AFTER 1 1564 /* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ 1565 #if !defined(PNG_1_0_X) 1566 extern PNG_EXPORT(void,png_set_add_alpha) PNGARG((png_structp png_ptr, 1567 png_uint_32 filler, int flags)); 1568 #endif 1569 #endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ 1570 1571 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) 1572 /* Swap bytes in 16-bit depth files. */ 1573 extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr)); 1574 #endif 1575 1576 #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) 1577 /* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ 1578 extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr)); 1579 #endif 1580 1581 #if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) 1582 /* Swap packing order of pixels in bytes. */ 1583 extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr)); 1584 #endif 1585 1586 #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) 1587 /* Converts files to legal bit depths. */ 1588 extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr, 1589 png_color_8p true_bits)); 1590 #endif 1591 1592 #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ 1593 defined(PNG_WRITE_INTERLACING_SUPPORTED) 1594 /* Have the code handle the interlacing. Returns the number of passes. */ 1595 extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr)); 1596 #endif 1597 1598 #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) 1599 /* Invert monochrome files */ 1600 extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr)); 1601 #endif 1602 1603 #if defined(PNG_READ_BACKGROUND_SUPPORTED) 1604 /* Handle alpha and tRNS by replacing with a background color. */ 1605 #ifdef PNG_FLOATING_POINT_SUPPORTED 1606 extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr, 1607 png_color_16p background_color, int background_gamma_code, 1608 int need_expand, double background_gamma)); 1609 #endif 1610 #define PNG_BACKGROUND_GAMMA_UNKNOWN 0 1611 #define PNG_BACKGROUND_GAMMA_SCREEN 1 1612 #define PNG_BACKGROUND_GAMMA_FILE 2 1613 #define PNG_BACKGROUND_GAMMA_UNIQUE 3 1614 #endif 1615 1616 #if defined(PNG_READ_16_TO_8_SUPPORTED) 1617 /* strip the second byte of information from a 16-bit depth file. */ 1618 extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr)); 1619 #endif 1620 1621 #if defined(PNG_READ_DITHER_SUPPORTED) 1622 /* Turn on dithering, and reduce the palette to the number of colors available. */ 1623 extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr, 1624 png_colorp palette, int num_palette, int maximum_colors, 1625 png_uint_16p histogram, int full_dither)); 1626 #endif 1627 1628 #if defined(PNG_READ_GAMMA_SUPPORTED) 1629 /* Handle gamma correction. Screen_gamma=(display_exponent) */ 1630 #ifdef PNG_FLOATING_POINT_SUPPORTED 1631 extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr, 1632 double screen_gamma, double default_file_gamma)); 1633 #endif 1634 #endif 1635 1636 #if defined(PNG_1_0_X) || defined (PNG_1_2_X) 1637 #if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ 1638 defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) 1639 /* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */ 1640 /* Deprecated and will be removed. Use png_permit_mng_features() instead. */ 1641 extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr, 1642 int empty_plte_permitted)); 1643 #endif 1644 #endif 1645 1646 #if defined(PNG_WRITE_FLUSH_SUPPORTED) 1647 /* Set how many lines between output flushes - 0 for no flushing */ 1648 extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows)); 1649 /* Flush the current PNG output buffer */ 1650 extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr)); 1651 #endif 1652 1653 /* optional update palette with requested transformations */ 1654 extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr)); 1655 1656 /* optional call to update the users info structure */ 1657 extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, 1658 png_infop info_ptr)); 1659 1660 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED 1661 /* read one or more rows of image data. */ 1662 extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, 1663 png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); 1664 #endif 1665 1666 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED 1667 /* read a row of data. */ 1668 extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, 1669 png_bytep row, 1670 png_bytep display_row)); 1671 #endif 1672 1673 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED 1674 /* read the whole image into memory at once. */ 1675 extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr, 1676 png_bytepp image)); 1677 #endif 1678 1679 /* write a row of image data */ 1680 extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr, 1681 png_bytep row)); 1682 1683 /* write a few rows of image data */ 1684 extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr, 1685 png_bytepp row, png_uint_32 num_rows)); 1686 1687 /* write the image data */ 1688 extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr, 1689 png_bytepp image)); 1690 1691 /* writes the end of the PNG file. */ 1692 extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr, 1693 png_infop info_ptr)); 1694 1695 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED 1696 /* read the end of the PNG file. */ 1697 extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr, 1698 png_infop info_ptr)); 1699 #endif 1700 1701 /* free any memory associated with the png_info_struct */ 1702 extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr, 1703 png_infopp info_ptr_ptr)); 1704 1705 /* free any memory associated with the png_struct and the png_info_structs */ 1706 extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp 1707 png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); 1708 1709 /* free all memory used by the read (old method - NOT DLL EXPORTED) */ 1710 extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr, 1711 png_infop end_info_ptr)); 1712 1713 /* free any memory associated with the png_struct and the png_info_structs */ 1714 extern PNG_EXPORT(void,png_destroy_write_struct) 1715 PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); 1716 1717 /* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ 1718 extern void png_write_destroy PNGARG((png_structp png_ptr)); 1719 1720 /* set the libpng method of handling chunk CRC errors */ 1721 extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, 1722 int crit_action, int ancil_action)); 1723 1724 /* Values for png_set_crc_action() to say how to handle CRC errors in 1725 * ancillary and critical chunks, and whether to use the data contained 1726 * therein. Note that it is impossible to "discard" data in a critical 1727 * chunk. For versions prior to 0.90, the action was always error/quit, 1728 * whereas in version 0.90 and later, the action for CRC errors in ancillary 1729 * chunks is warn/discard. These values should NOT be changed. 1730 * 1731 * value action:critical action:ancillary 1732 */ 1733 #define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ 1734 #define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ 1735 #define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ 1736 #define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ 1737 #define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ 1738 #define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ 1739 1740 /* These functions give the user control over the scan-line filtering in 1741 * libpng and the compression methods used by zlib. These functions are 1742 * mainly useful for testing, as the defaults should work with most users. 1743 * Those users who are tight on memory or want faster performance at the 1744 * expense of compression can modify them. See the compression library 1745 * header file (zlib.h) for an explination of the compression functions. 1746 */ 1747 1748 /* set the filtering method(s) used by libpng. Currently, the only valid 1749 * value for "method" is 0. 1750 */ 1751 extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, 1752 int filters)); 1753 1754 /* Flags for png_set_filter() to say which filters to use. The flags 1755 * are chosen so that they don't conflict with real filter types 1756 * below, in case they are supplied instead of the #defined constants. 1757 * These values should NOT be changed. 1758 */ 1759 #define PNG_NO_FILTERS 0x00 1760 #define PNG_FILTER_NONE 0x08 1761 #define PNG_FILTER_SUB 0x10 1762 #define PNG_FILTER_UP 0x20 1763 #define PNG_FILTER_AVG 0x40 1764 #define PNG_FILTER_PAETH 0x80 1765 #define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ 1766 PNG_FILTER_AVG | PNG_FILTER_PAETH) 1767 1768 /* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. 1769 * These defines should NOT be changed. 1770 */ 1771 #define PNG_FILTER_VALUE_NONE 0 1772 #define PNG_FILTER_VALUE_SUB 1 1773 #define PNG_FILTER_VALUE_UP 2 1774 #define PNG_FILTER_VALUE_AVG 3 1775 #define PNG_FILTER_VALUE_PAETH 4 1776 #define PNG_FILTER_VALUE_LAST 5 1777 1778 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */ 1779 /* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ 1780 * defines, either the default (minimum-sum-of-absolute-differences), or 1781 * the experimental method (weighted-minimum-sum-of-absolute-differences). 1782 * 1783 * Weights are factors >= 1.0, indicating how important it is to keep the 1784 * filter type consistent between rows. Larger numbers mean the current 1785 * filter is that many times as likely to be the same as the "num_weights" 1786 * previous filters. This is cumulative for each previous row with a weight. 1787 * There needs to be "num_weights" values in "filter_weights", or it can be 1788 * NULL if the weights aren't being specified. Weights have no influence on 1789 * the selection of the first row filter. Well chosen weights can (in theory) 1790 * improve the compression for a given image. 1791 * 1792 * Costs are factors >= 1.0 indicating the relative decoding costs of a 1793 * filter type. Higher costs indicate more decoding expense, and are 1794 * therefore less likely to be selected over a filter with lower computational 1795 * costs. There needs to be a value in "filter_costs" for each valid filter 1796 * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't 1797 * setting the costs. Costs try to improve the speed of decompression without 1798 * unduly increasing the compressed image size. 1799 * 1800 * A negative weight or cost indicates the default value is to be used, and 1801 * values in the range [0.0, 1.0) indicate the value is to remain unchanged. 1802 * The default values for both weights and costs are currently 1.0, but may 1803 * change if good general weighting/cost heuristics can be found. If both 1804 * the weights and costs are set to 1.0, this degenerates the WEIGHTED method 1805 * to the UNWEIGHTED method, but with added encoding time/computation. 1806 */ 1807 #ifdef PNG_FLOATING_POINT_SUPPORTED 1808 extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr, 1809 int heuristic_method, int num_weights, png_doublep filter_weights, 1810 png_doublep filter_costs)); 1811 #endif 1812 #endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ 1813 1814 /* Heuristic used for row filter selection. These defines should NOT be 1815 * changed. 1816 */ 1817 #define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ 1818 #define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ 1819 #define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ 1820 #define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ 1821 1822 /* Set the library compression level. Currently, valid values range from 1823 * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 1824 * (0 - no compression, 9 - "maximal" compression). Note that tests have 1825 * shown that zlib compression levels 3-6 usually perform as well as level 9 1826 * for PNG images, and do considerably fewer caclulations. In the future, 1827 * these values may not correspond directly to the zlib compression levels. 1828 */ 1829 extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr, 1830 int level)); 1831 1832 extern PNG_EXPORT(void,png_set_compression_mem_level) 1833 PNGARG((png_structp png_ptr, int mem_level)); 1834 1835 extern PNG_EXPORT(void,png_set_compression_strategy) 1836 PNGARG((png_structp png_ptr, int strategy)); 1837 1838 extern PNG_EXPORT(void,png_set_compression_window_bits) 1839 PNGARG((png_structp png_ptr, int window_bits)); 1840 1841 extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr, 1842 int method)); 1843 1844 /* These next functions are called for input/output, memory, and error 1845 * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, 1846 * and call standard C I/O routines such as fread(), fwrite(), and 1847 * fprintf(). These functions can be made to use other I/O routines 1848 * at run time for those applications that need to handle I/O in a 1849 * different manner by calling png_set_???_fn(). See libpng.txt for 1850 * more information. 1851 */ 1852 1853 #if !defined(PNG_NO_STDIO) 1854 /* Initialize the input/output for the PNG file to the default functions. */ 1855 extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp)); 1856 #endif 1857 1858 /* Replace the (error and abort), and warning functions with user 1859 * supplied functions. If no messages are to be printed you must still 1860 * write and use replacement functions. The replacement error_fn should 1861 * still do a longjmp to the last setjmp location if you are using this 1862 * method of error handling. If error_fn or warning_fn is NULL, the 1863 * default function will be used. 1864 */ 1865 1866 extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr, 1867 png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); 1868 1869 /* Return the user pointer associated with the error functions */ 1870 extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr)); 1871 1872 /* Replace the default data output functions with a user supplied one(s). 1873 * If buffered output is not used, then output_flush_fn can be set to NULL. 1874 * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time 1875 * output_flush_fn will be ignored (and thus can be NULL). 1876 */ 1877 extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, 1878 png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); 1879 1880 /* Replace the default data input function with a user supplied one. */ 1881 extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr, 1882 png_voidp io_ptr, png_rw_ptr read_data_fn)); 1883 1884 /* Return the user pointer associated with the I/O functions */ 1885 extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr)); 1886 1887 extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr, 1888 png_read_status_ptr read_row_fn)); 1889 1890 extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr, 1891 png_write_status_ptr write_row_fn)); 1892 1893 #ifdef PNG_USER_MEM_SUPPORTED 1894 /* Replace the default memory allocation functions with user supplied one(s). */ 1895 extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr, 1896 png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); 1897 /* Return the user pointer associated with the memory functions */ 1898 extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr)); 1899 #endif 1900 1901 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ 1902 defined(PNG_LEGACY_SUPPORTED) 1903 extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp 1904 png_ptr, png_user_transform_ptr read_user_transform_fn)); 1905 #endif 1906 1907 #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ 1908 defined(PNG_LEGACY_SUPPORTED) 1909 extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp 1910 png_ptr, png_user_transform_ptr write_user_transform_fn)); 1911 #endif 1912 1913 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ 1914 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ 1915 defined(PNG_LEGACY_SUPPORTED) 1916 extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp 1917 png_ptr, png_voidp user_transform_ptr, int user_transform_depth, 1918 int user_transform_channels)); 1919 /* Return the user pointer associated with the user transform functions */ 1920 extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr) 1921 PNGARG((png_structp png_ptr)); 1922 #endif 1923 1924 #ifdef PNG_USER_CHUNKS_SUPPORTED 1925 extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr, 1926 png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); 1927 extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp 1928 png_ptr)); 1929 #endif 1930 1931 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED 1932 /* Sets the function callbacks for the push reader, and a pointer to a 1933 * user-defined structure available to the callback functions. 1934 */ 1935 extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr, 1936 png_voidp progressive_ptr, 1937 png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, 1938 png_progressive_end_ptr end_fn)); 1939 1940 /* returns the user pointer associated with the push read functions */ 1941 extern PNG_EXPORT(png_voidp,png_get_progressive_ptr) 1942 PNGARG((png_structp png_ptr)); 1943 1944 /* function to be called when data becomes available */ 1945 extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr, 1946 png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)); 1947 1948 /* function that combines rows. Not very much different than the 1949 * png_combine_row() call. Is this even used????? 1950 */ 1951 extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, 1952 png_bytep old_row, png_bytep new_row)); 1953 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ 1954 1955 extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, 1956 png_uint_32 size)); 1957 1958 #if defined(PNG_1_0_X) 1959 # define png_malloc_warn png_malloc 1960 #else 1961 /* Added at libpng version 1.2.4 */ 1962 extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr, 1963 png_uint_32 size)); 1964 #endif 1965 1966 /* frees a pointer allocated by png_malloc() */ 1967 extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); 1968 1969 #if defined(PNG_1_0_X) 1970 /* Function to allocate memory for zlib. */ 1971 extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items, 1972 uInt size)); 1973 1974 /* Function to free memory for zlib */ 1975 extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr)); 1976 #endif 1977 1978 /* Free data that was allocated internally */ 1979 extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, 1980 png_infop info_ptr, png_uint_32 free_me, int num)); 1981 #ifdef PNG_FREE_ME_SUPPORTED 1982 /* Reassign responsibility for freeing existing data, whether allocated 1983 * by libpng or by the application */ 1984 extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, 1985 png_infop info_ptr, int freer, png_uint_32 mask)); 1986 #endif 1987 /* assignments for png_data_freer */ 1988 #define PNG_DESTROY_WILL_FREE_DATA 1 1989 #define PNG_SET_WILL_FREE_DATA 1 1990 #define PNG_USER_WILL_FREE_DATA 2 1991 /* Flags for png_ptr->free_me and info_ptr->free_me */ 1992 #define PNG_FREE_HIST 0x0008 1993 #define PNG_FREE_ICCP 0x0010 1994 #define PNG_FREE_SPLT 0x0020 1995 #define PNG_FREE_ROWS 0x0040 1996 #define PNG_FREE_PCAL 0x0080 1997 #define PNG_FREE_SCAL 0x0100 1998 #define PNG_FREE_UNKN 0x0200 1999 #define PNG_FREE_LIST 0x0400 2000 #define PNG_FREE_PLTE 0x1000 2001 #define PNG_FREE_TRNS 0x2000 2002 #define PNG_FREE_TEXT 0x4000 2003 #define PNG_FREE_ALL 0x7fff 2004 #define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ 2005 2006 #ifdef PNG_USER_MEM_SUPPORTED 2007 extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr, 2008 png_uint_32 size)); 2009 extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr, 2010 png_voidp ptr)); 2011 #endif 2012 2013 extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr, 2014 png_voidp s1, png_voidp s2, png_uint_32 size)); 2015 2016 extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr, 2017 png_voidp s1, int value, png_uint_32 size)); 2018 2019 #if defined(USE_FAR_KEYWORD) /* memory model conversion function */ 2020 extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr, 2021 int check)); 2022 #endif /* USE_FAR_KEYWORD */ 2023 2024 /* Fatal error in PNG image of libpng - can't continue */ 2025 extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr, 2026 png_const_charp error_message)); 2027 2028 /* The same, but the chunk name is prepended to the error string. */ 2029 extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr, 2030 png_const_charp error_message)); 2031 2032 /* Non-fatal error in libpng. Can continue, but may have a problem. */ 2033 extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr, 2034 png_const_charp warning_message)); 2035 2036 /* Non-fatal error in libpng, chunk name is prepended to message. */ 2037 extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr, 2038 png_const_charp warning_message)); 2039 2040 /* The png_set_<chunk> functions are for storing values in the png_info_struct. 2041 * Similarly, the png_get_<chunk> calls are used to read values from the 2042 * png_info_struct, either storing the parameters in the passed variables, or 2043 * setting pointers into the png_info_struct where the data is stored. The 2044 * png_get_<chunk> functions return a non-zero value if the data was available 2045 * in info_ptr, or return zero and do not change any of the parameters if the 2046 * data was not available. 2047 * 2048 * These functions should be used instead of directly accessing png_info 2049 * to avoid problems with future changes in the size and internal layout of 2050 * png_info_struct. 2051 */ 2052 /* Returns "flag" if chunk data is valid in info_ptr. */ 2053 extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr, 2054 png_infop info_ptr, png_uint_32 flag)); 2055 2056 /* Returns number of bytes needed to hold a transformed row. */ 2057 extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr, 2058 png_infop info_ptr)); 2059 2060 #if defined(PNG_INFO_IMAGE_SUPPORTED) 2061 /* Returns row_pointers, which is an array of pointers to scanlines that was 2062 returned from png_read_png(). */ 2063 extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr, 2064 png_infop info_ptr)); 2065 /* Set row_pointers, which is an array of pointers to scanlines for use 2066 by png_write_png(). */ 2067 extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr, 2068 png_infop info_ptr, png_bytepp row_pointers)); 2069 #endif 2070 2071 /* Returns number of color channels in image. */ 2072 extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr, 2073 png_infop info_ptr)); 2074 2075 #ifdef PNG_EASY_ACCESS_SUPPORTED 2076 /* Returns image width in pixels. */ 2077 extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp 2078 png_ptr, png_infop info_ptr)); 2079 2080 /* Returns image height in pixels. */ 2081 extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp 2082 png_ptr, png_infop info_ptr)); 2083 2084 /* Returns image bit_depth. */ 2085 extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp 2086 png_ptr, png_infop info_ptr)); 2087 2088 /* Returns image color_type. */ 2089 extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp 2090 png_ptr, png_infop info_ptr)); 2091 2092 /* Returns image filter_type. */ 2093 extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp 2094 png_ptr, png_infop info_ptr)); 2095 2096 /* Returns image interlace_type. */ 2097 extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp 2098 png_ptr, png_infop info_ptr)); 2099 2100 /* Returns image compression_type. */ 2101 extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp 2102 png_ptr, png_infop info_ptr)); 2103 2104 /* Returns image resolution in pixels per meter, from pHYs chunk data. */ 2105 extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp 2106 png_ptr, png_infop info_ptr)); 2107 extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp 2108 png_ptr, png_infop info_ptr)); 2109 extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp 2110 png_ptr, png_infop info_ptr)); 2111 2112 /* Returns pixel aspect ratio, computed from pHYs chunk data. */ 2113 #ifdef PNG_FLOATING_POINT_SUPPORTED 2114 extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp 2115 png_ptr, png_infop info_ptr)); 2116 #endif 2117 2118 /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ 2119 extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp 2120 png_ptr, png_infop info_ptr)); 2121 extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp 2122 png_ptr, png_infop info_ptr)); 2123 extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp 2124 png_ptr, png_infop info_ptr)); 2125 extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp 2126 png_ptr, png_infop info_ptr)); 2127 2128 #endif /* PNG_EASY_ACCESS_SUPPORTED */ 2129 2130 /* Returns pointer to signature string read from PNG header */ 2131 extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr, 2132 png_infop info_ptr)); 2133 2134 #if defined(PNG_bKGD_SUPPORTED) 2135 extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr, 2136 png_infop info_ptr, png_color_16p *background)); 2137 #endif 2138 2139 #if defined(PNG_bKGD_SUPPORTED) 2140 extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr, 2141 png_infop info_ptr, png_color_16p background)); 2142 #endif 2143 2144 #if defined(PNG_cHRM_SUPPORTED) 2145 #ifdef PNG_FLOATING_POINT_SUPPORTED 2146 extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr, 2147 png_infop info_ptr, double *white_x, double *white_y, double *red_x, 2148 double *red_y, double *green_x, double *green_y, double *blue_x, 2149 double *blue_y)); 2150 #endif 2151 #ifdef PNG_FIXED_POINT_SUPPORTED 2152 extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr, 2153 png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point 2154 *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, 2155 png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point 2156 *int_blue_x, png_fixed_point *int_blue_y)); 2157 #endif 2158 #endif 2159 2160 #if defined(PNG_cHRM_SUPPORTED) 2161 #ifdef PNG_FLOATING_POINT_SUPPORTED 2162 extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr, 2163 png_infop info_ptr, double white_x, double white_y, double red_x, 2164 double red_y, double green_x, double green_y, double blue_x, double blue_y)); 2165 #endif 2166 #ifdef PNG_FIXED_POINT_SUPPORTED 2167 extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr, 2168 png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, 2169 png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point 2170 int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, 2171 png_fixed_point int_blue_y)); 2172 #endif 2173 #endif 2174 2175 #if defined(PNG_gAMA_SUPPORTED) 2176 #ifdef PNG_FLOATING_POINT_SUPPORTED 2177 extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr, 2178 png_infop info_ptr, double *file_gamma)); 2179 #endif 2180 extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr, 2181 png_infop info_ptr, png_fixed_point *int_file_gamma)); 2182 #endif 2183 2184 #if defined(PNG_gAMA_SUPPORTED) 2185 #ifdef PNG_FLOATING_POINT_SUPPORTED 2186 extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr, 2187 png_infop info_ptr, double file_gamma)); 2188 #endif 2189 extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr, 2190 png_infop info_ptr, png_fixed_point int_file_gamma)); 2191 #endif 2192 2193 #if defined(PNG_hIST_SUPPORTED) 2194 extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr, 2195 png_infop info_ptr, png_uint_16p *hist)); 2196 #endif 2197 2198 #if defined(PNG_hIST_SUPPORTED) 2199 extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr, 2200 png_infop info_ptr, png_uint_16p hist)); 2201 #endif 2202 2203 extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr, 2204 png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, 2205 int *bit_depth, int *color_type, int *interlace_method, 2206 int *compression_method, int *filter_method)); 2207 2208 extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr, 2209 png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, 2210 int color_type, int interlace_method, int compression_method, 2211 int filter_method)); 2212 2213 #if defined(PNG_oFFs_SUPPORTED) 2214 extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr, 2215 png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, 2216 int *unit_type)); 2217 #endif 2218 2219 #if defined(PNG_oFFs_SUPPORTED) 2220 extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr, 2221 png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, 2222 int unit_type)); 2223 #endif 2224 2225 #if defined(PNG_pCAL_SUPPORTED) 2226 extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr, 2227 png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, 2228 int *type, int *nparams, png_charp *units, png_charpp *params)); 2229 #endif 2230 2231 #if defined(PNG_pCAL_SUPPORTED) 2232 extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr, 2233 png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, 2234 int type, int nparams, png_charp units, png_charpp params)); 2235 #endif 2236 2237 #if defined(PNG_pHYs_SUPPORTED) 2238 extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr, 2239 png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); 2240 #endif 2241 2242 #if defined(PNG_pHYs_SUPPORTED) 2243 extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr, 2244 png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); 2245 #endif 2246 2247 extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr, 2248 png_infop info_ptr, png_colorp *palette, int *num_palette)); 2249 2250 extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr, 2251 png_infop info_ptr, png_colorp palette, int num_palette)); 2252 2253 #if defined(PNG_sBIT_SUPPORTED) 2254 extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr, 2255 png_infop info_ptr, png_color_8p *sig_bit)); 2256 #endif 2257 2258 #if defined(PNG_sBIT_SUPPORTED) 2259 extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr, 2260 png_infop info_ptr, png_color_8p sig_bit)); 2261 #endif 2262 2263 #if defined(PNG_sRGB_SUPPORTED) 2264 extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr, 2265 png_infop info_ptr, int *intent)); 2266 #endif 2267 2268 #if defined(PNG_sRGB_SUPPORTED) 2269 extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr, 2270 png_infop info_ptr, int intent)); 2271 extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr, 2272 png_infop info_ptr, int intent)); 2273 #endif 2274 2275 #if defined(PNG_iCCP_SUPPORTED) 2276 extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr, 2277 png_infop info_ptr, png_charpp name, int *compression_type, 2278 png_charpp profile, png_uint_32 *proflen)); 2279 /* Note to maintainer: profile should be png_bytepp */ 2280 #endif 2281 2282 #if defined(PNG_iCCP_SUPPORTED) 2283 extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr, 2284 png_infop info_ptr, png_charp name, int compression_type, 2285 png_charp profile, png_uint_32 proflen)); 2286 /* Note to maintainer: profile should be png_bytep */ 2287 #endif 2288 2289 #if defined(PNG_sPLT_SUPPORTED) 2290 extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr, 2291 png_infop info_ptr, png_sPLT_tpp entries)); 2292 #endif 2293 2294 #if defined(PNG_sPLT_SUPPORTED) 2295 extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr, 2296 png_infop info_ptr, png_sPLT_tp entries, int nentries)); 2297 #endif 2298 2299 #if defined(PNG_TEXT_SUPPORTED) 2300 /* png_get_text also returns the number of text chunks in *num_text */ 2301 extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr, 2302 png_infop info_ptr, png_textp *text_ptr, int *num_text)); 2303 #endif 2304 2305 /* 2306 * Note while png_set_text() will accept a structure whose text, 2307 * language, and translated keywords are NULL pointers, the structure 2308 * returned by png_get_text will always contain regular 2309 * zero-terminated C strings. They might be empty strings but 2310 * they will never be NULL pointers. 2311 */ 2312 2313 #if defined(PNG_TEXT_SUPPORTED) 2314 extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr, 2315 png_infop info_ptr, png_textp text_ptr, int num_text)); 2316 #endif 2317 2318 #if defined(PNG_tIME_SUPPORTED) 2319 extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr, 2320 png_infop info_ptr, png_timep *mod_time)); 2321 #endif 2322 2323 #if defined(PNG_tIME_SUPPORTED) 2324 extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr, 2325 png_infop info_ptr, png_timep mod_time)); 2326 #endif 2327 2328 #if defined(PNG_tRNS_SUPPORTED) 2329 extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, 2330 png_infop info_ptr, png_bytep *trans, int *num_trans, 2331 png_color_16p *trans_values)); 2332 #endif 2333 2334 #if defined(PNG_tRNS_SUPPORTED) 2335 extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, 2336 png_infop info_ptr, png_bytep trans, int num_trans, 2337 png_color_16p trans_values)); 2338 #endif 2339 2340 #if defined(PNG_tRNS_SUPPORTED) 2341 #endif 2342 2343 #if defined(PNG_sCAL_SUPPORTED) 2344 #ifdef PNG_FLOATING_POINT_SUPPORTED 2345 extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr, 2346 png_infop info_ptr, int *unit, double *width, double *height)); 2347 #else 2348 #ifdef PNG_FIXED_POINT_SUPPORTED 2349 extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr, 2350 png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); 2351 #endif 2352 #endif 2353 #endif /* PNG_sCAL_SUPPORTED */ 2354 2355 #if defined(PNG_sCAL_SUPPORTED) 2356 #ifdef PNG_FLOATING_POINT_SUPPORTED 2357 extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr, 2358 png_infop info_ptr, int unit, double width, double height)); 2359 #else 2360 #ifdef PNG_FIXED_POINT_SUPPORTED 2361 extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, 2362 png_infop info_ptr, int unit, png_charp swidth, png_charp sheight)); 2363 #endif 2364 #endif 2365 #endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ 2366 2367 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) 2368 /* provide a list of chunks and how they are to be handled, if the built-in 2369 handling or default unknown chunk handling is not desired. Any chunks not 2370 listed will be handled in the default manner. The IHDR and IEND chunks 2371 must not be listed. 2372 keep = 0: follow default behavour 2373 = 1: do not keep 2374 = 2: keep only if safe-to-copy 2375 = 3: keep even if unsafe-to-copy 2376 */ 2377 extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp 2378 png_ptr, int keep, png_bytep chunk_list, int num_chunks)); 2379 extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, 2380 png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); 2381 extern PNG_EXPORT(void, png_set_unknown_chunk_location) 2382 PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location)); 2383 extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp 2384 png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); 2385 #endif 2386 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED 2387 PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep 2388 chunk_name)); 2389 #endif 2390 2391 /* Png_free_data() will turn off the "valid" flag for anything it frees. 2392 If you need to turn it off for a chunk that your application has freed, 2393 you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ 2394 extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr, 2395 png_infop info_ptr, int mask)); 2396 2397 #if defined(PNG_INFO_IMAGE_SUPPORTED) 2398 /* The "params" pointer is currently not used and is for future expansion. */ 2399 extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr, 2400 png_infop info_ptr, 2401 int transforms, 2402 png_voidp params)); 2403 extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr, 2404 png_infop info_ptr, 2405 int transforms, 2406 png_voidp params)); 2407 #endif 2408 2409 /* Define PNG_DEBUG at compile time for debugging information. Higher 2410 * numbers for PNG_DEBUG mean more debugging information. This has 2411 * only been added since version 0.95 so it is not implemented throughout 2412 * libpng yet, but more support will be added as needed. 2413 */ 2414 #ifdef PNG_DEBUG 2415 #if (PNG_DEBUG > 0) 2416 #if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) 2417 #include <crtdbg.h> 2418 #if (PNG_DEBUG > 1) 2419 #define png_debug(l,m) _RPT0(_CRT_WARN,m) 2420 #define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m,p1) 2421 #define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2) 2422 #endif 2423 #else /* PNG_DEBUG_FILE || !_MSC_VER */ 2424 #ifndef PNG_DEBUG_FILE 2425 #define PNG_DEBUG_FILE stderr 2426 #endif /* PNG_DEBUG_FILE */ 2427 #if (PNG_DEBUG > 1) 2428 #define png_debug(l,m) \ 2429 { \ 2430 int num_tabs=l; \ 2431 fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ 2432 (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ 2433 } 2434 #define png_debug1(l,m,p1) \ 2435 { \ 2436 int num_tabs=l; \ 2437 fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ 2438 (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ 2439 } 2440 #define png_debug2(l,m,p1,p2) \ 2441 { \ 2442 int num_tabs=l; \ 2443 fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ 2444 (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ 2445 } 2446 #endif /* (PNG_DEBUG > 1) */ 2447 #endif /* _MSC_VER */ 2448 #endif /* (PNG_DEBUG > 0) */ 2449 #endif /* PNG_DEBUG */ 2450 #ifndef png_debug 2451 #define png_debug(l, m) 2452 #endif 2453 #ifndef png_debug1 2454 #define png_debug1(l, m, p1) 2455 #endif 2456 #ifndef png_debug2 2457 #define png_debug2(l, m, p1, p2) 2458 #endif 2459 2460 #if 0 2461 extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void)); 2462 #endif 2463 2464 extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr)); 2465 extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr)); 2466 extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr)); 2467 extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); 2468 2469 #ifdef PNG_MNG_FEATURES_SUPPORTED 2470 extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp 2471 png_ptr, png_uint_32 mng_features_permitted)); 2472 #endif 2473 2474 /* For use in png_set_keep_unknown, added to version 1.2.6 */ 2475 #define PNG_HANDLE_CHUNK_AS_DEFAULT 0 2476 #define PNG_HANDLE_CHUNK_NEVER 1 2477 #define PNG_HANDLE_CHUNK_IF_SAFE 2 2478 #define PNG_HANDLE_CHUNK_ALWAYS 3 2479 2480 /* Added to version 1.2.0 */ 2481 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) 2482 #define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED 0x01 /* not user-settable */ 2483 #define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU 0x02 /* not user-settable */ 2484 #define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW 0x04 2485 #define PNG_ASM_FLAG_MMX_READ_INTERLACE 0x08 2486 #define PNG_ASM_FLAG_MMX_READ_FILTER_SUB 0x10 2487 #define PNG_ASM_FLAG_MMX_READ_FILTER_UP 0x20 2488 #define PNG_ASM_FLAG_MMX_READ_FILTER_AVG 0x40 2489 #define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80 2490 #define PNG_ASM_FLAGS_INITIALIZED 0x80000000 /* not user-settable */ 2491 2492 #define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ 2493 | PNG_ASM_FLAG_MMX_READ_INTERLACE \ 2494 | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ 2495 | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ 2496 | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ 2497 | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ) 2498 #define PNG_MMX_WRITE_FLAGS ( 0 ) 2499 2500 #define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \ 2501 | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU \ 2502 | PNG_MMX_READ_FLAGS \ 2503 | PNG_MMX_WRITE_FLAGS ) 2504 2505 #define PNG_SELECT_READ 1 2506 #define PNG_SELECT_WRITE 2 2507 2508 #if !defined(PNG_1_0_X) 2509 /* pngget.c */ 2510 extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask) 2511 PNGARG((int flag_select, int *compilerID)); 2512 2513 /* pngget.c */ 2514 extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask) 2515 PNGARG((int flag_select)); 2516 2517 /* pngget.c */ 2518 extern PNG_EXPORT(png_uint_32,png_get_asm_flags) 2519 PNGARG((png_structp png_ptr)); 2520 2521 /* pngget.c */ 2522 extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold) 2523 PNGARG((png_structp png_ptr)); 2524 2525 /* pngget.c */ 2526 extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold) 2527 PNGARG((png_structp png_ptr)); 2528 2529 /* pngset.c */ 2530 extern PNG_EXPORT(void,png_set_asm_flags) 2531 PNGARG((png_structp png_ptr, png_uint_32 asm_flags)); 2532 2533 /* pngset.c */ 2534 extern PNG_EXPORT(void,png_set_mmx_thresholds) 2535 PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold, 2536 png_uint_32 mmx_rowbytes_threshold)); 2537 2538 #endif /* PNG_1_0_X */ 2539 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ 2540 2541 #if !defined(PNG_1_0_X) 2542 /* png.c, pnggccrd.c, or pngvcrd.c */ 2543 extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); 2544 2545 /* Strip the prepended error numbers ("#nnn ") from error and warning 2546 * messages before passing them to the error or warning handler. */ 2547 #ifdef PNG_ERROR_NUMBERS_SUPPORTED 2548 extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp 2549 png_ptr, png_uint_32 strip_mode)); 2550 #endif 2551 2552 #endif /* PNG_1_0_X */ 2553 2554 /* Added at libpng-1.2.6 */ 2555 #ifdef PNG_SET_USER_LIMITS_SUPPORTED 2556 extern PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp 2557 png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max)); 2558 extern PNG_EXPORT(png_uint_32,png_get_user_width_max) PNGARG((png_structp 2559 png_ptr)); 2560 extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp 2561 png_ptr)); 2562 #endif 2563 2564 /* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ 2565 2566 #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED 2567 /* With these routines we avoid an integer divide, which will be slower on 2568 * most machines. However, it does take more operations than the corresponding 2569 * divide method, so it may be slower on a few RISC systems. There are two 2570 * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. 2571 * 2572 * Note that the rounding factors are NOT supposed to be the same! 128 and 2573 * 32768 are correct for the NODIV code; 127 and 32767 are correct for the 2574 * standard method. 2575 * 2576 * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] 2577 */ 2578 2579 /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ 2580 2581 # define png_composite(composite, fg, alpha, bg) \ 2582 { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \ 2583 + (png_uint_16)(bg)*(png_uint_16)(255 - \ 2584 (png_uint_16)(alpha)) + (png_uint_16)128); \ 2585 (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } 2586 2587 # define png_composite_16(composite, fg, alpha, bg) \ 2588 { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \ 2589 + (png_uint_32)(bg)*(png_uint_32)(65535L - \ 2590 (png_uint_32)(alpha)) + (png_uint_32)32768L); \ 2591 (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } 2592 2593 #else /* standard method using integer division */ 2594 2595 # define png_composite(composite, fg, alpha, bg) \ 2596 (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ 2597 (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ 2598 (png_uint_16)127) / 255) 2599 2600 # define png_composite_16(composite, fg, alpha, bg) \ 2601 (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ 2602 (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \ 2603 (png_uint_32)32767) / (png_uint_32)65535L) 2604 2605 #endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ 2606 2607 /* Inline macros to do direct reads of bytes from the input buffer. These 2608 * require that you are using an architecture that uses PNG byte ordering 2609 * (MSB first) and supports unaligned data storage. I think that PowerPC 2610 * in big-endian mode and 680x0 are the only ones that will support this. 2611 * The x86 line of processors definitely do not. The png_get_int_32() 2612 * routine also assumes we are using two's complement format for negative 2613 * values, which is almost certainly true. 2614 */ 2615 #if defined(PNG_READ_BIG_ENDIAN_SUPPORTED) 2616 # define png_get_uint_32(buf) ( *((png_uint_32p) (buf))) 2617 # define png_get_uint_16(buf) ( *((png_uint_16p) (buf))) 2618 # define png_get_int_32(buf) ( *((png_int_32p) (buf))) 2619 #else 2620 extern PNG_EXPORT(png_uint_32,png_get_uint_32) PNGARG((png_bytep buf)); 2621 extern PNG_EXPORT(png_uint_16,png_get_uint_16) PNGARG((png_bytep buf)); 2622 extern PNG_EXPORT(png_int_32,png_get_int_32) PNGARG((png_bytep buf)); 2623 #endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */ 2624 extern PNG_EXPORT(png_uint_32,png_get_uint_31) 2625 PNGARG((png_structp png_ptr, png_bytep buf)); 2626 /* No png_get_int_16 -- may be added if there's a real need for it. */ 2627 2628 /* Place a 32-bit number into a buffer in PNG byte order (big-endian). 2629 */ 2630 extern PNG_EXPORT(void,png_save_uint_32) 2631 PNGARG((png_bytep buf, png_uint_32 i)); 2632 extern PNG_EXPORT(void,png_save_int_32) 2633 PNGARG((png_bytep buf, png_int_32 i)); 2634 2635 /* Place a 16-bit number into a buffer in PNG byte order. 2636 * The parameter is declared unsigned int, not png_uint_16, 2637 * just to avoid potential problems on pre-ANSI C compilers. 2638 */ 2639 extern PNG_EXPORT(void,png_save_uint_16) 2640 PNGARG((png_bytep buf, unsigned int i)); 2641 /* No png_save_int_16 -- may be added if there's a real need for it. */ 2642 2643 /* ************************************************************************* */ 2644 2645 /* These next functions are used internally in the code. They generally 2646 * shouldn't be used unless you are writing code to add or replace some 2647 * functionality in libpng. More information about most functions can 2648 * be found in the files where the functions are located. 2649 */ 2650 2651 #if defined(PNG_INTERNAL) 2652 2653 /* Various modes of operation. Note that after an init, mode is set to 2654 * zero automatically when the structure is created. 2655 */ 2656 #define PNG_HAVE_IHDR 0x01 2657 #define PNG_HAVE_PLTE 0x02 2658 #define PNG_HAVE_IDAT 0x04 2659 #define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */ 2660 #define PNG_HAVE_IEND 0x10 2661 #define PNG_HAVE_gAMA 0x20 2662 #define PNG_HAVE_cHRM 0x40 2663 #define PNG_HAVE_sRGB 0x80 2664 #define PNG_HAVE_CHUNK_HEADER 0x100 2665 #define PNG_WROTE_tIME 0x200 2666 #define PNG_WROTE_INFO_BEFORE_PLTE 0x400 2667 #define PNG_BACKGROUND_IS_GRAY 0x800 2668 #define PNG_HAVE_PNG_SIGNATURE 0x1000 2669 #define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ 2670 2671 /* flags for the transformations the PNG library does on the image data */ 2672 #define PNG_BGR 0x0001 2673 #define PNG_INTERLACE 0x0002 2674 #define PNG_PACK 0x0004 2675 #define PNG_SHIFT 0x0008 2676 #define PNG_SWAP_BYTES 0x0010 2677 #define PNG_INVERT_MONO 0x0020 2678 #define PNG_DITHER 0x0040 2679 #define PNG_BACKGROUND 0x0080 2680 #define PNG_BACKGROUND_EXPAND 0x0100 2681 /* 0x0200 unused */ 2682 #define PNG_16_TO_8 0x0400 2683 #define PNG_RGBA 0x0800 2684 #define PNG_EXPAND 0x1000 2685 #define PNG_GAMMA 0x2000 2686 #define PNG_GRAY_TO_RGB 0x4000 2687 #define PNG_FILLER 0x8000L 2688 #define PNG_PACKSWAP 0x10000L 2689 #define PNG_SWAP_ALPHA 0x20000L 2690 #define PNG_STRIP_ALPHA 0x40000L 2691 #define PNG_INVERT_ALPHA 0x80000L 2692 #define PNG_USER_TRANSFORM 0x100000L 2693 #define PNG_RGB_TO_GRAY_ERR 0x200000L 2694 #define PNG_RGB_TO_GRAY_WARN 0x400000L 2695 #define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */ 2696 /* 0x800000L Unused */ 2697 #define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */ 2698 #define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */ 2699 /* 0x4000000L unused */ 2700 /* 0x8000000L unused */ 2701 /* 0x10000000L unused */ 2702 /* 0x20000000L unused */ 2703 /* 0x40000000L unused */ 2704 2705 /* flags for png_create_struct */ 2706 #define PNG_STRUCT_PNG 0x0001 2707 #define PNG_STRUCT_INFO 0x0002 2708 2709 /* Scaling factor for filter heuristic weighting calculations */ 2710 #define PNG_WEIGHT_SHIFT 8 2711 #define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) 2712 #define PNG_COST_SHIFT 3 2713 #define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) 2714 2715 /* flags for the png_ptr->flags rather than declaring a byte for each one */ 2716 #define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 2717 #define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 2718 #define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004 2719 #define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008 2720 #define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010 2721 #define PNG_FLAG_ZLIB_FINISHED 0x0020 2722 #define PNG_FLAG_ROW_INIT 0x0040 2723 #define PNG_FLAG_FILLER_AFTER 0x0080 2724 #define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 2725 #define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 2726 #define PNG_FLAG_CRC_CRITICAL_USE 0x0400 2727 #define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 2728 #define PNG_FLAG_FREE_PLTE 0x1000 2729 #define PNG_FLAG_FREE_TRNS 0x2000 2730 #define PNG_FLAG_FREE_HIST 0x4000 2731 #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L 2732 #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L 2733 #define PNG_FLAG_LIBRARY_MISMATCH 0x20000L 2734 #define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L 2735 #define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L 2736 #define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L 2737 #define PNG_FLAG_ADD_ALPHA 0x200000L /* Added to libpng-1.2.8 */ 2738 #define PNG_FLAG_STRIP_ALPHA 0x400000L /* Added to libpng-1.2.8 */ 2739 /* 0x800000L unused */ 2740 /* 0x1000000L unused */ 2741 /* 0x2000000L unused */ 2742 /* 0x4000000L unused */ 2743 /* 0x8000000L unused */ 2744 /* 0x10000000L unused */ 2745 /* 0x20000000L unused */ 2746 /* 0x40000000L unused */ 2747 2748 #define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ 2749 PNG_FLAG_CRC_ANCILLARY_NOWARN) 2750 2751 #define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ 2752 PNG_FLAG_CRC_CRITICAL_IGNORE) 2753 2754 #define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ 2755 PNG_FLAG_CRC_CRITICAL_MASK) 2756 2757 /* save typing and make code easier to understand */ 2758 2759 #define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ 2760 abs((int)((c1).green) - (int)((c2).green)) + \ 2761 abs((int)((c1).blue) - (int)((c2).blue))) 2762 2763 /* Added to libpng-1.2.6 JB */ 2764 #define PNG_ROWBYTES(pixel_bits, width) \ 2765 ((pixel_bits) >= 8 ? \ 2766 ((width) * (((png_uint_32)(pixel_bits)) >> 3)) : \ 2767 (( ((width) * ((png_uint_32)(pixel_bits))) + 7) >> 3) ) 2768 2769 /* PNG_OUT_OF_RANGE returns true if value is outside the range 2770 ideal-delta..ideal+delta. Each argument is evaluated twice. 2771 "ideal" and "delta" should be constants, normally simple 2772 integers, "value" a variable. Added to libpng-1.2.6 JB */ 2773 #define PNG_OUT_OF_RANGE(value, ideal, delta) \ 2774 ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) 2775 2776 /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ 2777 #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) 2778 /* place to hold the signature string for a PNG file. */ 2779 #ifdef PNG_USE_GLOBAL_ARRAYS 2780 PNG_EXPORT_VAR (const png_byte FARDATA) png_sig[8]; 2781 #else 2782 #if 0 2783 #define png_sig png_sig_bytes(NULL) 2784 #endif 2785 #endif 2786 #endif /* PNG_NO_EXTERN */ 2787 2788 /* Constant strings for known chunk types. If you need to add a chunk, 2789 * define the name here, and add an invocation of the macro in png.c and 2790 * wherever it's needed. 2791 */ 2792 #define PNG_IHDR const png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'} 2793 #define PNG_IDAT const png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'} 2794 #define PNG_IEND const png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'} 2795 #define PNG_PLTE const png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'} 2796 #define PNG_bKGD const png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'} 2797 #define PNG_cHRM const png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'} 2798 #define PNG_gAMA const png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'} 2799 #define PNG_hIST const png_byte png_hIST[5] = {104, 73, 83, 84, '\0'} 2800 #define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'} 2801 #define PNG_iTXt const png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'} 2802 #define PNG_oFFs const png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'} 2803 #define PNG_pCAL const png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'} 2804 #define PNG_sCAL const png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'} 2805 #define PNG_pHYs const png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'} 2806 #define PNG_sBIT const png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'} 2807 #define PNG_sPLT const png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'} 2808 #define PNG_sRGB const png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'} 2809 #define PNG_tEXt const png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'} 2810 #define PNG_tIME const png_byte png_tIME[5] = {116, 73, 77, 69, '\0'} 2811 #define PNG_tRNS const png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'} 2812 #define PNG_zTXt const png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'} 2813 2814 #ifdef PNG_USE_GLOBAL_ARRAYS 2815 PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5]; 2816 PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5]; 2817 PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5]; 2818 PNG_EXPORT_VAR (const png_byte FARDATA) png_PLTE[5]; 2819 PNG_EXPORT_VAR (const png_byte FARDATA) png_bKGD[5]; 2820 PNG_EXPORT_VAR (const png_byte FARDATA) png_cHRM[5]; 2821 PNG_EXPORT_VAR (const png_byte FARDATA) png_gAMA[5]; 2822 PNG_EXPORT_VAR (const png_byte FARDATA) png_hIST[5]; 2823 PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5]; 2824 PNG_EXPORT_VAR (const png_byte FARDATA) png_iTXt[5]; 2825 PNG_EXPORT_VAR (const png_byte FARDATA) png_oFFs[5]; 2826 PNG_EXPORT_VAR (const png_byte FARDATA) png_pCAL[5]; 2827 PNG_EXPORT_VAR (const png_byte FARDATA) png_sCAL[5]; 2828 PNG_EXPORT_VAR (const png_byte FARDATA) png_pHYs[5]; 2829 PNG_EXPORT_VAR (const png_byte FARDATA) png_sBIT[5]; 2830 PNG_EXPORT_VAR (const png_byte FARDATA) png_sPLT[5]; 2831 PNG_EXPORT_VAR (const png_byte FARDATA) png_sRGB[5]; 2832 PNG_EXPORT_VAR (const png_byte FARDATA) png_tEXt[5]; 2833 PNG_EXPORT_VAR (const png_byte FARDATA) png_tIME[5]; 2834 PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5]; 2835 PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5]; 2836 #endif /* PNG_USE_GLOBAL_ARRAYS */ 2837 2838 #if defined(PNG_1_0_X) || defined (PNG_1_2_X) 2839 /* Initialize png_ptr struct for reading, and allocate any other memory. 2840 * (old interface - DEPRECATED - use png_create_read_struct instead). 2841 */ 2842 extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr)); 2843 #undef png_read_init 2844 #define png_read_init(png_ptr) png_read_init_3(&png_ptr, \ 2845 PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); 2846 #endif 2847 2848 extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr, 2849 png_const_charp user_png_ver, png_size_t png_struct_size)); 2850 #if defined(PNG_1_0_X) || defined (PNG_1_2_X) 2851 extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, 2852 png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t 2853 png_info_size)); 2854 #endif 2855 2856 #if defined(PNG_1_0_X) || defined (PNG_1_2_X) 2857 /* Initialize png_ptr struct for writing, and allocate any other memory. 2858 * (old interface - DEPRECATED - use png_create_write_struct instead). 2859 */ 2860 extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr)); 2861 #undef png_write_init 2862 #define png_write_init(png_ptr) png_write_init_3(&png_ptr, \ 2863 PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); 2864 #endif 2865 2866 extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr, 2867 png_const_charp user_png_ver, png_size_t png_struct_size)); 2868 extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, 2869 png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t 2870 png_info_size)); 2871 2872 /* Allocate memory for an internal libpng struct */ 2873 PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); 2874 2875 /* Free memory from internal libpng struct */ 2876 PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); 2877 2878 PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr 2879 malloc_fn, png_voidp mem_ptr)); 2880 PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, 2881 png_free_ptr free_fn, png_voidp mem_ptr)); 2882 2883 /* Free any memory that info_ptr points to and reset struct. */ 2884 PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, 2885 png_infop info_ptr)); 2886 2887 #ifndef PNG_1_0_X 2888 /* Function to allocate memory for zlib. */ 2889 PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size)); 2890 2891 /* Function to free memory for zlib */ 2892 PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); 2893 2894 #ifdef PNG_SIZE_T 2895 /* Function to convert a sizeof an item to png_sizeof item */ 2896 PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); 2897 #endif 2898 2899 /* Next four functions are used internally as callbacks. PNGAPI is required 2900 * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */ 2901 2902 PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr, 2903 png_bytep data, png_size_t length)); 2904 2905 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED 2906 PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr, 2907 png_bytep buffer, png_size_t length)); 2908 #endif 2909 2910 PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr, 2911 png_bytep data, png_size_t length)); 2912 2913 #if defined(PNG_WRITE_FLUSH_SUPPORTED) 2914 #if !defined(PNG_NO_STDIO) 2915 PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr)); 2916 #endif 2917 #endif 2918 #else /* PNG_1_0_X */ 2919 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED 2920 PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr, 2921 png_bytep buffer, png_size_t length)); 2922 #endif 2923 #endif /* PNG_1_0_X */ 2924 2925 /* Reset the CRC variable */ 2926 PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)); 2927 2928 /* Write the "data" buffer to whatever output you are using. */ 2929 PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data, 2930 png_size_t length)); 2931 2932 /* Read data from whatever input you are using into the "data" buffer */ 2933 PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data, 2934 png_size_t length)); 2935 2936 /* Read bytes into buf, and update png_ptr->crc */ 2937 PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, 2938 png_size_t length)); 2939 2940 /* Decompress data in a chunk that uses compression */ 2941 #if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ 2942 defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) 2943 PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr, 2944 int comp_type, png_charp chunkdata, png_size_t chunklength, 2945 png_size_t prefix_length, png_size_t *data_length)); 2946 #endif 2947 2948 /* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ 2949 PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)); 2950 2951 /* Read the CRC from the file and compare it to the libpng calculated CRC */ 2952 PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)); 2953 2954 /* Calculate the CRC over a section of data. Note that we are only 2955 * passing a maximum of 64K on systems that have this as a memory limit, 2956 * since this is the maximum buffer size we can specify. 2957 */ 2958 PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr, 2959 png_size_t length)); 2960 2961 #if defined(PNG_WRITE_FLUSH_SUPPORTED) 2962 PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); 2963 #endif 2964 2965 /* simple function to write the signature */ 2966 PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)); 2967 2968 /* write various chunks */ 2969 2970 /* Write the IHDR chunk, and update the png_struct with the necessary 2971 * information. 2972 */ 2973 PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, 2974 png_uint_32 height, 2975 int bit_depth, int color_type, int compression_method, int filter_method, 2976 int interlace_method)); 2977 2978 PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette, 2979 png_uint_32 num_pal)); 2980 2981 PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data, 2982 png_size_t length)); 2983 2984 PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)); 2985 2986 #if defined(PNG_WRITE_gAMA_SUPPORTED) 2987 #ifdef PNG_FLOATING_POINT_SUPPORTED 2988 PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma)); 2989 #endif 2990 #ifdef PNG_FIXED_POINT_SUPPORTED 2991 PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point 2992 file_gamma)); 2993 #endif 2994 #endif 2995 2996 #if defined(PNG_WRITE_sBIT_SUPPORTED) 2997 PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit, 2998 int color_type)); 2999 #endif 3000 3001 #if defined(PNG_WRITE_cHRM_SUPPORTED) 3002 #ifdef PNG_FLOATING_POINT_SUPPORTED 3003 PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr, 3004 double white_x, double white_y, 3005 double red_x, double red_y, double green_x, double green_y, 3006 double blue_x, double blue_y)); 3007 #endif 3008 #ifdef PNG_FIXED_POINT_SUPPORTED 3009 PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr, 3010 png_fixed_point int_white_x, png_fixed_point int_white_y, 3011 png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point 3012 int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, 3013 png_fixed_point int_blue_y)); 3014 #endif 3015 #endif 3016 3017 #if defined(PNG_WRITE_sRGB_SUPPORTED) 3018 PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr, 3019 int intent)); 3020 #endif 3021 3022 #if defined(PNG_WRITE_iCCP_SUPPORTED) 3023 PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, 3024 png_charp name, int compression_type, 3025 png_charp profile, int proflen)); 3026 /* Note to maintainer: profile should be png_bytep */ 3027 #endif 3028 3029 #if defined(PNG_WRITE_sPLT_SUPPORTED) 3030 PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, 3031 png_sPLT_tp palette)); 3032 #endif 3033 3034 #if defined(PNG_WRITE_tRNS_SUPPORTED) 3035 PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans, 3036 png_color_16p values, int number, int color_type)); 3037 #endif 3038 3039 #if defined(PNG_WRITE_bKGD_SUPPORTED) 3040 PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr, 3041 png_color_16p values, int color_type)); 3042 #endif 3043 3044 #if defined(PNG_WRITE_hIST_SUPPORTED) 3045 PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist, 3046 int num_hist)); 3047 #endif 3048 3049 #if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ 3050 defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) 3051 PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr, 3052 png_charp key, png_charpp new_key)); 3053 #endif 3054 3055 #if defined(PNG_WRITE_tEXt_SUPPORTED) 3056 PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key, 3057 png_charp text, png_size_t text_len)); 3058 #endif 3059 3060 #if defined(PNG_WRITE_zTXt_SUPPORTED) 3061 PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key, 3062 png_charp text, png_size_t text_len, int compression)); 3063 #endif 3064 3065 #if defined(PNG_WRITE_iTXt_SUPPORTED) 3066 PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr, 3067 int compression, png_charp key, png_charp lang, png_charp lang_key, 3068 png_charp text)); 3069 #endif 3070 3071 #if defined(PNG_TEXT_SUPPORTED) /* Added at version 1.0.14 and 1.2.4 */ 3072 PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr, 3073 png_infop info_ptr, png_textp text_ptr, int num_text)); 3074 #endif 3075 3076 #if defined(PNG_WRITE_oFFs_SUPPORTED) 3077 PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, 3078 png_int_32 x_offset, png_int_32 y_offset, int unit_type)); 3079 #endif 3080 3081 #if defined(PNG_WRITE_pCAL_SUPPORTED) 3082 PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose, 3083 png_int_32 X0, png_int_32 X1, int type, int nparams, 3084 png_charp units, png_charpp params)); 3085 #endif 3086 3087 #if defined(PNG_WRITE_pHYs_SUPPORTED) 3088 PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr, 3089 png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, 3090 int unit_type)); 3091 #endif 3092 3093 #if defined(PNG_WRITE_tIME_SUPPORTED) 3094 PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr, 3095 png_timep mod_time)); 3096 #endif 3097 3098 #if defined(PNG_WRITE_sCAL_SUPPORTED) 3099 #if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) 3100 PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr, 3101 int unit, double width, double height)); 3102 #else 3103 #ifdef PNG_FIXED_POINT_SUPPORTED 3104 PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr, 3105 int unit, png_charp width, png_charp height)); 3106 #endif 3107 #endif 3108 #endif 3109 3110 /* Called when finished processing a row of data */ 3111 PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)); 3112 3113 /* Internal use only. Called before first row of data */ 3114 PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)); 3115 3116 #if defined(PNG_READ_GAMMA_SUPPORTED) 3117 PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)); 3118 #endif 3119 3120 /* combine a row of data, dealing with alpha, etc. if requested */ 3121 PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, 3122 int mask)); 3123 3124 #if defined(PNG_READ_INTERLACING_SUPPORTED) 3125 /* expand an interlaced row */ 3126 /* OLD pre-1.0.9 interface: 3127 PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, 3128 png_bytep row, int pass, png_uint_32 transformations)); 3129 */ 3130 PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)); 3131 #endif 3132 3133 /* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ 3134 3135 #if defined(PNG_WRITE_INTERLACING_SUPPORTED) 3136 /* grab pixels out of a row for an interlaced pass */ 3137 PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, 3138 png_bytep row, int pass)); 3139 #endif 3140 3141 /* unfilter a row */ 3142 PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, 3143 png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); 3144 3145 /* Choose the best filter to use and filter the row data */ 3146 PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr, 3147 png_row_infop row_info)); 3148 3149 /* Write out the filtered row. */ 3150 PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, 3151 png_bytep filtered_row)); 3152 /* finish a row while reading, dealing with interlacing passes, etc. */ 3153 PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); 3154 3155 /* initialize the row buffers, etc. */ 3156 PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)); 3157 /* optional call to update the users info structure */ 3158 PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, 3159 png_infop info_ptr)); 3160 3161 /* these are the functions that do the transformations */ 3162 #if defined(PNG_READ_FILLER_SUPPORTED) 3163 PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, 3164 png_bytep row, png_uint_32 filler, png_uint_32 flags)); 3165 #endif 3166 3167 #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) 3168 PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info, 3169 png_bytep row)); 3170 #endif 3171 3172 #if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) 3173 PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info, 3174 png_bytep row)); 3175 #endif 3176 3177 #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) 3178 PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info, 3179 png_bytep row)); 3180 #endif 3181 3182 #if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) 3183 PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info, 3184 png_bytep row)); 3185 #endif 3186 3187 #if defined(PNG_WRITE_FILLER_SUPPORTED) || \ 3188 defined(PNG_READ_STRIP_ALPHA_SUPPORTED) 3189 PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info, 3190 png_bytep row, png_uint_32 flags)); 3191 #endif 3192 3193 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) 3194 PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row)); 3195 #endif 3196 3197 #if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) 3198 PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row)); 3199 #endif 3200 3201 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) 3202 PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop 3203 row_info, png_bytep row)); 3204 #endif 3205 3206 #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) 3207 PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info, 3208 png_bytep row)); 3209 #endif 3210 3211 #if defined(PNG_READ_PACK_SUPPORTED) 3212 PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row)); 3213 #endif 3214 3215 #if defined(PNG_READ_SHIFT_SUPPORTED) 3216 PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row, 3217 png_color_8p sig_bits)); 3218 #endif 3219 3220 #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) 3221 PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row)); 3222 #endif 3223 3224 #if defined(PNG_READ_16_TO_8_SUPPORTED) 3225 PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); 3226 #endif 3227 3228 #if defined(PNG_READ_DITHER_SUPPORTED) 3229 PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info, 3230 png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup)); 3231 3232 # if defined(PNG_CORRECT_PALETTE_SUPPORTED) 3233 PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr, 3234 png_colorp palette, int num_palette)); 3235 # endif 3236 #endif 3237 3238 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) 3239 PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row)); 3240 #endif 3241 3242 #if defined(PNG_WRITE_PACK_SUPPORTED) 3243 PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info, 3244 png_bytep row, png_uint_32 bit_depth)); 3245 #endif 3246 3247 #if defined(PNG_WRITE_SHIFT_SUPPORTED) 3248 PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, 3249 png_color_8p bit_depth)); 3250 #endif 3251 3252 #if defined(PNG_READ_BACKGROUND_SUPPORTED) 3253 #if defined(PNG_READ_GAMMA_SUPPORTED) 3254 PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, 3255 png_color_16p trans_values, png_color_16p background, 3256 png_color_16p background_1, 3257 png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, 3258 png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, 3259 png_uint_16pp gamma_16_to_1, int gamma_shift)); 3260 #else 3261 PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, 3262 png_color_16p trans_values, png_color_16p background)); 3263 #endif 3264 #endif 3265 3266 #if defined(PNG_READ_GAMMA_SUPPORTED) 3267 PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row, 3268 png_bytep gamma_table, png_uint_16pp gamma_16_table, 3269 int gamma_shift)); 3270 #endif 3271 3272 #if defined(PNG_READ_EXPAND_SUPPORTED) 3273 PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info, 3274 png_bytep row, png_colorp palette, png_bytep trans, int num_trans)); 3275 PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info, 3276 png_bytep row, png_color_16p trans_value)); 3277 #endif 3278 3279 /* The following decodes the appropriate chunks, and does error correction, 3280 * then calls the appropriate callback for the chunk if it is valid. 3281 */ 3282 3283 /* decode the IHDR chunk */ 3284 PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, 3285 png_uint_32 length)); 3286 PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr, 3287 png_uint_32 length)); 3288 PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr, 3289 png_uint_32 length)); 3290 3291 #if defined(PNG_READ_bKGD_SUPPORTED) 3292 PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr, 3293 png_uint_32 length)); 3294 #endif 3295 3296 #if defined(PNG_READ_cHRM_SUPPORTED) 3297 PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr, 3298 png_uint_32 length)); 3299 #endif 3300 3301 #if defined(PNG_READ_gAMA_SUPPORTED) 3302 PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr, 3303 png_uint_32 length)); 3304 #endif 3305 3306 #if defined(PNG_READ_hIST_SUPPORTED) 3307 PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr, 3308 png_uint_32 length)); 3309 #endif 3310 3311 #if defined(PNG_READ_iCCP_SUPPORTED) 3312 extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, 3313 png_uint_32 length)); 3314 #endif /* PNG_READ_iCCP_SUPPORTED */ 3315 3316 #if defined(PNG_READ_iTXt_SUPPORTED) 3317 PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr, 3318 png_uint_32 length)); 3319 #endif 3320 3321 #if defined(PNG_READ_oFFs_SUPPORTED) 3322 PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr, 3323 png_uint_32 length)); 3324 #endif 3325 3326 #if defined(PNG_READ_pCAL_SUPPORTED) 3327 PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr, 3328 png_uint_32 length)); 3329 #endif 3330 3331 #if defined(PNG_READ_pHYs_SUPPORTED) 3332 PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr, 3333 png_uint_32 length)); 3334 #endif 3335 3336 #if defined(PNG_READ_sBIT_SUPPORTED) 3337 PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr, 3338 png_uint_32 length)); 3339 #endif 3340 3341 #if defined(PNG_READ_sCAL_SUPPORTED) 3342 PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr, 3343 png_uint_32 length)); 3344 #endif 3345 3346 #if defined(PNG_READ_sPLT_SUPPORTED) 3347 extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, 3348 png_uint_32 length)); 3349 #endif /* PNG_READ_sPLT_SUPPORTED */ 3350 3351 #if defined(PNG_READ_sRGB_SUPPORTED) 3352 PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr, 3353 png_uint_32 length)); 3354 #endif 3355 3356 #if defined(PNG_READ_tEXt_SUPPORTED) 3357 PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr, 3358 png_uint_32 length)); 3359 #endif 3360 3361 #if defined(PNG_READ_tIME_SUPPORTED) 3362 PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr, 3363 png_uint_32 length)); 3364 #endif 3365 3366 #if defined(PNG_READ_tRNS_SUPPORTED) 3367 PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr, 3368 png_uint_32 length)); 3369 #endif 3370 3371 #if defined(PNG_READ_zTXt_SUPPORTED) 3372 PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, 3373 png_uint_32 length)); 3374 #endif 3375 3376 PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, 3377 png_infop info_ptr, png_uint_32 length)); 3378 3379 PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, 3380 png_bytep chunk_name)); 3381 3382 /* handle the transformations for reading and writing */ 3383 PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); 3384 PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); 3385 3386 PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr)); 3387 3388 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED 3389 PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr, 3390 png_infop info_ptr)); 3391 PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr, 3392 png_infop info_ptr)); 3393 PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)); 3394 PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr, 3395 png_uint_32 length)); 3396 PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)); 3397 PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)); 3398 PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr, 3399 png_bytep buffer, png_size_t buffer_length)); 3400 PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)); 3401 PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr, 3402 png_bytep buffer, png_size_t buffer_length)); 3403 PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)); 3404 PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr, 3405 png_infop info_ptr, png_uint_32 length)); 3406 PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr, 3407 png_infop info_ptr)); 3408 PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr, 3409 png_infop info_ptr)); 3410 PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row)); 3411 PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr, 3412 png_infop info_ptr)); 3413 PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr, 3414 png_infop info_ptr)); 3415 PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr)); 3416 #if defined(PNG_READ_tEXt_SUPPORTED) 3417 PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr, 3418 png_infop info_ptr, png_uint_32 length)); 3419 PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr, 3420 png_infop info_ptr)); 3421 #endif 3422 #if defined(PNG_READ_zTXt_SUPPORTED) 3423 PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr, 3424 png_infop info_ptr, png_uint_32 length)); 3425 PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr, 3426 png_infop info_ptr)); 3427 #endif 3428 #if defined(PNG_READ_iTXt_SUPPORTED) 3429 PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr, 3430 png_infop info_ptr, png_uint_32 length)); 3431 PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr, 3432 png_infop info_ptr)); 3433 #endif 3434 3435 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ 3436 3437 #ifdef PNG_MNG_FEATURES_SUPPORTED 3438 PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info, 3439 png_bytep row)); 3440 PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, 3441 png_bytep row)); 3442 #endif 3443 3444 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) 3445 /* png.c */ /* PRIVATE */ 3446 PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr)); 3447 #endif 3448 3449 #if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) 3450 PNG_EXTERN png_uint_32 png_get_pixels_per_inch PNGARG((png_structp png_ptr, 3451 png_infop info_ptr)); 3452 3453 PNG_EXTERN png_uint_32 png_get_x_pixels_per_inch PNGARG((png_structp png_ptr, 3454 png_infop info_ptr)); 3455 3456 PNG_EXTERN png_uint_32 png_get_y_pixels_per_inch PNGARG((png_structp png_ptr, 3457 png_infop info_ptr)); 3458 3459 PNG_EXTERN float png_get_x_offset_inches PNGARG((png_structp png_ptr, 3460 png_infop info_ptr)); 3461 3462 PNG_EXTERN float png_get_y_offset_inches PNGARG((png_structp png_ptr, 3463 png_infop info_ptr)); 3464 3465 #if defined(PNG_pHYs_SUPPORTED) 3466 PNG_EXTERN png_uint_32 png_get_pHYs_dpi PNGARG((png_structp png_ptr, 3467 png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); 3468 #endif /* PNG_pHYs_SUPPORTED */ 3469 #endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ 3470 3471 /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ 3472 3473 #endif /* PNG_INTERNAL */ 3474 3475 #ifdef __cplusplus 3476 } 3477 #endif 3478 3479 #endif /* PNG_VERSION_INFO_ONLY */ 3480 /* do not put anything past this line */ 3481 #endif /* PNG_H */ 3482