Changeset 561 for trunk/src/3rdparty/libpng/pngget.c
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/3rdparty/libpng/pngget.c
r2 r561 2 2 /* pngget.c - retrieval of values from info struct 3 3 * 4 * Last changed in libpng 1.2.15 January 5, 2007 5 * For conditions of distribution and use, see copyright notice in png.h 6 * Copyright (c) 1998-2007 Glenn Randers-Pehrson 4 * Last changed in libpng 1.2.37 [June 4, 2009] 5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 8 * 9 * This code is released under the libpng license. 10 * For conditions of distribution and use, see the disclaimer 11 * and license in png.h 12 * 9 13 */ 10 14 11 15 #define PNG_INTERNAL 12 16 #include "png.h" 13 14 17 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 15 18 … … 19 22 if (png_ptr != NULL && info_ptr != NULL) 20 23 return(info_ptr->valid & flag); 24 21 25 else 22 26 return(0); … … 28 32 if (png_ptr != NULL && info_ptr != NULL) 29 33 return(info_ptr->rowbytes); 34 30 35 else 31 36 return(0); … … 38 43 if (png_ptr != NULL && info_ptr != NULL) 39 44 return(info_ptr->row_pointers); 45 40 46 else 41 47 return(0); … … 44 50 45 51 #ifdef PNG_EASY_ACCESS_SUPPORTED 46 /* easy access to info, added in libpng-0.99 */52 /* Easy access to info, added in libpng-0.99 */ 47 53 png_uint_32 PNGAPI 48 54 png_get_image_width(png_structp png_ptr, png_infop info_ptr) 49 55 { 50 56 if (png_ptr != NULL && info_ptr != NULL) 51 {52 57 return info_ptr->width; 53 } 58 54 59 return (0); 55 60 } … … 59 64 { 60 65 if (png_ptr != NULL && info_ptr != NULL) 61 {62 66 return info_ptr->height; 63 } 67 64 68 return (0); 65 69 } … … 69 73 { 70 74 if (png_ptr != NULL && info_ptr != NULL) 71 {72 75 return info_ptr->bit_depth; 73 } 76 74 77 return (0); 75 78 } … … 79 82 { 80 83 if (png_ptr != NULL && info_ptr != NULL) 81 {82 84 return info_ptr->color_type; 83 } 85 84 86 return (0); 85 87 } … … 89 91 { 90 92 if (png_ptr != NULL && info_ptr != NULL) 91 {92 93 return info_ptr->filter_type; 93 } 94 94 95 return (0); 95 96 } … … 99 100 { 100 101 if (png_ptr != NULL && info_ptr != NULL) 101 {102 102 return info_ptr->interlace_type; 103 } 103 104 104 return (0); 105 105 } … … 109 109 { 110 110 if (png_ptr != NULL && info_ptr != NULL) 111 {112 111 return info_ptr->compression_type; 113 } 112 114 113 return (0); 115 114 } … … 122 121 if (info_ptr->valid & PNG_INFO_pHYs) 123 122 { 124 png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter"); 125 if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) 123 png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter"); 124 125 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER) 126 126 return (0); 127 else return (info_ptr->x_pixels_per_unit); 127 128 else 129 return (info_ptr->x_pixels_per_unit); 128 130 } 129 131 #else … … 140 142 if (info_ptr->valid & PNG_INFO_pHYs) 141 143 { 142 png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter"); 143 if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) 144 png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter"); 145 146 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER) 144 147 return (0); 145 else return (info_ptr->y_pixels_per_unit); 148 149 else 150 return (info_ptr->y_pixels_per_unit); 146 151 } 147 152 #else … … 158 163 if (info_ptr->valid & PNG_INFO_pHYs) 159 164 { 160 png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter"); 161 if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER || 165 png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter"); 166 167 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER || 162 168 info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) 163 169 return (0); 164 else return (info_ptr->x_pixels_per_unit); 170 171 else 172 return (info_ptr->x_pixels_per_unit); 165 173 } 166 174 #else … … 176 184 if (png_ptr != NULL && info_ptr != NULL) 177 185 #if defined(PNG_pHYs_SUPPORTED) 186 178 187 if (info_ptr->valid & PNG_INFO_pHYs) 179 188 { 180 png_debug1(1, "in %s retrieval function \n", "png_get_aspect_ratio");189 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); 181 190 if (info_ptr->x_pixels_per_unit == 0) 182 191 return ((float)0.0); … … 186 195 } 187 196 #else 188 return (0.0);197 return (0.0); 189 198 #endif 190 199 return ((float)0.0); … … 197 206 if (png_ptr != NULL && info_ptr != NULL) 198 207 #if defined(PNG_oFFs_SUPPORTED) 208 199 209 if (info_ptr->valid & PNG_INFO_oFFs) 200 210 { 201 png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); 202 if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) 211 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); 212 213 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) 203 214 return (0); 204 else return (info_ptr->x_offset); 215 216 else 217 return (info_ptr->x_offset); 205 218 } 206 219 #else 207 return (0);220 return (0); 208 221 #endif 209 222 return (0); … … 214 227 { 215 228 if (png_ptr != NULL && info_ptr != NULL) 229 216 230 #if defined(PNG_oFFs_SUPPORTED) 217 231 if (info_ptr->valid & PNG_INFO_oFFs) 218 232 { 219 png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); 220 if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) 233 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); 234 235 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) 221 236 return (0); 222 else return (info_ptr->y_offset); 237 238 else 239 return (info_ptr->y_offset); 223 240 } 224 241 #else … … 232 249 { 233 250 if (png_ptr != NULL && info_ptr != NULL) 251 234 252 #if defined(PNG_oFFs_SUPPORTED) 235 253 if (info_ptr->valid & PNG_INFO_oFFs) 236 254 { 237 png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); 238 if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) 255 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); 256 257 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) 239 258 return (0); 240 else return (info_ptr->x_offset); 259 260 else 261 return (info_ptr->x_offset); 241 262 } 242 263 #else … … 250 271 { 251 272 if (png_ptr != NULL && info_ptr != NULL) 273 252 274 #if defined(PNG_oFFs_SUPPORTED) 253 275 if (info_ptr->valid & PNG_INFO_oFFs) 254 276 { 255 png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); 256 if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) 277 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); 278 279 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) 257 280 return (0); 258 else return (info_ptr->y_offset); 281 282 else 283 return (info_ptr->y_offset); 259 284 } 260 285 #else … … 309 334 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) 310 335 { 311 png_debug1(1, "in %s retrieval function \n", "pHYs");336 png_debug1(1, "in %s retrieval function", "pHYs"); 312 337 if (res_x != NULL) 313 338 { … … 324 349 *unit_type = (int)info_ptr->phys_unit_type; 325 350 retval |= PNG_INFO_pHYs; 326 if (*unit_type == 1)351 if (*unit_type == 1) 327 352 { 328 353 if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); … … 366 391 && background != NULL) 367 392 { 368 png_debug1(1, "in %s retrieval function \n", "bKGD");393 png_debug1(1, "in %s retrieval function", "bKGD"); 369 394 *background = &(info_ptr->background); 370 395 return (PNG_INFO_bKGD); … … 383 408 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) 384 409 { 385 png_debug1(1, "in %s retrieval function \n", "cHRM");410 png_debug1(1, "in %s retrieval function", "cHRM"); 386 411 if (white_x != NULL) 387 412 *white_x = (double)info_ptr->x_white; … … 414 439 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) 415 440 { 416 png_debug1(1, "in %s retrieval function \n", "cHRM");441 png_debug1(1, "in %s retrieval function", "cHRM"); 417 442 if (white_x != NULL) 418 443 *white_x = info_ptr->int_x_white; … … 446 471 && file_gamma != NULL) 447 472 { 448 png_debug1(1, "in %s retrieval function \n", "gAMA");473 png_debug1(1, "in %s retrieval function", "gAMA"); 449 474 *file_gamma = (double)info_ptr->gamma; 450 475 return (PNG_INFO_gAMA); … … 461 486 && int_file_gamma != NULL) 462 487 { 463 png_debug1(1, "in %s retrieval function \n", "gAMA");488 png_debug1(1, "in %s retrieval function", "gAMA"); 464 489 *int_file_gamma = info_ptr->int_gamma; 465 490 return (PNG_INFO_gAMA); … … 477 502 && file_srgb_intent != NULL) 478 503 { 479 png_debug1(1, "in %s retrieval function \n", "sRGB");504 png_debug1(1, "in %s retrieval function", "sRGB"); 480 505 *file_srgb_intent = (int)info_ptr->srgb_intent; 481 506 return (PNG_INFO_sRGB); … … 494 519 && name != NULL && profile != NULL && proflen != NULL) 495 520 { 496 png_debug1(1, "in %s retrieval function \n", "iCCP");521 png_debug1(1, "in %s retrieval function", "iCCP"); 497 522 *name = info_ptr->iccp_name; 498 523 *profile = info_ptr->iccp_profile; 499 /* compression_type is a dummy so the API won't have to change 500 if we introduce multiple compression types later. */ 524 /* Compression_type is a dummy so the API won't have to change 525 * if we introduce multiple compression types later. 526 */ 501 527 *proflen = (int)info_ptr->iccp_proflen; 502 528 *compression_type = (int)info_ptr->iccp_compression; … … 528 554 && hist != NULL) 529 555 { 530 png_debug1(1, "in %s retrieval function \n", "hIST");556 png_debug1(1, "in %s retrieval function", "hIST"); 531 557 *hist = info_ptr->hist; 532 558 return (PNG_INFO_hIST); … … 546 572 bit_depth != NULL && color_type != NULL) 547 573 { 548 png_debug1(1, "in %s retrieval function \n", "IHDR");574 png_debug1(1, "in %s retrieval function", "IHDR"); 549 575 *width = info_ptr->width; 550 576 *height = info_ptr->height; 551 577 *bit_depth = info_ptr->bit_depth; 552 578 if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16) 553 png_error(png_ptr, "Invalid bit depth"); 579 png_error(png_ptr, "Invalid bit depth"); 580 554 581 *color_type = info_ptr->color_type; 582 555 583 if (info_ptr->color_type > 6) 556 png_error(png_ptr, "Invalid color type"); 584 png_error(png_ptr, "Invalid color type"); 585 557 586 if (compression_type != NULL) 558 587 *compression_type = info_ptr->compression_type; 588 559 589 if (filter_type != NULL) 560 590 *filter_type = info_ptr->filter_type; 591 561 592 if (interlace_type != NULL) 562 593 *interlace_type = info_ptr->interlace_type; 563 594 564 /* check for potential overflow of rowbytes */595 /* Check for potential overflow of rowbytes */ 565 596 if (*width == 0 || *width > PNG_UINT_31_MAX) 566 597 png_error(png_ptr, "Invalid image width"); 598 567 599 if (*height == 0 || *height > PNG_UINT_31_MAX) 568 600 png_error(png_ptr, "Invalid image height"); 601 569 602 if (info_ptr->width > (PNG_UINT_32_MAX 570 603 >> 3) /* 8-byte RGBA pixels */ … … 577 610 "Width too large for libpng to process image data."); 578 611 } 612 579 613 return (1); 580 614 } … … 590 624 && offset_x != NULL && offset_y != NULL && unit_type != NULL) 591 625 { 592 png_debug1(1, "in %s retrieval function \n", "oFFs");626 png_debug1(1, "in %s retrieval function", "oFFs"); 593 627 *offset_x = info_ptr->x_offset; 594 628 *offset_y = info_ptr->y_offset; … … 607 641 { 608 642 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) 609 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&610 nparams != NULL && units != NULL && params != NULL)611 { 612 png_debug1(1, "in %s retrieval function \n", "pCAL");643 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && 644 nparams != NULL && units != NULL && params != NULL) 645 { 646 png_debug1(1, "in %s retrieval function", "pCAL"); 613 647 *purpose = info_ptr->pcal_purpose; 614 648 *X0 = info_ptr->pcal_X0; … … 631 665 { 632 666 if (png_ptr != NULL && info_ptr != NULL && 633 (info_ptr->valid & PNG_INFO_sCAL))667 (info_ptr->valid & PNG_INFO_sCAL)) 634 668 { 635 669 *unit = info_ptr->scal_unit; … … 647 681 { 648 682 if (png_ptr != NULL && info_ptr != NULL && 649 (info_ptr->valid & PNG_INFO_sCAL))683 (info_ptr->valid & PNG_INFO_sCAL)) 650 684 { 651 685 *unit = info_ptr->scal_unit; … … 670 704 (info_ptr->valid & PNG_INFO_pHYs)) 671 705 { 672 png_debug1(1, "in %s retrieval function\n", "pHYs"); 706 png_debug1(1, "in %s retrieval function", "pHYs"); 707 673 708 if (res_x != NULL) 674 709 { … … 676 711 retval |= PNG_INFO_pHYs; 677 712 } 713 678 714 if (res_y != NULL) 679 715 { … … 681 717 retval |= PNG_INFO_pHYs; 682 718 } 719 683 720 if (unit_type != NULL) 684 721 { … … 698 735 && palette != NULL) 699 736 { 700 png_debug1(1, "in %s retrieval function \n", "PLTE");737 png_debug1(1, "in %s retrieval function", "PLTE"); 701 738 *palette = info_ptr->palette; 702 739 *num_palette = info_ptr->num_palette; 703 png_debug1(3, "num_palette = %d \n", *num_palette);740 png_debug1(3, "num_palette = %d", *num_palette); 704 741 return (PNG_INFO_PLTE); 705 742 } … … 714 751 && sig_bit != NULL) 715 752 { 716 png_debug1(1, "in %s retrieval function \n", "sBIT");753 png_debug1(1, "in %s retrieval function", "sBIT"); 717 754 *sig_bit = &(info_ptr->sig_bit); 718 755 return (PNG_INFO_sBIT); … … 729 766 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) 730 767 { 731 png_debug1(1, "in %s retrieval function \n",768 png_debug1(1, "in %s retrieval function", 732 769 (png_ptr->chunk_name[0] == '\0' ? "text" 733 770 : (png_const_charp)png_ptr->chunk_name)); 771 734 772 if (text_ptr != NULL) 735 773 *text_ptr = info_ptr->text; 774 736 775 if (num_text != NULL) 737 776 *num_text = info_ptr->num_text; 777 738 778 return ((png_uint_32)info_ptr->num_text); 739 779 } … … 751 791 && mod_time != NULL) 752 792 { 753 png_debug1(1, "in %s retrieval function \n", "tIME");793 png_debug1(1, "in %s retrieval function", "tIME"); 754 794 *mod_time = &(info_ptr->mod_time); 755 795 return (PNG_INFO_tIME); … … 767 807 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) 768 808 { 769 png_debug1(1, "in %s retrieval function \n", "tRNS");809 png_debug1(1, "in %s retrieval function", "tRNS"); 770 810 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) 771 811 { … … 775 815 retval |= PNG_INFO_tRNS; 776 816 } 817 777 818 if (trans_values != NULL) 778 819 *trans_values = &(info_ptr->trans_values); … … 785 826 retval |= PNG_INFO_tRNS; 786 827 } 787 if(trans != NULL) 828 829 if (trans != NULL) 788 830 *trans = NULL; 789 831 } 790 if (num_trans != NULL)832 if (num_trans != NULL) 791 833 { 792 834 *num_trans = info_ptr->num_trans; … … 838 880 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED 839 881 #ifndef PNG_1_0_X 840 /* this function was added to libpng 1.2.0 and should exist by default */882 /* This function was added to libpng 1.2.0 and should exist by default */ 841 883 png_uint_32 PNGAPI 842 884 png_get_asm_flags (png_structp png_ptr) 843 885 { 844 /* obsolete, to be removed from libpng-1.4.0 */886 /* Obsolete, to be removed from libpng-1.4.0 */ 845 887 return (png_ptr? 0L: 0L); 846 888 } 847 889 848 /* this function was added to libpng 1.2.0 and should exist by default */890 /* This function was added to libpng 1.2.0 and should exist by default */ 849 891 png_uint_32 PNGAPI 850 892 png_get_asm_flagmask (int flag_select) 851 893 { 852 /* obsolete, to be removed from libpng-1.4.0 */894 /* Obsolete, to be removed from libpng-1.4.0 */ 853 895 flag_select=flag_select; 854 896 return 0L; … … 856 898 857 899 /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ 858 /* this function was added to libpng 1.2.0 */900 /* This function was added to libpng 1.2.0 */ 859 901 png_uint_32 PNGAPI 860 902 png_get_mmx_flagmask (int flag_select, int *compilerID) 861 903 { 862 /* obsolete, to be removed from libpng-1.4.0 */904 /* Obsolete, to be removed from libpng-1.4.0 */ 863 905 flag_select=flag_select; 864 906 *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */ … … 866 908 } 867 909 868 /* this function was added to libpng 1.2.0 */910 /* This function was added to libpng 1.2.0 */ 869 911 png_byte PNGAPI 870 912 png_get_mmx_bitdepth_threshold (png_structp png_ptr) 871 913 { 872 /* obsolete, to be removed from libpng-1.4.0 */914 /* Obsolete, to be removed from libpng-1.4.0 */ 873 915 return (png_ptr? 0: 0); 874 916 } 875 917 876 /* this function was added to libpng 1.2.0 */918 /* This function was added to libpng 1.2.0 */ 877 919 png_uint_32 PNGAPI 878 920 png_get_mmx_rowbytes_threshold (png_structp png_ptr) 879 921 { 880 /* obsolete, to be removed from libpng-1.4.0 */922 /* Obsolete, to be removed from libpng-1.4.0 */ 881 923 return (png_ptr? 0L: 0L); 882 924 } … … 885 927 886 928 #ifdef PNG_SET_USER_LIMITS_SUPPORTED 887 /* these functions were added to libpng 1.2.6 */929 /* These functions were added to libpng 1.2.6 */ 888 930 png_uint_32 PNGAPI 889 931 png_get_user_width_max (png_structp png_ptr) … … 897 939 } 898 940 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ 899 941 900 942 901 943 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
Note:
See TracChangeset
for help on using the changeset viewer.