Changeset 846 for trunk/src/3rdparty/libpng/pngget.c
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/3rdparty/libpng/pngget.c
r561 r846 2 2 /* pngget.c - retrieval of values from info struct 3 3 * 4 * Last changed in libpng 1. 2.37 [June 4, 2009]5 * Copyright (c) 1998-20 09Glenn Randers-Pehrson4 * Last changed in libpng 1.4.0 [January 3, 2010] 5 * Copyright (c) 1998-2010 Glenn Randers-Pehrson 6 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) … … 13 13 */ 14 14 15 #define PNG_ INTERNAL15 #define PNG_NO_PEDANTIC_WARNINGS 16 16 #include "png.h" 17 17 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 18 #include "pngpriv.h" 18 19 19 20 png_uint_32 PNGAPI … … 27 28 } 28 29 29 png_ uint_32PNGAPI30 png_size_t PNGAPI 30 31 png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) 31 32 { … … 37 38 } 38 39 39 #if defined(PNG_INFO_IMAGE_SUPPORTED)40 #ifdef PNG_INFO_IMAGE_SUPPORTED 40 41 png_bytepp PNGAPI 41 42 png_get_rows(png_structp png_ptr, png_infop info_ptr) … … 118 119 { 119 120 if (png_ptr != NULL && info_ptr != NULL) 120 #if defined(PNG_pHYs_SUPPORTED)121 #ifdef PNG_pHYs_SUPPORTED 121 122 if (info_ptr->valid & PNG_INFO_pHYs) 122 123 { … … 139 140 { 140 141 if (png_ptr != NULL && info_ptr != NULL) 141 #if defined(PNG_pHYs_SUPPORTED)142 #ifdef PNG_pHYs_SUPPORTED 142 143 if (info_ptr->valid & PNG_INFO_pHYs) 143 144 { … … 160 161 { 161 162 if (png_ptr != NULL && info_ptr != NULL) 162 #if defined(PNG_pHYs_SUPPORTED)163 #ifdef PNG_pHYs_SUPPORTED 163 164 if (info_ptr->valid & PNG_INFO_pHYs) 164 165 { … … 183 184 { 184 185 if (png_ptr != NULL && info_ptr != NULL) 185 #if defined(PNG_pHYs_SUPPORTED)186 #ifdef PNG_pHYs_SUPPORTED 186 187 187 188 if (info_ptr->valid & PNG_INFO_pHYs) 188 189 { 189 190 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); 191 190 192 if (info_ptr->x_pixels_per_unit == 0) 191 193 return ((float)0.0); 194 192 195 else 193 196 return ((float)((float)info_ptr->y_pixels_per_unit … … 205 208 { 206 209 if (png_ptr != NULL && info_ptr != NULL) 207 #if defined(PNG_oFFs_SUPPORTED)210 #ifdef PNG_oFFs_SUPPORTED 208 211 209 212 if (info_ptr->valid & PNG_INFO_oFFs) … … 228 231 if (png_ptr != NULL && info_ptr != NULL) 229 232 230 #if defined(PNG_oFFs_SUPPORTED)233 #ifdef PNG_oFFs_SUPPORTED 231 234 if (info_ptr->valid & PNG_INFO_oFFs) 232 235 { … … 250 253 if (png_ptr != NULL && info_ptr != NULL) 251 254 252 #if defined(PNG_oFFs_SUPPORTED)255 #ifdef PNG_oFFs_SUPPORTED 253 256 if (info_ptr->valid & PNG_INFO_oFFs) 254 257 { … … 272 275 if (png_ptr != NULL && info_ptr != NULL) 273 276 274 #if defined(PNG_oFFs_SUPPORTED)277 #ifdef PNG_oFFs_SUPPORTED 275 278 if (info_ptr->valid & PNG_INFO_oFFs) 276 279 { … … 325 328 } 326 329 327 #if defined(PNG_pHYs_SUPPORTED)330 #ifdef PNG_pHYs_SUPPORTED 328 331 png_uint_32 PNGAPI 329 332 png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, … … 335 338 { 336 339 png_debug1(1, "in %s retrieval function", "pHYs"); 340 337 341 if (res_x != NULL) 338 342 { … … 383 387 } 384 388 385 #if defined(PNG_bKGD_SUPPORTED)389 #ifdef PNG_bKGD_SUPPORTED 386 390 png_uint_32 PNGAPI 387 391 png_get_bKGD(png_structp png_ptr, png_infop info_ptr, … … 392 396 { 393 397 png_debug1(1, "in %s retrieval function", "bKGD"); 398 394 399 *background = &(info_ptr->background); 395 400 return (PNG_INFO_bKGD); … … 399 404 #endif 400 405 401 #if defined(PNG_cHRM_SUPPORTED)406 #ifdef PNG_cHRM_SUPPORTED 402 407 #ifdef PNG_FLOATING_POINT_SUPPORTED 403 408 png_uint_32 PNGAPI … … 409 414 { 410 415 png_debug1(1, "in %s retrieval function", "cHRM"); 416 411 417 if (white_x != NULL) 412 418 *white_x = (double)info_ptr->x_white; … … 437 443 png_fixed_point *blue_x, png_fixed_point *blue_y) 438 444 { 445 png_debug1(1, "in %s retrieval function", "cHRM"); 446 439 447 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) 440 448 { 441 png_debug1(1, "in %s retrieval function", "cHRM");442 449 if (white_x != NULL) 443 450 *white_x = info_ptr->int_x_white; … … 463 470 #endif 464 471 465 #if defined(PNG_gAMA_SUPPORTED)472 #ifdef PNG_gAMA_SUPPORTED 466 473 #ifdef PNG_FLOATING_POINT_SUPPORTED 467 474 png_uint_32 PNGAPI 468 475 png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) 469 476 { 477 png_debug1(1, "in %s retrieval function", "gAMA"); 478 470 479 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) 471 480 && file_gamma != NULL) 472 481 { 473 png_debug1(1, "in %s retrieval function", "gAMA");474 482 *file_gamma = (double)info_ptr->gamma; 475 483 return (PNG_INFO_gAMA); … … 483 491 png_fixed_point *int_file_gamma) 484 492 { 493 png_debug1(1, "in %s retrieval function", "gAMA"); 494 485 495 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) 486 496 && int_file_gamma != NULL) 487 497 { 488 png_debug1(1, "in %s retrieval function", "gAMA");489 498 *int_file_gamma = info_ptr->int_gamma; 490 499 return (PNG_INFO_gAMA); … … 495 504 #endif 496 505 497 #if defined(PNG_sRGB_SUPPORTED)506 #ifdef PNG_sRGB_SUPPORTED 498 507 png_uint_32 PNGAPI 499 508 png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) 500 509 { 510 png_debug1(1, "in %s retrieval function", "sRGB"); 511 501 512 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) 502 513 && file_srgb_intent != NULL) 503 514 { 504 png_debug1(1, "in %s retrieval function", "sRGB");505 515 *file_srgb_intent = (int)info_ptr->srgb_intent; 506 516 return (PNG_INFO_sRGB); … … 510 520 #endif 511 521 512 #if defined(PNG_iCCP_SUPPORTED)522 #ifdef PNG_iCCP_SUPPORTED 513 523 png_uint_32 PNGAPI 514 524 png_get_iCCP(png_structp png_ptr, png_infop info_ptr, … … 516 526 png_charpp profile, png_uint_32 *proflen) 517 527 { 528 png_debug1(1, "in %s retrieval function", "iCCP"); 529 518 530 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) 519 531 && name != NULL && profile != NULL && proflen != NULL) 520 532 { 521 png_debug1(1, "in %s retrieval function", "iCCP");522 533 *name = info_ptr->iccp_name; 523 534 *profile = info_ptr->iccp_profile; … … 533 544 #endif 534 545 535 #if defined(PNG_sPLT_SUPPORTED)546 #ifdef PNG_sPLT_SUPPORTED 536 547 png_uint_32 PNGAPI 537 548 png_get_sPLT(png_structp png_ptr, png_infop info_ptr, … … 547 558 #endif 548 559 549 #if defined(PNG_hIST_SUPPORTED)560 #ifdef PNG_hIST_SUPPORTED 550 561 png_uint_32 PNGAPI 551 562 png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) 552 563 { 564 png_debug1(1, "in %s retrieval function", "hIST"); 565 553 566 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) 554 567 && hist != NULL) 555 568 { 556 png_debug1(1, "in %s retrieval function", "hIST");557 569 *hist = info_ptr->hist; 558 570 return (PNG_INFO_hIST); … … 569 581 570 582 { 571 if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && 572 bit_depth != NULL && color_type != NULL) 573 { 574 png_debug1(1, "in %s retrieval function", "IHDR"); 575 *width = info_ptr->width; 576 *height = info_ptr->height; 577 *bit_depth = info_ptr->bit_depth; 578 if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16) 579 png_error(png_ptr, "Invalid bit depth"); 580 581 *color_type = info_ptr->color_type; 582 583 if (info_ptr->color_type > 6) 584 png_error(png_ptr, "Invalid color type"); 585 586 if (compression_type != NULL) 587 *compression_type = info_ptr->compression_type; 588 589 if (filter_type != NULL) 590 *filter_type = info_ptr->filter_type; 591 592 if (interlace_type != NULL) 593 *interlace_type = info_ptr->interlace_type; 594 595 /* Check for potential overflow of rowbytes */ 596 if (*width == 0 || *width > PNG_UINT_31_MAX) 597 png_error(png_ptr, "Invalid image width"); 598 599 if (*height == 0 || *height > PNG_UINT_31_MAX) 600 png_error(png_ptr, "Invalid image height"); 601 602 if (info_ptr->width > (PNG_UINT_32_MAX 603 >> 3) /* 8-byte RGBA pixels */ 604 - 64 /* bigrowbuf hack */ 605 - 1 /* filter byte */ 606 - 7*8 /* rounding of width to multiple of 8 pixels */ 607 - 8) /* extra max_pixel_depth pad */ 608 { 609 png_warning(png_ptr, 610 "Width too large for libpng to process image data."); 611 } 612 613 return (1); 614 } 615 return (0); 616 } 617 618 #if defined(PNG_oFFs_SUPPORTED) 583 png_debug1(1, "in %s retrieval function", "IHDR"); 584 585 if (png_ptr == NULL || info_ptr == NULL || width == NULL || 586 height == NULL || bit_depth == NULL || color_type == NULL) 587 return (0); 588 589 *width = info_ptr->width; 590 *height = info_ptr->height; 591 *bit_depth = info_ptr->bit_depth; 592 *color_type = info_ptr->color_type; 593 594 if (compression_type != NULL) 595 *compression_type = info_ptr->compression_type; 596 597 if (filter_type != NULL) 598 *filter_type = info_ptr->filter_type; 599 600 if (interlace_type != NULL) 601 *interlace_type = info_ptr->interlace_type; 602 603 /* This is redundant if we can be sure that the info_ptr values were all 604 * assigned in png_set_IHDR(). We do the check anyhow in case an 605 * application has ignored our advice not to mess with the members 606 * of info_ptr directly. 607 */ 608 png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height, 609 info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, 610 info_ptr->compression_type, info_ptr->filter_type); 611 612 return (1); 613 } 614 615 #ifdef PNG_oFFs_SUPPORTED 619 616 png_uint_32 PNGAPI 620 617 png_get_oFFs(png_structp png_ptr, png_infop info_ptr, 621 618 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) 622 619 { 620 png_debug1(1, "in %s retrieval function", "oFFs"); 621 623 622 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) 624 623 && offset_x != NULL && offset_y != NULL && unit_type != NULL) 625 624 { 626 png_debug1(1, "in %s retrieval function", "oFFs");627 625 *offset_x = info_ptr->x_offset; 628 626 *offset_y = info_ptr->y_offset; … … 634 632 #endif 635 633 636 #if defined(PNG_pCAL_SUPPORTED)634 #ifdef PNG_pCAL_SUPPORTED 637 635 png_uint_32 PNGAPI 638 636 png_get_pCAL(png_structp png_ptr, png_infop info_ptr, … … 640 638 png_charp *units, png_charpp *params) 641 639 { 640 png_debug1(1, "in %s retrieval function", "pCAL"); 641 642 642 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) 643 643 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && 644 644 nparams != NULL && units != NULL && params != NULL) 645 645 { 646 png_debug1(1, "in %s retrieval function", "pCAL");647 646 *purpose = info_ptr->pcal_purpose; 648 647 *X0 = info_ptr->pcal_X0; … … 658 657 #endif 659 658 660 #if defined(PNG_sCAL_SUPPORTED)659 #ifdef PNG_sCAL_SUPPORTED 661 660 #ifdef PNG_FLOATING_POINT_SUPPORTED 662 661 png_uint_32 PNGAPI … … 694 693 #endif 695 694 696 #if defined(PNG_pHYs_SUPPORTED)695 #ifdef PNG_pHYs_SUPPORTED 697 696 png_uint_32 PNGAPI 698 697 png_get_pHYs(png_structp png_ptr, png_infop info_ptr, … … 701 700 png_uint_32 retval = 0; 702 701 702 png_debug1(1, "in %s retrieval function", "pHYs"); 703 703 704 if (png_ptr != NULL && info_ptr != NULL && 704 705 (info_ptr->valid & PNG_INFO_pHYs)) 705 706 { 706 png_debug1(1, "in %s retrieval function", "pHYs");707 708 707 if (res_x != NULL) 709 708 { … … 732 731 int *num_palette) 733 732 { 733 png_debug1(1, "in %s retrieval function", "PLTE"); 734 734 735 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) 735 736 && palette != NULL) 736 737 { 737 png_debug1(1, "in %s retrieval function", "PLTE");738 738 *palette = info_ptr->palette; 739 739 *num_palette = info_ptr->num_palette; … … 744 744 } 745 745 746 #if defined(PNG_sBIT_SUPPORTED)746 #ifdef PNG_sBIT_SUPPORTED 747 747 png_uint_32 PNGAPI 748 748 png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) 749 749 { 750 png_debug1(1, "in %s retrieval function", "sBIT"); 751 750 752 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) 751 753 && sig_bit != NULL) 752 754 { 753 png_debug1(1, "in %s retrieval function", "sBIT");754 755 *sig_bit = &(info_ptr->sig_bit); 755 756 return (PNG_INFO_sBIT); … … 759 760 #endif 760 761 761 #if defined(PNG_TEXT_SUPPORTED)762 #ifdef PNG_TEXT_SUPPORTED 762 763 png_uint_32 PNGAPI 763 764 png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, … … 784 785 #endif 785 786 786 #if defined(PNG_tIME_SUPPORTED)787 #ifdef PNG_tIME_SUPPORTED 787 788 png_uint_32 PNGAPI 788 789 png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) 789 790 { 791 png_debug1(1, "in %s retrieval function", "tIME"); 792 790 793 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) 791 794 && mod_time != NULL) 792 795 { 793 png_debug1(1, "in %s retrieval function", "tIME");794 796 *mod_time = &(info_ptr->mod_time); 795 797 return (PNG_INFO_tIME); … … 799 801 #endif 800 802 801 #if defined(PNG_tRNS_SUPPORTED)803 #ifdef PNG_tRNS_SUPPORTED 802 804 png_uint_32 PNGAPI 803 805 png_get_tRNS(png_structp png_ptr, png_infop info_ptr, 804 png_bytep *trans , int *num_trans, png_color_16p *trans_values)806 png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color) 805 807 { 806 808 png_uint_32 retval = 0; … … 808 810 { 809 811 png_debug1(1, "in %s retrieval function", "tRNS"); 812 810 813 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) 811 814 { 812 if (trans != NULL)815 if (trans_alpha != NULL) 813 816 { 814 *trans = info_ptr->trans;817 *trans_alpha = info_ptr->trans_alpha; 815 818 retval |= PNG_INFO_tRNS; 816 819 } 817 820 818 if (trans_ values!= NULL)819 *trans_ values = &(info_ptr->trans_values);821 if (trans_color != NULL) 822 *trans_color = &(info_ptr->trans_color); 820 823 } 821 824 else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ 822 825 { 823 if (trans_ values!= NULL)826 if (trans_color != NULL) 824 827 { 825 *trans_ values = &(info_ptr->trans_values);828 *trans_color = &(info_ptr->trans_color); 826 829 retval |= PNG_INFO_tRNS; 827 830 } 828 831 829 if (trans != NULL)830 *trans = NULL;832 if (trans_alpha != NULL) 833 *trans_alpha = NULL; 831 834 } 832 835 if (num_trans != NULL) … … 840 843 #endif 841 844 842 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)845 #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED 843 846 png_uint_32 PNGAPI 844 847 png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, … … 854 857 #endif 855 858 856 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)859 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED 857 860 png_byte PNGAPI 858 861 png_get_rgb_to_gray_status (png_structp png_ptr) … … 862 865 #endif 863 866 864 #if defined(PNG_USER_CHUNKS_SUPPORTED)867 #ifdef PNG_USER_CHUNKS_SUPPORTED 865 868 png_voidp PNGAPI 866 869 png_get_user_chunk_ptr(png_structp png_ptr) … … 871 874 872 875 #ifdef PNG_WRITE_SUPPORTED 873 png_ uint_32PNGAPI876 png_size_t PNGAPI 874 877 png_get_compression_buffer_size(png_structp png_ptr) 875 878 { 876 return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L); 877 } 878 #endif 879 880 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED 881 #ifndef PNG_1_0_X 882 /* This function was added to libpng 1.2.0 and should exist by default */ 883 png_uint_32 PNGAPI 884 png_get_asm_flags (png_structp png_ptr) 885 { 886 /* Obsolete, to be removed from libpng-1.4.0 */ 887 return (png_ptr? 0L: 0L); 888 } 889 890 /* This function was added to libpng 1.2.0 and should exist by default */ 891 png_uint_32 PNGAPI 892 png_get_asm_flagmask (int flag_select) 893 { 894 /* Obsolete, to be removed from libpng-1.4.0 */ 895 flag_select=flag_select; 896 return 0L; 897 } 898 899 /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ 900 /* This function was added to libpng 1.2.0 */ 901 png_uint_32 PNGAPI 902 png_get_mmx_flagmask (int flag_select, int *compilerID) 903 { 904 /* Obsolete, to be removed from libpng-1.4.0 */ 905 flag_select=flag_select; 906 *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */ 907 return 0L; 908 } 909 910 /* This function was added to libpng 1.2.0 */ 911 png_byte PNGAPI 912 png_get_mmx_bitdepth_threshold (png_structp png_ptr) 913 { 914 /* Obsolete, to be removed from libpng-1.4.0 */ 915 return (png_ptr? 0: 0); 916 } 917 918 /* This function was added to libpng 1.2.0 */ 919 png_uint_32 PNGAPI 920 png_get_mmx_rowbytes_threshold (png_structp png_ptr) 921 { 922 /* Obsolete, to be removed from libpng-1.4.0 */ 923 return (png_ptr? 0L: 0L); 924 } 925 #endif /* ?PNG_1_0_X */ 926 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ 879 return (png_ptr ? png_ptr->zbuf_size : 0L); 880 } 881 #endif 882 927 883 928 884 #ifdef PNG_SET_USER_LIMITS_SUPPORTED … … 938 894 return (png_ptr? png_ptr->user_height_max : 0); 939 895 } 896 /* This function was added to libpng 1.4.0 */ 897 png_uint_32 PNGAPI 898 png_get_chunk_cache_max (png_structp png_ptr) 899 { 900 return (png_ptr? png_ptr->user_chunk_cache_max? 0x7fffffffL : 901 png_ptr->user_chunk_cache_max - 1 : 0); 902 } 940 903 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ 941 904 905 #ifdef PNG_IO_STATE_SUPPORTED 906 png_uint_32 PNGAPI 907 png_get_io_state (png_structp png_ptr) 908 { 909 return png_ptr->io_state; 910 } 911 912 png_bytep PNGAPI 913 png_get_io_chunk_name (png_structp png_ptr) 914 { 915 return png_ptr->chunk_name; 916 } 917 #endif /* ?PNG_IO_STATE_SUPPORTED */ 942 918 943 919 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
Note:
See TracChangeset
for help on using the changeset viewer.