1 #ifndef LIBRARIES_PNG_H 2 #define LIBRARIES_PNG_H 3 4 /* 5 6 MorphOS Shared PNGLib 7 8 png.library include 9 10 Copyright © 2003-2026 The MorphOS Development Team, All Rights Reserved. 11 12 */ 13 14 #ifndef EXEC_LIBRARIES_H 15 # include <exec/libraries.h> 16 #endif 17 18 #define PNG_H 19 20 #define PNG_LIBPNG_VER_STRING "1.2.59" 21 #define PNG_HEADER_VERSION_STRING \ 22 " libpng version 1.2.59 - September 28, 2017\n" 23 24 #define PNG_LIBPNG_VER_SONUM 0 25 #define PNG_LIBPNG_VER_DLLNUM 13 26 27 #define PNG_LIBPNG_VER_MAJOR 1 28 #define PNG_LIBPNG_VER_MINOR 2 29 #define PNG_LIBPNG_VER_RELEASE 59 30 31 #define PNG_LIBPNG_VER_BUILD 0 32 33 #define PNG_LIBPNG_BUILD_ALPHA 1 34 #define PNG_LIBPNG_BUILD_BETA 2 35 #define PNG_LIBPNG_BUILD_RC 3 36 #define PNG_LIBPNG_BUILD_STABLE 4 37 #define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7 38 #define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with PNG_LIBPNG_BUILD_STABLE only */ 39 #define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with PNG_LIBPNG_BUILD_SPECIAL */ 40 #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with PNG_LIBPNG_BUILD_PRIVATE */ 41 42 #define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE 43 #define PNG_LIBPNG_BUILD_TYPE PNG_LIBPNG_BUILD_BASE_TYPE 44 45 #define PNG_LIBPNG_VER 10259 /* 1.2.59 */ 46 47 48 #ifndef PNG_VERSION_INFO_ONLY 49 50 #include <libraries/z.h> 51 #include <sys/types.h> 52 #include <setjmp.h> 53 #include <strings.h> 54 #include <time.h> 55 #include <stdio.h> 56 57 /* 58 this part mimics pngconf.h 59 60 these defines match those used to compile png.library 61 62 */ 63 64 #define PNG_1_2_X 65 66 /* 67 pngconf: what we don't have 68 69 */ 70 71 #define PNG_NO_CONSOLE_IO 72 73 74 /* 75 pngconf: some constants 76 77 */ 78 79 #define PNG_ZBUF_SIZE 8192 80 #define PNGARG(arglist) arglist 81 #define PNG_CONST const 82 83 84 /* 85 pngconf: what we do have 86 */ 87 88 #define PNG_READ_SUPPORTED 89 #define PNG_WRITE_SUPPORTED 90 #define PNG_MNG_FEATURES_SUPPORTED 91 #define PNG_FLOATING_POINT_SUPPORTED 92 #define PNG_FIXED_POINT_SUPPORTED 93 #define PNG_SETJMP_SUPPORTED 94 #define PNG_USER_MEM_SUPPORTED 95 96 97 #define PNG_READ_TRANSFORMS_SUPPORTED 98 99 #define PNG_READ_EXPAND_SUPPORTED 100 #define PNG_READ_SHIFT_SUPPORTED 101 #define PNG_READ_PACK_SUPPORTED 102 #define PNG_READ_BGR_SUPPORTED 103 #define PNG_READ_SWAP_SUPPORTED 104 #define PNG_READ_PACKSWAP_SUPPORTED 105 #define PNG_READ_INVERT_SUPPORTED 106 #define PNG_READ_DITHER_SUPPORTED 107 #define PNG_READ_BACKGROUND_SUPPORTED 108 #define PNG_READ_16_TO_8_SUPPORTED 109 #define PNG_READ_FILLER_SUPPORTED 110 #define PNG_READ_GAMMA_SUPPORTED 111 #define PNG_READ_GRAY_TO_RGB_SUPPORTED 112 #define PNG_READ_SWAP_ALPHA_SUPPORTED 113 #define PNG_READ_INVERT_ALPHA_SUPPORTED 114 #define PNG_READ_STRIP_ALPHA_SUPPORTED 115 #define PNG_READ_USER_TRANSFORM_SUPPORTED 116 #define PNG_READ_RGB_TO_GRAY_SUPPORTED 117 118 #define PNG_READ_BIG_ENDIAN_SUPPORTED 119 120 #define PNG_PROGRESSIVE_READ_SUPPORTED 121 #define PNG_READ_INTERLACING_SUPPORTED 122 #define PNG_READ_COMPOSITE_NODIV_SUPPORTED 123 124 #define PNG_WRITE_TRANSFORMS_SUPPORTED 125 126 #define PNG_WRITE_SHIFT_SUPPORTED 127 #define PNG_WRITE_PACK_SUPPORTED 128 #define PNG_WRITE_BGR_SUPPORTED 129 #define PNG_WRITE_SWAP_SUPPORTED 130 #define PNG_WRITE_PACKSWAP_SUPPORTED 131 #define PNG_WRITE_INVERT_SUPPORTED 132 #define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */ 133 #define PNG_WRITE_SWAP_ALPHA_SUPPORTED 134 #define PNG_WRITE_INVERT_ALPHA_SUPPORTED 135 #define PNG_WRITE_USER_TRANSFORM_SUPPORTED 136 137 #define PNG_USER_TRANSFORM_PTR_SUPPORTED 138 139 #define PNG_WRITE_INTERLACING_SUPPORTED 140 141 #define PNG_ERROR_NUMBERS_SUPPORTED 142 #define PNG_WRITE_FLUSH_SUPPORTED 143 144 #define PNG_TIME_RFC1123_SUPPORTED 145 #define PNG_EASY_ACCESS_SUPPORTED 146 #define PNG_SET_USER_LIMITS_SUPPORTED 147 148 #define PNG_OPTIMIZED_CODE_SUPPORTED 149 150 /* 151 zconf: chunks 152 */ 153 154 #define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED 155 #define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED 156 157 #define PNG_UNKNOWN_CHUNKS_SUPPORTED 158 #define PNG_HANDLE_AS_UNKNOWN_SUPPORTED 159 160 #define PNG_READ_USER_CHUNKS_SUPPORTED 161 #define PNG_USER_CHUNKS_SUPPORTED 162 163 #define PNG_READ_OPT_PLTE_SUPPORTED 164 165 #define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED 166 #define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED 167 168 #define PNG_READ_TEXT_SUPPORTED 169 #define PNG_TEXT_SUPPORTED 170 171 #define PNG_iTXt_SUPPORTED 172 #define PNG_READ_iTXt_SUPPORTED 173 #define PNG_WRITE_iTXt_SUPPORTED 174 175 #define PNG_READ_bKGD_SUPPORTED 176 #define PNG_WRITE_bKGD_SUPPORTED 177 #define PNG_bKGD_SUPPORTED 178 179 #define PNG_READ_cHRM_SUPPORTED 180 #define PNG_WRITE_cHRM_SUPPORTED 181 #define PNG_cHRM_SUPPORTED 182 183 #define PNG_READ_gAMA_SUPPORTED 184 #define PNG_WRITE_gAMA_SUPPORTED 185 #define PNG_gAMA_SUPPORTED 186 187 #define PNG_READ_hIST_SUPPORTED 188 #define PNG_WRITE_hIST_SUPPORTED 189 #define PNG_hIST_SUPPORTED 190 191 #define PNG_READ_iCCP_SUPPORTED 192 #define PNG_WRITE_iCCP_SUPPORTED 193 #define PNG_iCCP_SUPPORTED 194 195 #define PNG_READ_iTXt_SUPPORTED 196 #define PNG_WRITE_iTXt_SUPPORTED 197 #define PNG_iTXt_SUPPORTED 198 199 #define PNG_READ_oFFs_SUPPORTED 200 #define PNG_WRITE_oFFs_SUPPORTED 201 #define PNG_oFFs_SUPPORTED 202 203 #define PNG_READ_pCAL_SUPPORTED 204 #define PNG_WRITE_pCAL_SUPPORTED 205 #define PNG_pCAL_SUPPORTED 206 207 #define PNG_READ_sCAL_SUPPORTED 208 #define PNG_WRITE_sCAL_SUPPORTED 209 #define PNG_sCAL_SUPPORTED 210 211 #define PNG_READ_pHYs_SUPPORTED 212 #define PNG_WRITE_pHYs_SUPPORTED 213 #define PNG_pHYs_SUPPORTED 214 215 #define PNG_READ_sBIT_SUPPORTED 216 #define PNG_WRITE_sBIT_SUPPORTED 217 #define PNG_sBIT_SUPPORTED 218 219 #define PNG_READ_sPLT_SUPPORTED 220 #define PNG_WRITE_sPLT_SUPPORTED 221 #define PNG_sPLT_SUPPORTED 222 223 #define PNG_READ_sRGB_SUPPORTED 224 #define PNG_WRITE_sRGB_SUPPORTED 225 #define PNG_sRGB_SUPPORTED 226 227 #define PNG_READ_tEXt_SUPPORTED 228 #define PNG_WRITE_tEXt_SUPPORTED 229 #define PNG_tEXt_SUPPORTED 230 231 #define PNG_READ_tIME_SUPPORTED 232 #define PNG_WRITE_tIME_SUPPORTED 233 #define PNG_tIME_SUPPORTED 234 235 #define PNG_READ_tRNS_SUPPORTED 236 #define PNG_WRITE_tRNS_SUPPORTED 237 #define PNG_tRNS_SUPPORTED 238 239 #define PNG_READ_zTXt_SUPPORTED 240 #define PNG_WRITE_zTXt_SUPPORTED 241 #define PNG_zTXt_SUPPORTED 242 243 244 #define PNG_INFO_IMAGE_SUPPORTED 245 246 247 #define PNG_SET_USER_LIMITS_SUPPORTED 248 #define PNG_USER_WIDTH_MAX 1000000L 249 #define PNG_USER_HEIGHT_MAX 1000000L 250 251 252 /* 253 zconf: types and defines 254 */ 255 256 257 #define FAR 258 #define FARDATA 259 260 typedef unsigned long png_uint_32; 261 typedef long png_int_32; 262 typedef unsigned short png_uint_16; 263 typedef short png_int_16; 264 typedef unsigned char png_byte; 265 266 267 typedef size_t png_size_t; 268 #define png_sizeof(x) sizeof(x) 269 270 typedef png_int_32 png_fixed_point; 271 272 typedef void FAR * png_voidp; 273 typedef png_byte FAR * png_bytep; 274 typedef png_uint_32 FAR * png_uint_32p; 275 typedef png_int_32 FAR * png_int_32p; 276 typedef png_uint_16 FAR * png_uint_16p; 277 typedef png_int_16 FAR * png_int_16p; 278 typedef PNG_CONST char FAR * png_const_charp; 279 typedef char FAR * png_charp; 280 typedef png_fixed_point FAR * png_fixed_point_p; 281 282 typedef FILE * png_FILE_p; 283 284 typedef double FAR * png_doublep; 285 286 typedef png_byte FAR * FAR * png_bytepp; 287 typedef png_uint_32 FAR * FAR * png_uint_32pp; 288 typedef png_int_32 FAR * FAR * png_int_32pp; 289 typedef png_uint_16 FAR * FAR * png_uint_16pp; 290 typedef png_int_16 FAR * FAR * png_int_16pp; 291 typedef PNG_CONST char FAR * FAR * png_const_charpp; 292 typedef char FAR * FAR * png_charpp; 293 typedef png_fixed_point FAR * FAR * png_fixed_point_pp; 294 typedef double FAR * FAR * png_doublepp; 295 296 typedef char FAR * FAR * FAR * png_charppp; 297 298 typedef charf * png_zcharp; 299 typedef charf * FAR * png_zcharpp; 300 typedef z_stream FAR * png_zstreamp; 301 302 #define PNGAPI 303 #define PNG_IMPEXP 304 #define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol 305 306 #define PNG_ABORT() abort() 307 #if _JBLEN != 59 && !defined(PNG_SKIP_SETJMP_CHECK) 308 /* 309 MorphOS png.library requires that the png_jmpbuf is 310 used with setjmp59/longjmp59 routines. Once the code 311 has been adjusted, define PNG_SKIP_SETJMP_CHECK. 312 */ 313 # define png_jmpbuf(png_ptr) \ 314 (MORPHOS_SHARED_PNG_LIBRARY_REQUIRES_USE_OF_setjmp59_FUNCTION) 315 #else 316 # define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf59) 317 #endif 318 319 320 /* 321 this part mimics png.h 322 */ 323 324 325 #ifdef __cplusplus 326 extern "C" { 327 #endif /* __cplusplus */ 328 329 #define int_p_NULL NULL 330 #define png_bytep_NULL NULL 331 #define png_bytepp_NULL NULL 332 #define png_doublep_NULL NULL 333 #define png_error_ptr_NULL NULL 334 #define png_flush_ptr_NULL NULL 335 #define png_free_ptr_NULL NULL 336 #define png_infopp_NULL NULL 337 #define png_malloc_ptr_NULL NULL 338 #define png_read_status_ptr_NULL NULL 339 #define png_rw_ptr_NULL NULL 340 #define png_structp_NULL NULL 341 #define png_uint_16p_NULL NULL 342 #define png_voidp_NULL NULL 343 #define png_write_status_ptr_NULL NULL 344 345 #define png_libpng_ver png_get_header_ver(NULL) 346 347 348 typedef struct png_color_struct 349 { 350 png_byte red; 351 png_byte green; 352 png_byte blue; 353 } png_color; 354 typedef png_color FAR * png_colorp; 355 typedef png_color FAR * FAR * png_colorpp; 356 357 typedef struct png_color_16_struct 358 { 359 png_byte index; 360 png_uint_16 red; 361 png_uint_16 green; 362 png_uint_16 blue; 363 png_uint_16 gray; 364 } png_color_16; 365 typedef png_color_16 FAR * png_color_16p; 366 typedef png_color_16 FAR * FAR * png_color_16pp; 367 368 typedef struct png_color_8_struct 369 { 370 png_byte red; 371 png_byte green; 372 png_byte blue; 373 png_byte gray; 374 png_byte alpha; 375 } png_color_8; 376 typedef png_color_8 FAR * png_color_8p; 377 typedef png_color_8 FAR * FAR * png_color_8pp; 378 379 typedef struct png_sPLT_entry_struct 380 { 381 png_uint_16 red; 382 png_uint_16 green; 383 png_uint_16 blue; 384 png_uint_16 alpha; 385 png_uint_16 frequency; 386 } png_sPLT_entry; 387 typedef png_sPLT_entry FAR * png_sPLT_entryp; 388 typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp; 389 390 typedef struct png_sPLT_struct 391 { 392 png_charp name; 393 png_byte depth; 394 png_sPLT_entryp entries; 395 png_int_32 nentries; 396 } png_sPLT_t; 397 typedef png_sPLT_t FAR * png_sPLT_tp; 398 typedef png_sPLT_t FAR * FAR * png_sPLT_tpp; 399 400 typedef struct png_text_struct 401 { 402 int compression; 403 png_charp key; 404 png_charp text; 405 png_size_t text_length; 406 png_size_t itxt_length; 407 png_charp lang; 408 png_charp lang_key; 409 } png_text; 410 typedef png_text FAR * png_textp; 411 typedef png_text FAR * FAR * png_textpp; 412 413 414 #define PNG_TEXT_COMPRESSION_NONE_WR -3 415 #define PNG_TEXT_COMPRESSION_zTXt_WR -2 416 #define PNG_TEXT_COMPRESSION_NONE -1 417 #define PNG_TEXT_COMPRESSION_zTXt 0 418 #define PNG_ITXT_COMPRESSION_NONE 1 419 #define PNG_ITXT_COMPRESSION_zTXt 2 420 #define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */ 421 422 423 typedef struct png_time_struct 424 { 425 png_uint_16 year; 426 png_byte month; 427 png_byte day; 428 png_byte hour; 429 png_byte minute; 430 png_byte second; 431 } png_time; 432 typedef png_time FAR * png_timep; 433 typedef png_time FAR * FAR * png_timepp; 434 435 436 #define PNG_CHUNK_NAME_LENGTH 5 437 typedef struct png_unknown_chunk_t 438 { 439 png_byte name[PNG_CHUNK_NAME_LENGTH]; 440 png_byte *data; 441 png_size_t size; 442 443 png_byte location; 444 } 445 png_unknown_chunk; 446 typedef png_unknown_chunk FAR * png_unknown_chunkp; 447 typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp; 448 449 450 typedef struct png_info_struct 451 { 452 png_uint_32 width; 453 png_uint_32 height; 454 png_uint_32 valid; 455 png_uint_32 rowbytes; 456 png_colorp palette; 457 png_uint_16 num_palette; 458 png_uint_16 num_trans; 459 png_byte bit_depth; 460 png_byte color_type; 461 462 png_byte compression_type; 463 png_byte filter_type; 464 png_byte interlace_type; 465 466 png_byte channels; 467 png_byte pixel_depth; 468 png_byte spare_byte; 469 png_byte signature[8]; 470 471 float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */ 472 473 png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */ 474 475 int num_text; /* number of comments read/to write */ 476 int max_text; /* current size of text array */ 477 png_textp text; /* array of comments read/to write */ 478 479 png_time mod_time; 480 481 png_color_8 sig_bit; /* significant bits in color channels */ 482 483 png_bytep trans; /* transparent values for paletted image */ 484 png_color_16 trans_values; /* transparent color for non-palette image */ 485 486 png_color_16 background; 487 488 png_int_32 x_offset; /* x offset on page */ 489 png_int_32 y_offset; /* y offset on page */ 490 png_byte offset_unit_type; /* offset units type */ 491 492 png_uint_32 x_pixels_per_unit; /* horizontal pixel density */ 493 png_uint_32 y_pixels_per_unit; /* vertical pixel density */ 494 png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */ 495 496 png_uint_16p hist; 497 498 float x_white; 499 float y_white; 500 float x_red; 501 float y_red; 502 float x_green; 503 float y_green; 504 float x_blue; 505 float y_blue; 506 507 png_charp pcal_purpose; /* pCAL chunk description string */ 508 png_int_32 pcal_X0; /* minimum value */ 509 png_int_32 pcal_X1; /* maximum value */ 510 png_charp pcal_units; /* Latin-1 string giving physical units */ 511 png_charpp pcal_params; /* ASCII strings containing parameter values */ 512 png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */ 513 png_byte pcal_nparams; /* number of parameters given in pcal_params */ 514 515 png_uint_32 free_me; /* flags items libpng is responsible for freeing */ 516 517 png_unknown_chunkp unknown_chunks; 518 png_size_t unknown_chunks_num; 519 520 png_charp iccp_name; /* profile name */ 521 png_charp iccp_profile; /* International Color Consortium profile data */ 522 /* Note to maintainer: should be png_bytep */ 523 png_uint_32 iccp_proflen; /* ICC profile data length */ 524 png_byte iccp_compression; /* Always zero */ 525 526 png_sPLT_tp splt_palettes; 527 png_uint_32 splt_palettes_num; 528 529 png_byte scal_unit; /* unit of physical scale */ 530 531 double scal_pixel_width; /* width of one pixel */ 532 double scal_pixel_height; /* height of one pixel */ 533 534 png_charp scal_s_width; /* string containing height */ 535 png_charp scal_s_height; /* string containing width */ 536 537 png_bytepp row_pointers; /* the image bits */ 538 539 png_fixed_point int_gamma; /* gamma of image, if (valid & PNG_INFO_gAMA) */ 540 541 png_fixed_point int_x_white; 542 png_fixed_point int_y_white; 543 png_fixed_point int_x_red; 544 png_fixed_point int_y_red; 545 png_fixed_point int_x_green; 546 png_fixed_point int_y_green; 547 png_fixed_point int_x_blue; 548 png_fixed_point int_y_blue; 549 550 } png_info; 551 552 typedef png_info FAR * png_infop; 553 typedef png_info FAR * FAR * png_infopp; 554 555 #define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL) 556 #define PNG_UINT_32_MAX ((png_uint_32)(-1)) 557 #define PNG_SIZE_MAX ((png_size_t)(-1)) 558 /* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */ 559 #define PNG_MAX_UINT PNG_UINT_31_MAX 560 561 #define PNG_COLOR_MASK_PALETTE 1 562 #define PNG_COLOR_MASK_COLOR 2 563 #define PNG_COLOR_MASK_ALPHA 4 564 565 #define PNG_COLOR_TYPE_GRAY 0 566 #define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE) 567 #define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR) 568 #define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA) 569 #define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA) 570 571 #define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA 572 #define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA 573 574 575 #define PNG_COMPRESSION_TYPE_BASE 0 576 #define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE 577 578 #define PNG_FILTER_TYPE_BASE 0 579 #define PNG_INTRAPIXEL_DIFFERENCING 64 580 #define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE 581 582 #define PNG_INTERLACE_NONE 0 583 #define PNG_INTERLACE_ADAM7 1 584 #define PNG_INTERLACE_LAST 2 585 586 #define PNG_OFFSET_PIXEL 0 587 #define PNG_OFFSET_MICROMETER 1 588 #define PNG_OFFSET_LAST 2 589 590 #define PNG_EQUATION_LINEAR 0 591 #define PNG_EQUATION_BASE_E 1 592 #define PNG_EQUATION_ARBITRARY 2 593 #define PNG_EQUATION_HYPERBOLIC 3 594 #define PNG_EQUATION_LAST 4 595 596 #define PNG_SCALE_UNKNOWN 0 597 #define PNG_SCALE_METER 1 598 #define PNG_SCALE_RADIAN 2 599 #define PNG_SCALE_LAST 3 600 601 602 #define PNG_RESOLUTION_UNKNOWN 0 603 #define PNG_RESOLUTION_METER 1 604 #define PNG_RESOLUTION_LAST 2 605 606 #define PNG_sRGB_INTENT_PERCEPTUAL 0 607 #define PNG_sRGB_INTENT_RELATIVE 1 608 #define PNG_sRGB_INTENT_SATURATION 2 609 #define PNG_sRGB_INTENT_ABSOLUTE 3 610 #define PNG_sRGB_INTENT_LAST 4 611 612 #define PNG_KEYWORD_MAX_LENGTH 79 613 614 #define PNG_MAX_PALETTE_LENGTH 256 615 616 #define PNG_INFO_gAMA 0x0001 617 #define PNG_INFO_sBIT 0x0002 618 #define PNG_INFO_cHRM 0x0004 619 #define PNG_INFO_PLTE 0x0008 620 #define PNG_INFO_tRNS 0x0010 621 #define PNG_INFO_bKGD 0x0020 622 #define PNG_INFO_hIST 0x0040 623 #define PNG_INFO_pHYs 0x0080 624 #define PNG_INFO_oFFs 0x0100 625 #define PNG_INFO_tIME 0x0200 626 #define PNG_INFO_pCAL 0x0400 627 #define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ 628 #define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ 629 #define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ 630 #define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ 631 #define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */ 632 633 634 typedef struct png_row_info_struct 635 { 636 png_uint_32 width; 637 png_uint_32 rowbytes; 638 png_byte color_type; 639 png_byte bit_depth; 640 png_byte channels; 641 png_byte pixel_depth; 642 } png_row_info; 643 644 typedef png_row_info FAR * png_row_infop; 645 typedef png_row_info FAR * FAR * png_row_infopp; 646 647 648 typedef struct png_struct_def png_struct; 649 typedef png_struct FAR * png_structp; 650 651 typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp)); 652 typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); 653 typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp)); 654 typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32, int)); 655 typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32, int)); 656 657 typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop)); 658 typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop)); 659 typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep, png_uint_32, int)); 660 661 typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp, png_row_infop, png_bytep)); 662 663 typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp)); 664 typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); 665 666 #define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ 667 #define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ 668 #define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ 669 #define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ 670 #define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ 671 #define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ 672 #define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ 673 #define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ 674 #define PNG_TRANSFORM_BGR 0x0080 /* read and write */ 675 #define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ 676 #define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ 677 #define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ 678 #define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only, deprecated */ 679 #define PNG_TRANSFORM_STRIP_FILLER_BEFORE 0x0800 /* write only */ 680 #define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */ 681 #define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */ 682 683 #define PNG_FLAG_MNG_EMPTY_PLTE 0x01 684 #define PNG_FLAG_MNG_FILTER_64 0x04 685 #define PNG_ALL_MNG_FEATURES 0x05 686 687 typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); 688 typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); 689 690 struct png_struct_def 691 { 692 int jmpbuf59[59]; /* used in png_error */ 693 694 png_error_ptr error_fn; /* function for printing errors and aborting */ 695 png_error_ptr warning_fn; /* function for printing warnings */ 696 png_voidp error_ptr; /* user supplied struct for error functions */ 697 png_rw_ptr write_data_fn; /* function for writing output data */ 698 png_rw_ptr read_data_fn; /* function for reading input data */ 699 png_voidp io_ptr; /* ptr to application struct for I/O functions */ 700 701 png_user_transform_ptr read_user_transform_fn; /* user read transform */ 702 703 png_user_transform_ptr write_user_transform_fn; /* user write transform */ 704 705 png_voidp user_transform_ptr; /* user supplied struct for user transform */ 706 png_byte user_transform_depth; /* bit depth of user transformed pixels */ 707 png_byte user_transform_channels; /* channels in user transformed pixels */ 708 709 png_uint_32 mode; /* tells us where we are in the PNG file */ 710 png_uint_32 flags; /* flags indicating various things to libpng */ 711 png_uint_32 transformations; /* which transformations to perform */ 712 713 z_stream zstream; /* pointer to decompression structure (below) */ 714 png_bytep zbuf; /* buffer for zlib */ 715 png_size_t zbuf_size; /* size of zbuf */ 716 int zlib_level; /* holds zlib compression level */ 717 int zlib_method; /* holds zlib compression method */ 718 int zlib_window_bits; /* holds zlib compression window bits */ 719 int zlib_mem_level; /* holds zlib compression memory level */ 720 int zlib_strategy; /* holds zlib compression strategy */ 721 722 png_uint_32 width; /* width of image in pixels */ 723 png_uint_32 height; /* height of image in pixels */ 724 png_uint_32 num_rows; /* number of rows in current pass */ 725 png_uint_32 usr_width; /* width of row at start of write */ 726 png_uint_32 rowbytes; /* size of row in bytes */ 727 png_uint_32 irowbytes; /* size of current interlaced row in bytes */ 728 png_uint_32 iwidth; /* width of current interlaced row in pixels */ 729 png_uint_32 row_number; /* current row in interlace pass */ 730 png_bytep prev_row; /* buffer to save previous (unfiltered) row */ 731 png_bytep row_buf; /* buffer to save current (unfiltered) row */ 732 png_bytep sub_row; /* buffer to save "sub" row when filtering */ 733 png_bytep up_row; /* buffer to save "up" row when filtering */ 734 png_bytep avg_row; /* buffer to save "avg" row when filtering */ 735 png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ 736 png_row_info row_info; /* used for transformation routines */ 737 738 png_uint_32 idat_size; /* current IDAT size for read */ 739 png_uint_32 crc; /* current chunk CRC value */ 740 png_colorp palette; /* palette from the input file */ 741 png_uint_16 num_palette; /* number of color entries in palette */ 742 png_uint_16 num_trans; /* number of transparency values */ 743 png_byte chunk_name[5]; /* null-terminated name of current chunk */ 744 png_byte compression; /* file compression type (always 0) */ 745 png_byte filter; /* file filter type (always 0) */ 746 png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ 747 png_byte pass; /* current interlace pass (0 - 6) */ 748 png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ 749 png_byte color_type; /* color type of file */ 750 png_byte bit_depth; /* bit depth of file */ 751 png_byte usr_bit_depth; /* bit depth of users row */ 752 png_byte pixel_depth; /* number of bits per pixel */ 753 png_byte channels; /* number of channels in file */ 754 png_byte usr_channels; /* channels at start of write */ 755 png_byte sig_bytes; /* magic bytes read/written from start of file */ 756 757 png_uint_16 filler; /* filler bytes for pixel expansion */ 758 759 png_byte background_gamma_type; 760 761 float background_gamma; 762 763 png_color_16 background; /* background color in screen gamma space */ 764 765 png_color_16 background_1; /* background normalized to gamma 1.0 */ 766 767 png_flush_ptr output_flush_fn;/* Function for flushing output */ 768 png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ 769 png_uint_32 flush_rows; /* number of rows written since last flush */ 770 771 int gamma_shift; /* number of "insignificant" bits 16-bit gamma */ 772 773 float gamma; /* file gamma value */ 774 float screen_gamma; /* screen gamma value (display_exponent) */ 775 776 777 png_bytep gamma_table; /* gamma table for 8-bit depth files */ 778 png_bytep gamma_from_1; /* converts from 1.0 to screen */ 779 png_bytep gamma_to_1; /* converts from file to 1.0 */ 780 png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ 781 png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ 782 png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ 783 784 png_color_8 sig_bit; /* significant bits in each available channel */ 785 786 png_color_8 shift; /* shift for significant bit tranformation */ 787 788 png_bytep trans; /* transparency values for paletted files */ 789 png_color_16 trans_values; /* transparency values for non-paletted files */ 790 791 png_read_status_ptr read_row_fn; /* called after each row is decoded */ 792 png_write_status_ptr write_row_fn; /* called after each row is encoded */ 793 794 png_progressive_info_ptr info_fn; /* called after header data fully read */ 795 png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */ 796 png_progressive_end_ptr end_fn; /* called after image is complete */ 797 png_bytep save_buffer_ptr; /* current location in save_buffer */ 798 png_bytep save_buffer; /* buffer for previously read data */ 799 png_bytep current_buffer_ptr; /* current location in current_buffer */ 800 png_bytep current_buffer; /* buffer for recently used data */ 801 png_uint_32 push_length; /* size of current input chunk */ 802 png_uint_32 skip_length; /* bytes to skip in input data */ 803 png_size_t save_buffer_size; /* amount of data now in save_buffer */ 804 png_size_t save_buffer_max; /* total size of save_buffer */ 805 png_size_t buffer_size; /* total amount of available input data */ 806 png_size_t current_buffer_size; /* amount of data now in current_buffer */ 807 int process_mode; /* what push library is currently doing */ 808 int cur_palette; /* current push library palette index */ 809 810 811 png_size_t current_text_size; /* current size of text input data */ 812 png_size_t current_text_left; /* how much text left to read in input */ 813 png_charp current_text; /* current text chunk buffer */ 814 png_charp current_text_ptr; /* current location in current_text */ 815 816 817 png_bytep palette_lookup; /* lookup table for dithering */ 818 png_bytep dither_index; /* index translation for palette files */ 819 820 png_uint_16p hist; /* histogram */ 821 822 png_charp time_buffer; /* String to hold RFC 1123 time text */ 823 824 png_uint_32 free_me; /* flags items libpng is responsible for freeing */ 825 826 png_voidp user_chunk_ptr; 827 png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ 828 829 int num_chunk_list; 830 png_bytep chunk_list; 831 832 png_byte rgb_to_gray_status; 833 834 png_uint_16 rgb_to_gray_red_coeff; 835 png_uint_16 rgb_to_gray_green_coeff; 836 png_uint_16 rgb_to_gray_blue_coeff; 837 838 png_uint_32 mng_features_permitted; 839 840 png_fixed_point int_gamma; 841 842 png_byte filter_type; 843 844 png_voidp mem_ptr; /* user supplied struct for mem functions */ 845 png_malloc_ptr malloc_fn; /* function for allocating memory */ 846 png_free_ptr free_fn; /* function for freeing memory */ 847 848 png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ 849 850 851 png_bytep dither_sort; /* working sort array */ 852 png_bytep index_to_palette; /* where the original index currently is */ 853 /* in the palette */ 854 png_bytep palette_to_index; /* which original index points to this */ 855 /* palette color */ 856 857 png_byte compression_type; 858 859 png_uint_32 user_width_max; 860 png_uint_32 user_height_max; 861 862 png_unknown_chunk unknown_chunk; /* storage for unknown chunk that the library doesn't recognize. */ 863 864 png_uint_32 old_big_row_buf_size, old_prev_row_size; /* New members added in libpng-1.2.26 */ 865 866 png_charp chunkdata; /* buffer for reading chunk data */ 867 }; 868 869 870 /* This triggers a compiler error in png.c, if png.c and png.h 871 * do not agree upon the version number. 872 */ 873 typedef png_structp version_1_2_59; 874 875 typedef png_struct FAR * FAR * png_structpp; 876 877 878 #define PNG_FILLER_BEFORE 0 879 #define PNG_FILLER_AFTER 1 880 881 #define PNG_BACKGROUND_GAMMA_UNKNOWN 0 882 #define PNG_BACKGROUND_GAMMA_SCREEN 1 883 #define PNG_BACKGROUND_GAMMA_FILE 2 884 #define PNG_BACKGROUND_GAMMA_UNIQUE 3 885 886 887 #define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ 888 #define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ 889 #define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ 890 #define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ 891 #define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ 892 #define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ 893 894 895 #define PNG_NO_FILTERS 0x00 896 #define PNG_FILTER_NONE 0x08 897 #define PNG_FILTER_SUB 0x10 898 #define PNG_FILTER_UP 0x20 899 #define PNG_FILTER_AVG 0x40 900 #define PNG_FILTER_PAETH 0x80 901 #define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | PNG_FILTER_AVG | PNG_FILTER_PAETH) 902 903 904 #define PNG_FILTER_VALUE_NONE 0 905 #define PNG_FILTER_VALUE_SUB 1 906 #define PNG_FILTER_VALUE_UP 2 907 #define PNG_FILTER_VALUE_AVG 3 908 #define PNG_FILTER_VALUE_PAETH 4 909 #define PNG_FILTER_VALUE_LAST 5 910 911 #define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ 912 #define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ 913 #define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ 914 #define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ 915 916 917 #define PNG_DESTROY_WILL_FREE_DATA 1 918 #define PNG_SET_WILL_FREE_DATA 1 919 #define PNG_USER_WILL_FREE_DATA 2 920 /* Flags for png_ptr->free_me and info_ptr->free_me */ 921 #define PNG_FREE_HIST 0x0008 922 #define PNG_FREE_ICCP 0x0010 923 #define PNG_FREE_SPLT 0x0020 924 #define PNG_FREE_ROWS 0x0040 925 #define PNG_FREE_PCAL 0x0080 926 #define PNG_FREE_SCAL 0x0100 927 #define PNG_FREE_UNKN 0x0200 928 #define PNG_FREE_LIST 0x0400 929 #define PNG_FREE_PLTE 0x1000 930 #define PNG_FREE_TRNS 0x2000 931 #define PNG_FREE_TEXT 0x4000 932 #define PNG_FREE_ALL 0x7fff 933 #define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ 934 935 /* For use in png_set_keep_unknown, added to version 1.2.6 */ 936 #define PNG_HANDLE_CHUNK_AS_DEFAULT 0 937 #define PNG_HANDLE_CHUNK_NEVER 1 938 #define PNG_HANDLE_CHUNK_IF_SAFE 2 939 #define PNG_HANDLE_CHUNK_ALWAYS 3 940 941 /* Added at libpng-1.2.34 and 1.4.0 */ 942 #ifndef PNG_STRING_NEWLINE 943 #define PNG_STRING_NEWLINE "\n" 944 #endif 945 946 947 #if defined(__GNUC__) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) 948 static inline void png_convert_from_time_t(png_timep ptime, long long ttime) 949 { 950 void png_convert_from_time_t32(png_timep ptime, long ttime); 951 void png_convert_from_time_t64(png_timep ptime, long long ttime); 952 extern struct Library *PNGBase; 953 if (PNGBase->lib_Version >= 52) 954 png_convert_from_time_t64(ptime, ttime); 955 else 956 png_convert_from_time_t32(ptime, (long) ttime); 957 } 958 #else 959 #define png_convert_from_time_t(p,t) \ 960 do { \ 961 png_timep ptime_tmp_ = (p); \ 962 long long ttime_tmp_ = (t); \ 963 if (PNGBase->lib_Version >= 52) \ 964 png_convert_from_time_t64(ptime_tmp_, ttime_tmp_); \ 965 else \ 966 png_convert_from_time_t32(ptime_tmp_, (long) ttime_tmp_); \ 967 } while (0) 968 #endif 969 970 #ifdef __cplusplus 971 } 972 #endif 973 974 #endif /* PNG_VERSION_INFO_ONLY */ 975 976 #endif /* LIBRARIES_PNG_H */