| OLD | NEW |
| 1 | 1 |
| 2 /* pngget.c - retrieval of values from info struct | 2 /* pngget.c - retrieval of values from info struct |
| 3 * | 3 * |
| 4 * Last changed in libpng 1.2.30 [August 15, 2008] | 4 * Last changed in libpng 1.2.37 [June 4, 2009] |
| 5 * For conditions of distribution and use, see copyright notice in png.h | 5 * For conditions of distribution and use, see copyright notice in png.h |
| 6 * Copyright (c) 1998-2008 Glenn Randers-Pehrson | 6 * Copyright (c) 1998-2009 Glenn Randers-Pehrson |
| 7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) | 7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) |
| 8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) | 8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #define PNG_INTERNAL | 11 #define PNG_INTERNAL |
| 12 #include "png.h" | 12 #include "png.h" |
| 13 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) | 13 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) |
| 14 | 14 |
| 15 png_uint_32 PNGAPI | 15 png_uint_32 PNGAPI |
| 16 png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) | 16 png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) |
| 17 { | 17 { |
| 18 if (png_ptr != NULL && info_ptr != NULL) | 18 if (png_ptr != NULL && info_ptr != NULL) |
| 19 return(info_ptr->valid & flag); | 19 return(info_ptr->valid & flag); |
| 20 |
| 20 else | 21 else |
| 21 return(0); | 22 return(0); |
| 22 } | 23 } |
| 23 | 24 |
| 24 png_uint_32 PNGAPI | 25 png_uint_32 PNGAPI |
| 25 png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) | 26 png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) |
| 26 { | 27 { |
| 27 if (png_ptr != NULL && info_ptr != NULL) | 28 if (png_ptr != NULL && info_ptr != NULL) |
| 28 return(info_ptr->rowbytes); | 29 return(info_ptr->rowbytes); |
| 30 |
| 29 else | 31 else |
| 30 return(0); | 32 return(0); |
| 31 } | 33 } |
| 32 | 34 |
| 33 #if defined(PNG_INFO_IMAGE_SUPPORTED) | 35 #if defined(PNG_INFO_IMAGE_SUPPORTED) |
| 34 png_bytepp PNGAPI | 36 png_bytepp PNGAPI |
| 35 png_get_rows(png_structp png_ptr, png_infop info_ptr) | 37 png_get_rows(png_structp png_ptr, png_infop info_ptr) |
| 36 { | 38 { |
| 37 if (png_ptr != NULL && info_ptr != NULL) | 39 if (png_ptr != NULL && info_ptr != NULL) |
| 38 return(info_ptr->row_pointers); | 40 return(info_ptr->row_pointers); |
| 41 |
| 39 else | 42 else |
| 40 return(0); | 43 return(0); |
| 41 } | 44 } |
| 42 #endif | 45 #endif |
| 43 | 46 |
| 44 #ifdef PNG_EASY_ACCESS_SUPPORTED | 47 #ifdef PNG_EASY_ACCESS_SUPPORTED |
| 45 /* easy access to info, added in libpng-0.99 */ | 48 /* Easy access to info, added in libpng-0.99 */ |
| 46 png_uint_32 PNGAPI | 49 png_uint_32 PNGAPI |
| 47 png_get_image_width(png_structp png_ptr, png_infop info_ptr) | 50 png_get_image_width(png_structp png_ptr, png_infop info_ptr) |
| 48 { | 51 { |
| 49 if (png_ptr != NULL && info_ptr != NULL) | 52 if (png_ptr != NULL && info_ptr != NULL) |
| 50 { | |
| 51 return info_ptr->width; | 53 return info_ptr->width; |
| 52 } | 54 |
| 53 return (0); | 55 return (0); |
| 54 } | 56 } |
| 55 | 57 |
| 56 png_uint_32 PNGAPI | 58 png_uint_32 PNGAPI |
| 57 png_get_image_height(png_structp png_ptr, png_infop info_ptr) | 59 png_get_image_height(png_structp png_ptr, png_infop info_ptr) |
| 58 { | 60 { |
| 59 if (png_ptr != NULL && info_ptr != NULL) | 61 if (png_ptr != NULL && info_ptr != NULL) |
| 60 { | |
| 61 return info_ptr->height; | 62 return info_ptr->height; |
| 62 } | 63 |
| 63 return (0); | 64 return (0); |
| 64 } | 65 } |
| 65 | 66 |
| 66 png_byte PNGAPI | 67 png_byte PNGAPI |
| 67 png_get_bit_depth(png_structp png_ptr, png_infop info_ptr) | 68 png_get_bit_depth(png_structp png_ptr, png_infop info_ptr) |
| 68 { | 69 { |
| 69 if (png_ptr != NULL && info_ptr != NULL) | 70 if (png_ptr != NULL && info_ptr != NULL) |
| 70 { | |
| 71 return info_ptr->bit_depth; | 71 return info_ptr->bit_depth; |
| 72 } | 72 |
| 73 return (0); | 73 return (0); |
| 74 } | 74 } |
| 75 | 75 |
| 76 png_byte PNGAPI | 76 png_byte PNGAPI |
| 77 png_get_color_type(png_structp png_ptr, png_infop info_ptr) | 77 png_get_color_type(png_structp png_ptr, png_infop info_ptr) |
| 78 { | 78 { |
| 79 if (png_ptr != NULL && info_ptr != NULL) | 79 if (png_ptr != NULL && info_ptr != NULL) |
| 80 { | |
| 81 return info_ptr->color_type; | 80 return info_ptr->color_type; |
| 82 } | 81 |
| 83 return (0); | 82 return (0); |
| 84 } | 83 } |
| 85 | 84 |
| 86 png_byte PNGAPI | 85 png_byte PNGAPI |
| 87 png_get_filter_type(png_structp png_ptr, png_infop info_ptr) | 86 png_get_filter_type(png_structp png_ptr, png_infop info_ptr) |
| 88 { | 87 { |
| 89 if (png_ptr != NULL && info_ptr != NULL) | 88 if (png_ptr != NULL && info_ptr != NULL) |
| 90 { | |
| 91 return info_ptr->filter_type; | 89 return info_ptr->filter_type; |
| 92 } | 90 |
| 93 return (0); | 91 return (0); |
| 94 } | 92 } |
| 95 | 93 |
| 96 png_byte PNGAPI | 94 png_byte PNGAPI |
| 97 png_get_interlace_type(png_structp png_ptr, png_infop info_ptr) | 95 png_get_interlace_type(png_structp png_ptr, png_infop info_ptr) |
| 98 { | 96 { |
| 99 if (png_ptr != NULL && info_ptr != NULL) | 97 if (png_ptr != NULL && info_ptr != NULL) |
| 100 { | |
| 101 return info_ptr->interlace_type; | 98 return info_ptr->interlace_type; |
| 102 } | 99 |
| 103 return (0); | 100 return (0); |
| 104 } | 101 } |
| 105 | 102 |
| 106 png_byte PNGAPI | 103 png_byte PNGAPI |
| 107 png_get_compression_type(png_structp png_ptr, png_infop info_ptr) | 104 png_get_compression_type(png_structp png_ptr, png_infop info_ptr) |
| 108 { | 105 { |
| 109 if (png_ptr != NULL && info_ptr != NULL) | 106 if (png_ptr != NULL && info_ptr != NULL) |
| 110 { | |
| 111 return info_ptr->compression_type; | 107 return info_ptr->compression_type; |
| 112 } | 108 |
| 113 return (0); | 109 return (0); |
| 114 } | 110 } |
| 115 | 111 |
| 116 png_uint_32 PNGAPI | 112 png_uint_32 PNGAPI |
| 117 png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) | 113 png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) |
| 118 { | 114 { |
| 119 if (png_ptr != NULL && info_ptr != NULL) | 115 if (png_ptr != NULL && info_ptr != NULL) |
| 120 #if defined(PNG_pHYs_SUPPORTED) | 116 #if defined(PNG_pHYs_SUPPORTED) |
| 121 if (info_ptr->valid & PNG_INFO_pHYs) | 117 if (info_ptr->valid & PNG_INFO_pHYs) |
| 122 { | 118 { |
| 123 png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter"); | 119 png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter"); |
| 120 |
| 124 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER) | 121 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER) |
| 125 return (0); | 122 return (0); |
| 126 else return (info_ptr->x_pixels_per_unit); | 123 |
| 124 else |
| 125 return (info_ptr->x_pixels_per_unit); |
| 127 } | 126 } |
| 128 #else | 127 #else |
| 129 return (0); | 128 return (0); |
| 130 #endif | 129 #endif |
| 131 return (0); | 130 return (0); |
| 132 } | 131 } |
| 133 | 132 |
| 134 png_uint_32 PNGAPI | 133 png_uint_32 PNGAPI |
| 135 png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) | 134 png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) |
| 136 { | 135 { |
| 137 if (png_ptr != NULL && info_ptr != NULL) | 136 if (png_ptr != NULL && info_ptr != NULL) |
| 138 #if defined(PNG_pHYs_SUPPORTED) | 137 #if defined(PNG_pHYs_SUPPORTED) |
| 139 if (info_ptr->valid & PNG_INFO_pHYs) | 138 if (info_ptr->valid & PNG_INFO_pHYs) |
| 140 { | 139 { |
| 141 png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter"); | 140 png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter"); |
| 141 |
| 142 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER) | 142 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER) |
| 143 return (0); | 143 return (0); |
| 144 else return (info_ptr->y_pixels_per_unit); | 144 |
| 145 else |
| 146 return (info_ptr->y_pixels_per_unit); |
| 145 } | 147 } |
| 146 #else | 148 #else |
| 147 return (0); | 149 return (0); |
| 148 #endif | 150 #endif |
| 149 return (0); | 151 return (0); |
| 150 } | 152 } |
| 151 | 153 |
| 152 png_uint_32 PNGAPI | 154 png_uint_32 PNGAPI |
| 153 png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) | 155 png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) |
| 154 { | 156 { |
| 155 if (png_ptr != NULL && info_ptr != NULL) | 157 if (png_ptr != NULL && info_ptr != NULL) |
| 156 #if defined(PNG_pHYs_SUPPORTED) | 158 #if defined(PNG_pHYs_SUPPORTED) |
| 157 if (info_ptr->valid & PNG_INFO_pHYs) | 159 if (info_ptr->valid & PNG_INFO_pHYs) |
| 158 { | 160 { |
| 159 png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter"); | 161 png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter"); |
| 162 |
| 160 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER || | 163 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER || |
| 161 info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) | 164 info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) |
| 162 return (0); | 165 return (0); |
| 163 else return (info_ptr->x_pixels_per_unit); | 166 |
| 167 else |
| 168 return (info_ptr->x_pixels_per_unit); |
| 164 } | 169 } |
| 165 #else | 170 #else |
| 166 return (0); | 171 return (0); |
| 167 #endif | 172 #endif |
| 168 return (0); | 173 return (0); |
| 169 } | 174 } |
| 170 | 175 |
| 171 #ifdef PNG_FLOATING_POINT_SUPPORTED | 176 #ifdef PNG_FLOATING_POINT_SUPPORTED |
| 172 float PNGAPI | 177 float PNGAPI |
| 173 png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) | 178 png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) |
| 174 { | 179 { |
| 175 if (png_ptr != NULL && info_ptr != NULL) | 180 if (png_ptr != NULL && info_ptr != NULL) |
| 176 #if defined(PNG_pHYs_SUPPORTED) | 181 #if defined(PNG_pHYs_SUPPORTED) |
| 182 |
| 177 if (info_ptr->valid & PNG_INFO_pHYs) | 183 if (info_ptr->valid & PNG_INFO_pHYs) |
| 178 { | 184 { |
| 179 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); | 185 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); |
| 180 if (info_ptr->x_pixels_per_unit == 0) | 186 if (info_ptr->x_pixels_per_unit == 0) |
| 181 return ((float)0.0); | 187 return ((float)0.0); |
| 182 else | 188 else |
| 183 return ((float)((float)info_ptr->y_pixels_per_unit | 189 return ((float)((float)info_ptr->y_pixels_per_unit |
| 184 /(float)info_ptr->x_pixels_per_unit)); | 190 /(float)info_ptr->x_pixels_per_unit)); |
| 185 } | 191 } |
| 186 #else | 192 #else |
| 187 return (0.0); | 193 return (0.0); |
| 188 #endif | 194 #endif |
| 189 return ((float)0.0); | 195 return ((float)0.0); |
| 190 } | 196 } |
| 191 #endif | 197 #endif |
| 192 | 198 |
| 193 png_int_32 PNGAPI | 199 png_int_32 PNGAPI |
| 194 png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) | 200 png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) |
| 195 { | 201 { |
| 196 if (png_ptr != NULL && info_ptr != NULL) | 202 if (png_ptr != NULL && info_ptr != NULL) |
| 197 #if defined(PNG_oFFs_SUPPORTED) | 203 #if defined(PNG_oFFs_SUPPORTED) |
| 204 |
| 198 if (info_ptr->valid & PNG_INFO_oFFs) | 205 if (info_ptr->valid & PNG_INFO_oFFs) |
| 199 { | 206 { |
| 200 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); | 207 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); |
| 208 |
| 201 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) | 209 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) |
| 202 return (0); | 210 return (0); |
| 203 else return (info_ptr->x_offset); | 211 |
| 212 else |
| 213 return (info_ptr->x_offset); |
| 204 } | 214 } |
| 205 #else | 215 #else |
| 206 return (0); | 216 return (0); |
| 207 #endif | 217 #endif |
| 208 return (0); | 218 return (0); |
| 209 } | 219 } |
| 210 | 220 |
| 211 png_int_32 PNGAPI | 221 png_int_32 PNGAPI |
| 212 png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr) | 222 png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr) |
| 213 { | 223 { |
| 214 if (png_ptr != NULL && info_ptr != NULL) | 224 if (png_ptr != NULL && info_ptr != NULL) |
| 225 |
| 215 #if defined(PNG_oFFs_SUPPORTED) | 226 #if defined(PNG_oFFs_SUPPORTED) |
| 216 if (info_ptr->valid & PNG_INFO_oFFs) | 227 if (info_ptr->valid & PNG_INFO_oFFs) |
| 217 { | 228 { |
| 218 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); | 229 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); |
| 230 |
| 219 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) | 231 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) |
| 220 return (0); | 232 return (0); |
| 221 else return (info_ptr->y_offset); | 233 |
| 234 else |
| 235 return (info_ptr->y_offset); |
| 222 } | 236 } |
| 223 #else | 237 #else |
| 224 return (0); | 238 return (0); |
| 225 #endif | 239 #endif |
| 226 return (0); | 240 return (0); |
| 227 } | 241 } |
| 228 | 242 |
| 229 png_int_32 PNGAPI | 243 png_int_32 PNGAPI |
| 230 png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr) | 244 png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr) |
| 231 { | 245 { |
| 232 if (png_ptr != NULL && info_ptr != NULL) | 246 if (png_ptr != NULL && info_ptr != NULL) |
| 247 |
| 233 #if defined(PNG_oFFs_SUPPORTED) | 248 #if defined(PNG_oFFs_SUPPORTED) |
| 234 if (info_ptr->valid & PNG_INFO_oFFs) | 249 if (info_ptr->valid & PNG_INFO_oFFs) |
| 235 { | 250 { |
| 236 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); | 251 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); |
| 252 |
| 237 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) | 253 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) |
| 238 return (0); | 254 return (0); |
| 239 else return (info_ptr->x_offset); | 255 |
| 256 else |
| 257 return (info_ptr->x_offset); |
| 240 } | 258 } |
| 241 #else | 259 #else |
| 242 return (0); | 260 return (0); |
| 243 #endif | 261 #endif |
| 244 return (0); | 262 return (0); |
| 245 } | 263 } |
| 246 | 264 |
| 247 png_int_32 PNGAPI | 265 png_int_32 PNGAPI |
| 248 png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr) | 266 png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr) |
| 249 { | 267 { |
| 250 if (png_ptr != NULL && info_ptr != NULL) | 268 if (png_ptr != NULL && info_ptr != NULL) |
| 269 |
| 251 #if defined(PNG_oFFs_SUPPORTED) | 270 #if defined(PNG_oFFs_SUPPORTED) |
| 252 if (info_ptr->valid & PNG_INFO_oFFs) | 271 if (info_ptr->valid & PNG_INFO_oFFs) |
| 253 { | 272 { |
| 254 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); | 273 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); |
| 274 |
| 255 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) | 275 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) |
| 256 return (0); | 276 return (0); |
| 257 else return (info_ptr->y_offset); | 277 |
| 278 else |
| 279 return (info_ptr->y_offset); |
| 258 } | 280 } |
| 259 #else | 281 #else |
| 260 return (0); | 282 return (0); |
| 261 #endif | 283 #endif |
| 262 return (0); | 284 return (0); |
| 263 } | 285 } |
| 264 | 286 |
| 265 #if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) | 287 #if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) |
| 266 png_uint_32 PNGAPI | 288 png_uint_32 PNGAPI |
| 267 png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) | 289 png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 png_get_iCCP(png_structp png_ptr, png_infop info_ptr, | 510 png_get_iCCP(png_structp png_ptr, png_infop info_ptr, |
| 489 png_charpp name, int *compression_type, | 511 png_charpp name, int *compression_type, |
| 490 png_charpp profile, png_uint_32 *proflen) | 512 png_charpp profile, png_uint_32 *proflen) |
| 491 { | 513 { |
| 492 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) | 514 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) |
| 493 && name != NULL && profile != NULL && proflen != NULL) | 515 && name != NULL && profile != NULL && proflen != NULL) |
| 494 { | 516 { |
| 495 png_debug1(1, "in %s retrieval function", "iCCP"); | 517 png_debug1(1, "in %s retrieval function", "iCCP"); |
| 496 *name = info_ptr->iccp_name; | 518 *name = info_ptr->iccp_name; |
| 497 *profile = info_ptr->iccp_profile; | 519 *profile = info_ptr->iccp_profile; |
| 498 /* compression_type is a dummy so the API won't have to change | 520 /* Compression_type is a dummy so the API won't have to change |
| 499 if we introduce multiple compression types later. */ | 521 * if we introduce multiple compression types later. |
| 522 */ |
| 500 *proflen = (int)info_ptr->iccp_proflen; | 523 *proflen = (int)info_ptr->iccp_proflen; |
| 501 *compression_type = (int)info_ptr->iccp_compression; | 524 *compression_type = (int)info_ptr->iccp_compression; |
| 502 return (PNG_INFO_iCCP); | 525 return (PNG_INFO_iCCP); |
| 503 } | 526 } |
| 504 return (0); | 527 return (0); |
| 505 } | 528 } |
| 506 #endif | 529 #endif |
| 507 | 530 |
| 508 #if defined(PNG_sPLT_SUPPORTED) | 531 #if defined(PNG_sPLT_SUPPORTED) |
| 509 png_uint_32 PNGAPI | 532 png_uint_32 PNGAPI |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 | 565 |
| 543 { | 566 { |
| 544 if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && | 567 if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && |
| 545 bit_depth != NULL && color_type != NULL) | 568 bit_depth != NULL && color_type != NULL) |
| 546 { | 569 { |
| 547 png_debug1(1, "in %s retrieval function", "IHDR"); | 570 png_debug1(1, "in %s retrieval function", "IHDR"); |
| 548 *width = info_ptr->width; | 571 *width = info_ptr->width; |
| 549 *height = info_ptr->height; | 572 *height = info_ptr->height; |
| 550 *bit_depth = info_ptr->bit_depth; | 573 *bit_depth = info_ptr->bit_depth; |
| 551 if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16) | 574 if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16) |
| 552 png_error(png_ptr, "Invalid bit depth"); | 575 png_error(png_ptr, "Invalid bit depth"); |
| 576 |
| 553 *color_type = info_ptr->color_type; | 577 *color_type = info_ptr->color_type; |
| 578 |
| 554 if (info_ptr->color_type > 6) | 579 if (info_ptr->color_type > 6) |
| 555 png_error(png_ptr, "Invalid color type"); | 580 png_error(png_ptr, "Invalid color type"); |
| 581 |
| 556 if (compression_type != NULL) | 582 if (compression_type != NULL) |
| 557 *compression_type = info_ptr->compression_type; | 583 *compression_type = info_ptr->compression_type; |
| 584 |
| 558 if (filter_type != NULL) | 585 if (filter_type != NULL) |
| 559 *filter_type = info_ptr->filter_type; | 586 *filter_type = info_ptr->filter_type; |
| 587 |
| 560 if (interlace_type != NULL) | 588 if (interlace_type != NULL) |
| 561 *interlace_type = info_ptr->interlace_type; | 589 *interlace_type = info_ptr->interlace_type; |
| 562 | 590 |
| 563 /* check for potential overflow of rowbytes */ | 591 /* Check for potential overflow of rowbytes */ |
| 564 if (*width == 0 || *width > PNG_UINT_31_MAX) | 592 if (*width == 0 || *width > PNG_UINT_31_MAX) |
| 565 png_error(png_ptr, "Invalid image width"); | 593 png_error(png_ptr, "Invalid image width"); |
| 594 |
| 566 if (*height == 0 || *height > PNG_UINT_31_MAX) | 595 if (*height == 0 || *height > PNG_UINT_31_MAX) |
| 567 png_error(png_ptr, "Invalid image height"); | 596 png_error(png_ptr, "Invalid image height"); |
| 597 |
| 568 if (info_ptr->width > (PNG_UINT_32_MAX | 598 if (info_ptr->width > (PNG_UINT_32_MAX |
| 569 >> 3) /* 8-byte RGBA pixels */ | 599 >> 3) /* 8-byte RGBA pixels */ |
| 570 - 64 /* bigrowbuf hack */ | 600 - 64 /* bigrowbuf hack */ |
| 571 - 1 /* filter byte */ | 601 - 1 /* filter byte */ |
| 572 - 7*8 /* rounding of width to multiple of 8 pixels */ | 602 - 7*8 /* rounding of width to multiple of 8 pixels */ |
| 573 - 8) /* extra max_pixel_depth pad */ | 603 - 8) /* extra max_pixel_depth pad */ |
| 574 { | 604 { |
| 575 png_warning(png_ptr, | 605 png_warning(png_ptr, |
| 576 "Width too large for libpng to process image data."); | 606 "Width too large for libpng to process image data."); |
| 577 } | 607 } |
| 608 |
| 578 return (1); | 609 return (1); |
| 579 } | 610 } |
| 580 return (0); | 611 return (0); |
| 581 } | 612 } |
| 582 | 613 |
| 583 #if defined(PNG_oFFs_SUPPORTED) | 614 #if defined(PNG_oFFs_SUPPORTED) |
| 584 png_uint_32 PNGAPI | 615 png_uint_32 PNGAPI |
| 585 png_get_oFFs(png_structp png_ptr, png_infop info_ptr, | 616 png_get_oFFs(png_structp png_ptr, png_infop info_ptr, |
| 586 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) | 617 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) |
| 587 { | 618 { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 598 } | 629 } |
| 599 #endif | 630 #endif |
| 600 | 631 |
| 601 #if defined(PNG_pCAL_SUPPORTED) | 632 #if defined(PNG_pCAL_SUPPORTED) |
| 602 png_uint_32 PNGAPI | 633 png_uint_32 PNGAPI |
| 603 png_get_pCAL(png_structp png_ptr, png_infop info_ptr, | 634 png_get_pCAL(png_structp png_ptr, png_infop info_ptr, |
| 604 png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, | 635 png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, |
| 605 png_charp *units, png_charpp *params) | 636 png_charp *units, png_charpp *params) |
| 606 { | 637 { |
| 607 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) | 638 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) |
| 608 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && | 639 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && |
| 609 nparams != NULL && units != NULL && params != NULL) | 640 nparams != NULL && units != NULL && params != NULL) |
| 610 { | 641 { |
| 611 png_debug1(1, "in %s retrieval function", "pCAL"); | 642 png_debug1(1, "in %s retrieval function", "pCAL"); |
| 612 *purpose = info_ptr->pcal_purpose; | 643 *purpose = info_ptr->pcal_purpose; |
| 613 *X0 = info_ptr->pcal_X0; | 644 *X0 = info_ptr->pcal_X0; |
| 614 *X1 = info_ptr->pcal_X1; | 645 *X1 = info_ptr->pcal_X1; |
| 615 *type = (int)info_ptr->pcal_type; | 646 *type = (int)info_ptr->pcal_type; |
| 616 *nparams = (int)info_ptr->pcal_nparams; | 647 *nparams = (int)info_ptr->pcal_nparams; |
| 617 *units = info_ptr->pcal_units; | 648 *units = info_ptr->pcal_units; |
| 618 *params = info_ptr->pcal_params; | 649 *params = info_ptr->pcal_params; |
| 619 return (PNG_INFO_pCAL); | 650 return (PNG_INFO_pCAL); |
| 620 } | 651 } |
| 621 return (0); | 652 return (0); |
| 622 } | 653 } |
| 623 #endif | 654 #endif |
| 624 | 655 |
| 625 #if defined(PNG_sCAL_SUPPORTED) | 656 #if defined(PNG_sCAL_SUPPORTED) |
| 626 #ifdef PNG_FLOATING_POINT_SUPPORTED | 657 #ifdef PNG_FLOATING_POINT_SUPPORTED |
| 627 png_uint_32 PNGAPI | 658 png_uint_32 PNGAPI |
| 628 png_get_sCAL(png_structp png_ptr, png_infop info_ptr, | 659 png_get_sCAL(png_structp png_ptr, png_infop info_ptr, |
| 629 int *unit, double *width, double *height) | 660 int *unit, double *width, double *height) |
| 630 { | 661 { |
| 631 if (png_ptr != NULL && info_ptr != NULL && | 662 if (png_ptr != NULL && info_ptr != NULL && |
| 632 (info_ptr->valid & PNG_INFO_sCAL)) | 663 (info_ptr->valid & PNG_INFO_sCAL)) |
| 633 { | 664 { |
| 634 *unit = info_ptr->scal_unit; | 665 *unit = info_ptr->scal_unit; |
| 635 *width = info_ptr->scal_pixel_width; | 666 *width = info_ptr->scal_pixel_width; |
| 636 *height = info_ptr->scal_pixel_height; | 667 *height = info_ptr->scal_pixel_height; |
| 637 return (PNG_INFO_sCAL); | 668 return (PNG_INFO_sCAL); |
| 638 } | 669 } |
| 639 return(0); | 670 return(0); |
| 640 } | 671 } |
| 641 #else | 672 #else |
| 642 #ifdef PNG_FIXED_POINT_SUPPORTED | 673 #ifdef PNG_FIXED_POINT_SUPPORTED |
| 643 png_uint_32 PNGAPI | 674 png_uint_32 PNGAPI |
| 644 png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr, | 675 png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr, |
| 645 int *unit, png_charpp width, png_charpp height) | 676 int *unit, png_charpp width, png_charpp height) |
| 646 { | 677 { |
| 647 if (png_ptr != NULL && info_ptr != NULL && | 678 if (png_ptr != NULL && info_ptr != NULL && |
| 648 (info_ptr->valid & PNG_INFO_sCAL)) | 679 (info_ptr->valid & PNG_INFO_sCAL)) |
| 649 { | 680 { |
| 650 *unit = info_ptr->scal_unit; | 681 *unit = info_ptr->scal_unit; |
| 651 *width = info_ptr->scal_s_width; | 682 *width = info_ptr->scal_s_width; |
| 652 *height = info_ptr->scal_s_height; | 683 *height = info_ptr->scal_s_height; |
| 653 return (PNG_INFO_sCAL); | 684 return (PNG_INFO_sCAL); |
| 654 } | 685 } |
| 655 return(0); | 686 return(0); |
| 656 } | 687 } |
| 657 #endif | 688 #endif |
| 658 #endif | 689 #endif |
| 659 #endif | 690 #endif |
| 660 | 691 |
| 661 #if defined(PNG_pHYs_SUPPORTED) | 692 #if defined(PNG_pHYs_SUPPORTED) |
| 662 png_uint_32 PNGAPI | 693 png_uint_32 PNGAPI |
| 663 png_get_pHYs(png_structp png_ptr, png_infop info_ptr, | 694 png_get_pHYs(png_structp png_ptr, png_infop info_ptr, |
| 664 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) | 695 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) |
| 665 { | 696 { |
| 666 png_uint_32 retval = 0; | 697 png_uint_32 retval = 0; |
| 667 | 698 |
| 668 if (png_ptr != NULL && info_ptr != NULL && | 699 if (png_ptr != NULL && info_ptr != NULL && |
| 669 (info_ptr->valid & PNG_INFO_pHYs)) | 700 (info_ptr->valid & PNG_INFO_pHYs)) |
| 670 { | 701 { |
| 671 png_debug1(1, "in %s retrieval function", "pHYs"); | 702 png_debug1(1, "in %s retrieval function", "pHYs"); |
| 703 |
| 672 if (res_x != NULL) | 704 if (res_x != NULL) |
| 673 { | 705 { |
| 674 *res_x = info_ptr->x_pixels_per_unit; | 706 *res_x = info_ptr->x_pixels_per_unit; |
| 675 retval |= PNG_INFO_pHYs; | 707 retval |= PNG_INFO_pHYs; |
| 676 } | 708 } |
| 709 |
| 677 if (res_y != NULL) | 710 if (res_y != NULL) |
| 678 { | 711 { |
| 679 *res_y = info_ptr->y_pixels_per_unit; | 712 *res_y = info_ptr->y_pixels_per_unit; |
| 680 retval |= PNG_INFO_pHYs; | 713 retval |= PNG_INFO_pHYs; |
| 681 } | 714 } |
| 715 |
| 682 if (unit_type != NULL) | 716 if (unit_type != NULL) |
| 683 { | 717 { |
| 684 *unit_type = (int)info_ptr->phys_unit_type; | 718 *unit_type = (int)info_ptr->phys_unit_type; |
| 685 retval |= PNG_INFO_pHYs; | 719 retval |= PNG_INFO_pHYs; |
| 686 } | 720 } |
| 687 } | 721 } |
| 688 return (retval); | 722 return (retval); |
| 689 } | 723 } |
| 690 #endif | 724 #endif |
| 691 | 725 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 #if defined(PNG_TEXT_SUPPORTED) | 757 #if defined(PNG_TEXT_SUPPORTED) |
| 724 png_uint_32 PNGAPI | 758 png_uint_32 PNGAPI |
| 725 png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, | 759 png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, |
| 726 int *num_text) | 760 int *num_text) |
| 727 { | 761 { |
| 728 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) | 762 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) |
| 729 { | 763 { |
| 730 png_debug1(1, "in %s retrieval function", | 764 png_debug1(1, "in %s retrieval function", |
| 731 (png_ptr->chunk_name[0] == '\0' ? "text" | 765 (png_ptr->chunk_name[0] == '\0' ? "text" |
| 732 : (png_const_charp)png_ptr->chunk_name)); | 766 : (png_const_charp)png_ptr->chunk_name)); |
| 767 |
| 733 if (text_ptr != NULL) | 768 if (text_ptr != NULL) |
| 734 *text_ptr = info_ptr->text; | 769 *text_ptr = info_ptr->text; |
| 770 |
| 735 if (num_text != NULL) | 771 if (num_text != NULL) |
| 736 *num_text = info_ptr->num_text; | 772 *num_text = info_ptr->num_text; |
| 773 |
| 737 return ((png_uint_32)info_ptr->num_text); | 774 return ((png_uint_32)info_ptr->num_text); |
| 738 } | 775 } |
| 739 if (num_text != NULL) | 776 if (num_text != NULL) |
| 740 *num_text = 0; | 777 *num_text = 0; |
| 741 return(0); | 778 return(0); |
| 742 } | 779 } |
| 743 #endif | 780 #endif |
| 744 | 781 |
| 745 #if defined(PNG_tIME_SUPPORTED) | 782 #if defined(PNG_tIME_SUPPORTED) |
| 746 png_uint_32 PNGAPI | 783 png_uint_32 PNGAPI |
| (...skipping 19 matching lines...) Expand all Loading... |
| 766 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) | 803 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) |
| 767 { | 804 { |
| 768 png_debug1(1, "in %s retrieval function", "tRNS"); | 805 png_debug1(1, "in %s retrieval function", "tRNS"); |
| 769 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) | 806 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) |
| 770 { | 807 { |
| 771 if (trans != NULL) | 808 if (trans != NULL) |
| 772 { | 809 { |
| 773 *trans = info_ptr->trans; | 810 *trans = info_ptr->trans; |
| 774 retval |= PNG_INFO_tRNS; | 811 retval |= PNG_INFO_tRNS; |
| 775 } | 812 } |
| 813 |
| 776 if (trans_values != NULL) | 814 if (trans_values != NULL) |
| 777 *trans_values = &(info_ptr->trans_values); | 815 *trans_values = &(info_ptr->trans_values); |
| 778 } | 816 } |
| 779 else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ | 817 else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ |
| 780 { | 818 { |
| 781 if (trans_values != NULL) | 819 if (trans_values != NULL) |
| 782 { | 820 { |
| 783 *trans_values = &(info_ptr->trans_values); | 821 *trans_values = &(info_ptr->trans_values); |
| 784 retval |= PNG_INFO_tRNS; | 822 retval |= PNG_INFO_tRNS; |
| 785 } | 823 } |
| 824 |
| 786 if (trans != NULL) | 825 if (trans != NULL) |
| 787 *trans = NULL; | 826 *trans = NULL; |
| 788 } | 827 } |
| 789 if (num_trans != NULL) | 828 if (num_trans != NULL) |
| 790 { | 829 { |
| 791 *num_trans = info_ptr->num_trans; | 830 *num_trans = info_ptr->num_trans; |
| 792 retval |= PNG_INFO_tRNS; | 831 retval |= PNG_INFO_tRNS; |
| 793 } | 832 } |
| 794 } | 833 } |
| 795 return (retval); | 834 return (retval); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 #ifdef PNG_WRITE_SUPPORTED | 868 #ifdef PNG_WRITE_SUPPORTED |
| 830 png_uint_32 PNGAPI | 869 png_uint_32 PNGAPI |
| 831 png_get_compression_buffer_size(png_structp png_ptr) | 870 png_get_compression_buffer_size(png_structp png_ptr) |
| 832 { | 871 { |
| 833 return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L); | 872 return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L); |
| 834 } | 873 } |
| 835 #endif | 874 #endif |
| 836 | 875 |
| 837 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED | 876 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED |
| 838 #ifndef PNG_1_0_X | 877 #ifndef PNG_1_0_X |
| 839 /* this function was added to libpng 1.2.0 and should exist by default */ | 878 /* This function was added to libpng 1.2.0 and should exist by default */ |
| 840 png_uint_32 PNGAPI | 879 png_uint_32 PNGAPI |
| 841 png_get_asm_flags (png_structp png_ptr) | 880 png_get_asm_flags (png_structp png_ptr) |
| 842 { | 881 { |
| 843 /* obsolete, to be removed from libpng-1.4.0 */ | 882 /* Obsolete, to be removed from libpng-1.4.0 */ |
| 844 return (png_ptr? 0L: 0L); | 883 return (png_ptr? 0L: 0L); |
| 845 } | 884 } |
| 846 | 885 |
| 847 /* this function was added to libpng 1.2.0 and should exist by default */ | 886 /* This function was added to libpng 1.2.0 and should exist by default */ |
| 848 png_uint_32 PNGAPI | 887 png_uint_32 PNGAPI |
| 849 png_get_asm_flagmask (int flag_select) | 888 png_get_asm_flagmask (int flag_select) |
| 850 { | 889 { |
| 851 /* obsolete, to be removed from libpng-1.4.0 */ | 890 /* Obsolete, to be removed from libpng-1.4.0 */ |
| 852 flag_select=flag_select; | 891 flag_select=flag_select; |
| 853 return 0L; | 892 return 0L; |
| 854 } | 893 } |
| 855 | 894 |
| 856 /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ | 895 /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ |
| 857 /* this function was added to libpng 1.2.0 */ | 896 /* This function was added to libpng 1.2.0 */ |
| 858 png_uint_32 PNGAPI | 897 png_uint_32 PNGAPI |
| 859 png_get_mmx_flagmask (int flag_select, int *compilerID) | 898 png_get_mmx_flagmask (int flag_select, int *compilerID) |
| 860 { | 899 { |
| 861 /* obsolete, to be removed from libpng-1.4.0 */ | 900 /* Obsolete, to be removed from libpng-1.4.0 */ |
| 862 flag_select=flag_select; | 901 flag_select=flag_select; |
| 863 *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */ | 902 *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */ |
| 864 return 0L; | 903 return 0L; |
| 865 } | 904 } |
| 866 | 905 |
| 867 /* this function was added to libpng 1.2.0 */ | 906 /* This function was added to libpng 1.2.0 */ |
| 868 png_byte PNGAPI | 907 png_byte PNGAPI |
| 869 png_get_mmx_bitdepth_threshold (png_structp png_ptr) | 908 png_get_mmx_bitdepth_threshold (png_structp png_ptr) |
| 870 { | 909 { |
| 871 /* obsolete, to be removed from libpng-1.4.0 */ | 910 /* Obsolete, to be removed from libpng-1.4.0 */ |
| 872 return (png_ptr? 0: 0); | 911 return (png_ptr? 0: 0); |
| 873 } | 912 } |
| 874 | 913 |
| 875 /* this function was added to libpng 1.2.0 */ | 914 /* This function was added to libpng 1.2.0 */ |
| 876 png_uint_32 PNGAPI | 915 png_uint_32 PNGAPI |
| 877 png_get_mmx_rowbytes_threshold (png_structp png_ptr) | 916 png_get_mmx_rowbytes_threshold (png_structp png_ptr) |
| 878 { | 917 { |
| 879 /* obsolete, to be removed from libpng-1.4.0 */ | 918 /* Obsolete, to be removed from libpng-1.4.0 */ |
| 880 return (png_ptr? 0L: 0L); | 919 return (png_ptr? 0L: 0L); |
| 881 } | 920 } |
| 882 #endif /* ?PNG_1_0_X */ | 921 #endif /* ?PNG_1_0_X */ |
| 883 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ | 922 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ |
| 884 | 923 |
| 885 #ifdef PNG_SET_USER_LIMITS_SUPPORTED | 924 #ifdef PNG_SET_USER_LIMITS_SUPPORTED |
| 886 /* These functions were added to libpng 1.2.6 */ | 925 /* These functions were added to libpng 1.2.6 */ |
| 887 png_uint_32 PNGAPI | 926 png_uint_32 PNGAPI |
| 888 png_get_user_width_max (png_structp png_ptr) | 927 png_get_user_width_max (png_structp png_ptr) |
| 889 { | 928 { |
| 890 return (png_ptr? png_ptr->user_width_max : 0); | 929 return (png_ptr? png_ptr->user_width_max : 0); |
| 891 } | 930 } |
| 892 png_uint_32 PNGAPI | 931 png_uint_32 PNGAPI |
| 893 png_get_user_height_max (png_structp png_ptr) | 932 png_get_user_height_max (png_structp png_ptr) |
| 894 { | 933 { |
| 895 return (png_ptr? png_ptr->user_height_max : 0); | 934 return (png_ptr? png_ptr->user_height_max : 0); |
| 896 } | 935 } |
| 897 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ | 936 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ |
| 898 | 937 |
| 899 | 938 |
| 900 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ | 939 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ |
| OLD | NEW |