OLD | NEW |
| 1 |
1 /* pngget.c - retrieval of values from info struct | 2 /* pngget.c - retrieval of values from info struct |
2 * | 3 * |
3 * Last changed in libpng 1.6.1 [March 28, 2013] | 4 * Last changed in libpng 1.6.17 [March 26, 2015] |
4 * Copyright (c) 1998-2013 Glenn Randers-Pehrson | 5 * Copyright (c) 1998-2015 Glenn Randers-Pehrson |
5 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) | 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) |
6 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) | 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) |
7 * | 8 * |
8 * This code is released under the libpng license. | 9 * This code is released under the libpng license. |
9 * For conditions of distribution and use, see the disclaimer | 10 * For conditions of distribution and use, see the disclaimer |
10 * and license in png.h | 11 * and license in png.h |
11 * | 12 * |
12 */ | 13 */ |
13 | 14 |
14 #include "pngpriv.h" | 15 #include "pngpriv.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 return info_ptr->compression_type; | 109 return info_ptr->compression_type; |
109 | 110 |
110 return (0); | 111 return (0); |
111 } | 112 } |
112 | 113 |
113 png_uint_32 PNGAPI | 114 png_uint_32 PNGAPI |
114 png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp | 115 png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp |
115 info_ptr) | 116 info_ptr) |
116 { | 117 { |
117 #ifdef PNG_pHYs_SUPPORTED | 118 #ifdef PNG_pHYs_SUPPORTED |
118 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) | 119 if (png_ptr != NULL && info_ptr != NULL && |
| 120 (info_ptr->valid & PNG_INFO_pHYs) != 0) |
119 { | 121 { |
120 png_debug1(1, "in %s retrieval function", | 122 png_debug1(1, "in %s retrieval function", |
121 "png_get_x_pixels_per_meter"); | 123 "png_get_x_pixels_per_meter"); |
122 | 124 |
123 if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) | 125 if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) |
124 return (info_ptr->x_pixels_per_unit); | 126 return (info_ptr->x_pixels_per_unit); |
125 } | 127 } |
| 128 #else |
| 129 PNG_UNUSED(png_ptr) |
| 130 PNG_UNUSED(info_ptr) |
126 #endif | 131 #endif |
127 | 132 |
128 return (0); | 133 return (0); |
129 } | 134 } |
130 | 135 |
131 png_uint_32 PNGAPI | 136 png_uint_32 PNGAPI |
132 png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp | 137 png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp |
133 info_ptr) | 138 info_ptr) |
134 { | 139 { |
135 #ifdef PNG_pHYs_SUPPORTED | 140 #ifdef PNG_pHYs_SUPPORTED |
136 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) | 141 if (png_ptr != NULL && info_ptr != NULL && |
| 142 (info_ptr->valid & PNG_INFO_pHYs) != 0) |
137 { | 143 { |
138 png_debug1(1, "in %s retrieval function", | 144 png_debug1(1, "in %s retrieval function", |
139 "png_get_y_pixels_per_meter"); | 145 "png_get_y_pixels_per_meter"); |
140 | 146 |
141 if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) | 147 if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) |
142 return (info_ptr->y_pixels_per_unit); | 148 return (info_ptr->y_pixels_per_unit); |
143 } | 149 } |
| 150 #else |
| 151 PNG_UNUSED(png_ptr) |
| 152 PNG_UNUSED(info_ptr) |
144 #endif | 153 #endif |
145 | 154 |
146 return (0); | 155 return (0); |
147 } | 156 } |
148 | 157 |
149 png_uint_32 PNGAPI | 158 png_uint_32 PNGAPI |
150 png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr) | 159 png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr) |
151 { | 160 { |
152 #ifdef PNG_pHYs_SUPPORTED | 161 #ifdef PNG_pHYs_SUPPORTED |
153 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) | 162 if (png_ptr != NULL && info_ptr != NULL && |
| 163 (info_ptr->valid & PNG_INFO_pHYs) != 0) |
154 { | 164 { |
155 png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter"); | 165 png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter"); |
156 | 166 |
157 if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER && | 167 if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER && |
158 info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit) | 168 info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit) |
159 return (info_ptr->x_pixels_per_unit); | 169 return (info_ptr->x_pixels_per_unit); |
160 } | 170 } |
| 171 #else |
| 172 PNG_UNUSED(png_ptr) |
| 173 PNG_UNUSED(info_ptr) |
161 #endif | 174 #endif |
162 | 175 |
163 return (0); | 176 return (0); |
164 } | 177 } |
165 | 178 |
166 #ifdef PNG_FLOATING_POINT_SUPPORTED | 179 #ifdef PNG_FLOATING_POINT_SUPPORTED |
167 float PNGAPI | 180 float PNGAPI |
168 png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp | 181 png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp |
169 info_ptr) | 182 info_ptr) |
170 { | 183 { |
171 #ifdef PNG_READ_pHYs_SUPPORTED | 184 #ifdef PNG_READ_pHYs_SUPPORTED |
172 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) | 185 if (png_ptr != NULL && info_ptr != NULL && |
| 186 (info_ptr->valid & PNG_INFO_pHYs) != 0) |
173 { | 187 { |
174 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); | 188 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); |
175 | 189 |
176 if (info_ptr->x_pixels_per_unit != 0) | 190 if (info_ptr->x_pixels_per_unit != 0) |
177 return ((float)((float)info_ptr->y_pixels_per_unit | 191 return ((float)((float)info_ptr->y_pixels_per_unit |
178 /(float)info_ptr->x_pixels_per_unit)); | 192 /(float)info_ptr->x_pixels_per_unit)); |
179 } | 193 } |
180 #else | 194 #else |
181 PNG_UNUSED(png_ptr) | 195 PNG_UNUSED(png_ptr) |
182 PNG_UNUSED(info_ptr) | 196 PNG_UNUSED(info_ptr) |
183 #endif | 197 #endif |
184 | 198 |
185 return ((float)0.0); | 199 return ((float)0.0); |
186 } | 200 } |
187 #endif | 201 #endif |
188 | 202 |
189 #ifdef PNG_FIXED_POINT_SUPPORTED | 203 #ifdef PNG_FIXED_POINT_SUPPORTED |
190 png_fixed_point PNGAPI | 204 png_fixed_point PNGAPI |
191 png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr, | 205 png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr, |
192 png_const_inforp info_ptr) | 206 png_const_inforp info_ptr) |
193 { | 207 { |
194 #ifdef PNG_READ_pHYs_SUPPORTED | 208 #ifdef PNG_READ_pHYs_SUPPORTED |
195 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs) | 209 if (png_ptr != NULL && info_ptr != NULL && |
196 && info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 | 210 (info_ptr->valid & PNG_INFO_pHYs) != 0 && |
197 && info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX | 211 info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 && |
198 && info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX) | 212 info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX && |
| 213 info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX) |
199 { | 214 { |
200 png_fixed_point res; | 215 png_fixed_point res; |
201 | 216 |
202 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio_fixed"); | 217 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio_fixed"); |
203 | 218 |
204 /* The following casts work because a PNG 4 byte integer only has a valid | 219 /* The following casts work because a PNG 4 byte integer only has a valid |
205 * range of 0..2^31-1; otherwise the cast might overflow. | 220 * range of 0..2^31-1; otherwise the cast might overflow. |
206 */ | 221 */ |
207 if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1, | 222 if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1, |
208 (png_int_32)info_ptr->x_pixels_per_unit)) | 223 (png_int_32)info_ptr->x_pixels_per_unit) != 0) |
209 return res; | 224 return res; |
210 } | 225 } |
211 #else | 226 #else |
212 PNG_UNUSED(png_ptr) | 227 PNG_UNUSED(png_ptr) |
213 PNG_UNUSED(info_ptr) | 228 PNG_UNUSED(info_ptr) |
214 #endif | 229 #endif |
215 | 230 |
216 return 0; | 231 return 0; |
217 } | 232 } |
218 #endif | 233 #endif |
219 | 234 |
220 png_int_32 PNGAPI | 235 png_int_32 PNGAPI |
221 png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) | 236 png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) |
222 { | 237 { |
223 #ifdef PNG_oFFs_SUPPORTED | 238 #ifdef PNG_oFFs_SUPPORTED |
224 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) | 239 if (png_ptr != NULL && info_ptr != NULL && |
| 240 (info_ptr->valid & PNG_INFO_oFFs) != 0) |
225 { | 241 { |
226 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); | 242 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); |
227 | 243 |
228 if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) | 244 if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) |
229 return (info_ptr->x_offset); | 245 return (info_ptr->x_offset); |
230 } | 246 } |
| 247 #else |
| 248 PNG_UNUSED(png_ptr) |
| 249 PNG_UNUSED(info_ptr) |
231 #endif | 250 #endif |
232 | 251 |
233 return (0); | 252 return (0); |
234 } | 253 } |
235 | 254 |
236 png_int_32 PNGAPI | 255 png_int_32 PNGAPI |
237 png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) | 256 png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) |
238 { | 257 { |
239 #ifdef PNG_oFFs_SUPPORTED | 258 #ifdef PNG_oFFs_SUPPORTED |
240 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) | 259 if (png_ptr != NULL && info_ptr != NULL && |
| 260 (info_ptr->valid & PNG_INFO_oFFs) != 0) |
241 { | 261 { |
242 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); | 262 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); |
243 | 263 |
244 if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) | 264 if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) |
245 return (info_ptr->y_offset); | 265 return (info_ptr->y_offset); |
246 } | 266 } |
| 267 #else |
| 268 PNG_UNUSED(png_ptr) |
| 269 PNG_UNUSED(info_ptr) |
247 #endif | 270 #endif |
248 | 271 |
249 return (0); | 272 return (0); |
250 } | 273 } |
251 | 274 |
252 png_int_32 PNGAPI | 275 png_int_32 PNGAPI |
253 png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) | 276 png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) |
254 { | 277 { |
255 #ifdef PNG_oFFs_SUPPORTED | 278 #ifdef PNG_oFFs_SUPPORTED |
256 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) | 279 if (png_ptr != NULL && info_ptr != NULL && |
| 280 (info_ptr->valid & PNG_INFO_oFFs) != 0) |
257 { | 281 { |
258 png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels"); | 282 png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels"); |
259 | 283 |
260 if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) | 284 if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) |
261 return (info_ptr->x_offset); | 285 return (info_ptr->x_offset); |
262 } | 286 } |
| 287 #else |
| 288 PNG_UNUSED(png_ptr) |
| 289 PNG_UNUSED(info_ptr) |
263 #endif | 290 #endif |
264 | 291 |
265 return (0); | 292 return (0); |
266 } | 293 } |
267 | 294 |
268 png_int_32 PNGAPI | 295 png_int_32 PNGAPI |
269 png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) | 296 png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) |
270 { | 297 { |
271 #ifdef PNG_oFFs_SUPPORTED | 298 #ifdef PNG_oFFs_SUPPORTED |
272 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) | 299 if (png_ptr != NULL && info_ptr != NULL && |
| 300 (info_ptr->valid & PNG_INFO_oFFs) != 0) |
273 { | 301 { |
274 png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels"); | 302 png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels"); |
275 | 303 |
276 if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) | 304 if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) |
277 return (info_ptr->y_offset); | 305 return (info_ptr->y_offset); |
278 } | 306 } |
| 307 #else |
| 308 PNG_UNUSED(png_ptr) |
| 309 PNG_UNUSED(info_ptr) |
279 #endif | 310 #endif |
280 | 311 |
281 return (0); | 312 return (0); |
282 } | 313 } |
283 | 314 |
284 #ifdef PNG_INCH_CONVERSIONS_SUPPORTED | 315 #ifdef PNG_INCH_CONVERSIONS_SUPPORTED |
285 static png_uint_32 | 316 static png_uint_32 |
286 ppi_from_ppm(png_uint_32 ppm) | 317 ppi_from_ppm(png_uint_32 ppm) |
287 { | 318 { |
288 #if 0 | 319 #if 0 |
(...skipping 10 matching lines...) Expand all Loading... |
299 t1001 += t1001 >> 12; /* .000000000001001000000001001 */ | 330 t1001 += t1001 >> 12; /* .000000000001001000000001001 */ |
300 ppm += t1001; /* .000000000001001000001001001 */ | 331 ppm += t1001; /* .000000000001001000001001001 */ |
301 ppm += t1101; /* .110100000001001110101001001 */ | 332 ppm += t1101; /* .110100000001001110101001001 */ |
302 return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */ | 333 return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */ |
303 #else | 334 #else |
304 /* The argument is a PNG unsigned integer, so it is not permitted | 335 /* The argument is a PNG unsigned integer, so it is not permitted |
305 * to be bigger than 2^31. | 336 * to be bigger than 2^31. |
306 */ | 337 */ |
307 png_fixed_point result; | 338 png_fixed_point result; |
308 if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127, | 339 if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127, |
309 5000)) | 340 5000) != 0) |
310 return result; | 341 return result; |
311 | 342 |
312 /* Overflow. */ | 343 /* Overflow. */ |
313 return 0; | 344 return 0; |
314 #endif | 345 #endif |
315 } | 346 } |
316 | 347 |
317 png_uint_32 PNGAPI | 348 png_uint_32 PNGAPI |
318 png_get_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) | 349 png_get_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) |
319 { | 350 { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 } | 416 } |
386 #endif | 417 #endif |
387 | 418 |
388 #ifdef PNG_pHYs_SUPPORTED | 419 #ifdef PNG_pHYs_SUPPORTED |
389 png_uint_32 PNGAPI | 420 png_uint_32 PNGAPI |
390 png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr, | 421 png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr, |
391 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) | 422 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) |
392 { | 423 { |
393 png_uint_32 retval = 0; | 424 png_uint_32 retval = 0; |
394 | 425 |
395 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) | 426 if (png_ptr != NULL && info_ptr != NULL && |
| 427 (info_ptr->valid & PNG_INFO_pHYs) != 0) |
396 { | 428 { |
397 png_debug1(1, "in %s retrieval function", "pHYs"); | 429 png_debug1(1, "in %s retrieval function", "pHYs"); |
398 | 430 |
399 if (res_x != NULL) | 431 if (res_x != NULL) |
400 { | 432 { |
401 *res_x = info_ptr->x_pixels_per_unit; | 433 *res_x = info_ptr->x_pixels_per_unit; |
402 retval |= PNG_INFO_pHYs; | 434 retval |= PNG_INFO_pHYs; |
403 } | 435 } |
404 | 436 |
405 if (res_y != NULL) | 437 if (res_y != NULL) |
(...skipping 10 matching lines...) Expand all Loading... |
416 if (*unit_type == 1) | 448 if (*unit_type == 1) |
417 { | 449 { |
418 if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); | 450 if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); |
419 if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); | 451 if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); |
420 } | 452 } |
421 } | 453 } |
422 } | 454 } |
423 | 455 |
424 return (retval); | 456 return (retval); |
425 } | 457 } |
426 #endif /* PNG_pHYs_SUPPORTED */ | 458 #endif /* pHYs */ |
427 #endif /* PNG_INCH_CONVERSIONS_SUPPORTED */ | 459 #endif /* INCH_CONVERSIONS */ |
428 | 460 |
429 /* png_get_channels really belongs in here, too, but it's been around longer */ | 461 /* png_get_channels really belongs in here, too, but it's been around longer */ |
430 | 462 |
431 #endif /* PNG_EASY_ACCESS_SUPPORTED */ | 463 #endif /* EASY_ACCESS */ |
432 | 464 |
433 | 465 |
434 png_byte PNGAPI | 466 png_byte PNGAPI |
435 png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr) | 467 png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr) |
436 { | 468 { |
437 if (png_ptr != NULL && info_ptr != NULL) | 469 if (png_ptr != NULL && info_ptr != NULL) |
438 return(info_ptr->channels); | 470 return(info_ptr->channels); |
439 | 471 |
440 return (0); | 472 return (0); |
441 } | 473 } |
442 | 474 |
443 #ifdef PNG_READ_SUPPORTED | 475 #ifdef PNG_READ_SUPPORTED |
444 png_const_bytep PNGAPI | 476 png_const_bytep PNGAPI |
445 png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr) | 477 png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr) |
446 { | 478 { |
447 if (png_ptr != NULL && info_ptr != NULL) | 479 if (png_ptr != NULL && info_ptr != NULL) |
448 return(info_ptr->signature); | 480 return(info_ptr->signature); |
449 | 481 |
450 return (NULL); | 482 return (NULL); |
451 } | 483 } |
452 #endif | 484 #endif |
453 | 485 |
454 #ifdef PNG_bKGD_SUPPORTED | 486 #ifdef PNG_bKGD_SUPPORTED |
455 png_uint_32 PNGAPI | 487 png_uint_32 PNGAPI |
456 png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr, | 488 png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr, |
457 png_color_16p *background) | 489 png_color_16p *background) |
458 { | 490 { |
459 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) | 491 if (png_ptr != NULL && info_ptr != NULL && |
460 && background != NULL) | 492 (info_ptr->valid & PNG_INFO_bKGD) != 0 && |
| 493 background != NULL) |
461 { | 494 { |
462 png_debug1(1, "in %s retrieval function", "bKGD"); | 495 png_debug1(1, "in %s retrieval function", "bKGD"); |
463 | 496 |
464 *background = &(info_ptr->background); | 497 *background = &(info_ptr->background); |
465 return (PNG_INFO_bKGD); | 498 return (PNG_INFO_bKGD); |
466 } | 499 } |
467 | 500 |
468 return (0); | 501 return (0); |
469 } | 502 } |
470 #endif | 503 #endif |
471 | 504 |
472 #ifdef PNG_cHRM_SUPPORTED | 505 #ifdef PNG_cHRM_SUPPORTED |
473 /* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the | 506 /* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the |
474 * same time to correct the rgb grayscale coefficient defaults obtained from the | 507 * same time to correct the rgb grayscale coefficient defaults obtained from the |
475 * cHRM chunk in 1.5.4 | 508 * cHRM chunk in 1.5.4 |
476 */ | 509 */ |
477 # ifdef PNG_FLOATING_POINT_SUPPORTED | 510 # ifdef PNG_FLOATING_POINT_SUPPORTED |
478 png_uint_32 PNGAPI | 511 png_uint_32 PNGAPI |
479 png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr, | 512 png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr, |
480 double *white_x, double *white_y, double *red_x, double *red_y, | 513 double *white_x, double *white_y, double *red_x, double *red_y, |
481 double *green_x, double *green_y, double *blue_x, double *blue_y) | 514 double *green_x, double *green_y, double *blue_x, double *blue_y) |
482 { | 515 { |
483 /* Quiet API change: this code used to only return the end points if a cHRM | 516 /* Quiet API change: this code used to only return the end points if a cHRM |
484 * chunk was present, but the end points can also come from iCCP or sRGB | 517 * chunk was present, but the end points can also come from iCCP or sRGB |
485 * chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and | 518 * chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and |
486 * the png_set_ APIs merely check that set end points are mutually | 519 * the png_set_ APIs merely check that set end points are mutually |
487 * consistent. | 520 * consistent. |
488 */ | 521 */ |
489 if (png_ptr != NULL && info_ptr != NULL && | 522 if (png_ptr != NULL && info_ptr != NULL && |
490 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) | 523 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) |
491 { | 524 { |
492 png_debug1(1, "in %s retrieval function", "cHRM"); | 525 png_debug1(1, "in %s retrieval function", "cHRM"); |
493 | 526 |
494 if (white_x != NULL) | 527 if (white_x != NULL) |
495 *white_x = png_float(png_ptr, | 528 *white_x = png_float(png_ptr, |
496 info_ptr->colorspace.end_points_xy.whitex, "cHRM white X"); | 529 info_ptr->colorspace.end_points_xy.whitex, "cHRM white X"); |
497 if (white_y != NULL) | 530 if (white_y != NULL) |
498 *white_y = png_float(png_ptr, | 531 *white_y = png_float(png_ptr, |
499 info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y"); | 532 info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y"); |
500 if (red_x != NULL) | 533 if (red_x != NULL) |
(...skipping 20 matching lines...) Expand all Loading... |
521 return (0); | 554 return (0); |
522 } | 555 } |
523 | 556 |
524 png_uint_32 PNGAPI | 557 png_uint_32 PNGAPI |
525 png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr, | 558 png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr, |
526 double *red_X, double *red_Y, double *red_Z, double *green_X, | 559 double *red_X, double *red_Y, double *red_Z, double *green_X, |
527 double *green_Y, double *green_Z, double *blue_X, double *blue_Y, | 560 double *green_Y, double *green_Z, double *blue_X, double *blue_Y, |
528 double *blue_Z) | 561 double *blue_Z) |
529 { | 562 { |
530 if (png_ptr != NULL && info_ptr != NULL && | 563 if (png_ptr != NULL && info_ptr != NULL && |
531 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) | 564 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) |
532 { | 565 { |
533 png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)"); | 566 png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)"); |
534 | 567 |
535 if (red_X != NULL) | 568 if (red_X != NULL) |
536 *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X, | 569 *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X, |
537 "cHRM red X"); | 570 "cHRM red X"); |
538 if (red_Y != NULL) | 571 if (red_Y != NULL) |
539 *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y, | 572 *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y, |
540 "cHRM red Y"); | 573 "cHRM red Y"); |
541 if (red_Z != NULL) | 574 if (red_Z != NULL) |
(...skipping 27 matching lines...) Expand all Loading... |
569 # ifdef PNG_FIXED_POINT_SUPPORTED | 602 # ifdef PNG_FIXED_POINT_SUPPORTED |
570 png_uint_32 PNGAPI | 603 png_uint_32 PNGAPI |
571 png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, | 604 png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, |
572 png_fixed_point *int_red_X, png_fixed_point *int_red_Y, | 605 png_fixed_point *int_red_X, png_fixed_point *int_red_Y, |
573 png_fixed_point *int_red_Z, png_fixed_point *int_green_X, | 606 png_fixed_point *int_red_Z, png_fixed_point *int_green_X, |
574 png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, | 607 png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, |
575 png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, | 608 png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, |
576 png_fixed_point *int_blue_Z) | 609 png_fixed_point *int_blue_Z) |
577 { | 610 { |
578 if (png_ptr != NULL && info_ptr != NULL && | 611 if (png_ptr != NULL && info_ptr != NULL && |
579 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) | 612 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) |
580 { | 613 { |
581 png_debug1(1, "in %s retrieval function", "cHRM_XYZ"); | 614 png_debug1(1, "in %s retrieval function", "cHRM_XYZ"); |
582 | 615 |
583 if (int_red_X != NULL) | 616 if (int_red_X != NULL) |
584 *int_red_X = info_ptr->colorspace.end_points_XYZ.red_X; | 617 *int_red_X = info_ptr->colorspace.end_points_XYZ.red_X; |
585 if (int_red_Y != NULL) | 618 if (int_red_Y != NULL) |
586 *int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y; | 619 *int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y; |
587 if (int_red_Z != NULL) | 620 if (int_red_Z != NULL) |
588 *int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z; | 621 *int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z; |
589 if (int_green_X != NULL) | 622 if (int_green_X != NULL) |
(...skipping 16 matching lines...) Expand all Loading... |
606 | 639 |
607 png_uint_32 PNGAPI | 640 png_uint_32 PNGAPI |
608 png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, | 641 png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, |
609 png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, | 642 png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, |
610 png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, | 643 png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, |
611 png_fixed_point *blue_x, png_fixed_point *blue_y) | 644 png_fixed_point *blue_x, png_fixed_point *blue_y) |
612 { | 645 { |
613 png_debug1(1, "in %s retrieval function", "cHRM"); | 646 png_debug1(1, "in %s retrieval function", "cHRM"); |
614 | 647 |
615 if (png_ptr != NULL && info_ptr != NULL && | 648 if (png_ptr != NULL && info_ptr != NULL && |
616 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) | 649 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) |
617 { | 650 { |
618 if (white_x != NULL) | 651 if (white_x != NULL) |
619 *white_x = info_ptr->colorspace.end_points_xy.whitex; | 652 *white_x = info_ptr->colorspace.end_points_xy.whitex; |
620 if (white_y != NULL) | 653 if (white_y != NULL) |
621 *white_y = info_ptr->colorspace.end_points_xy.whitey; | 654 *white_y = info_ptr->colorspace.end_points_xy.whitey; |
622 if (red_x != NULL) | 655 if (red_x != NULL) |
623 *red_x = info_ptr->colorspace.end_points_xy.redx; | 656 *red_x = info_ptr->colorspace.end_points_xy.redx; |
624 if (red_y != NULL) | 657 if (red_y != NULL) |
625 *red_y = info_ptr->colorspace.end_points_xy.redy; | 658 *red_y = info_ptr->colorspace.end_points_xy.redy; |
626 if (green_x != NULL) | 659 if (green_x != NULL) |
(...skipping 14 matching lines...) Expand all Loading... |
641 | 674 |
642 #ifdef PNG_gAMA_SUPPORTED | 675 #ifdef PNG_gAMA_SUPPORTED |
643 # ifdef PNG_FIXED_POINT_SUPPORTED | 676 # ifdef PNG_FIXED_POINT_SUPPORTED |
644 png_uint_32 PNGAPI | 677 png_uint_32 PNGAPI |
645 png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, | 678 png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, |
646 png_fixed_point *file_gamma) | 679 png_fixed_point *file_gamma) |
647 { | 680 { |
648 png_debug1(1, "in %s retrieval function", "gAMA"); | 681 png_debug1(1, "in %s retrieval function", "gAMA"); |
649 | 682 |
650 if (png_ptr != NULL && info_ptr != NULL && | 683 if (png_ptr != NULL && info_ptr != NULL && |
651 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) && | 684 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 && |
652 file_gamma != NULL) | 685 file_gamma != NULL) |
653 { | 686 { |
654 *file_gamma = info_ptr->colorspace.gamma; | 687 *file_gamma = info_ptr->colorspace.gamma; |
655 return (PNG_INFO_gAMA); | 688 return (PNG_INFO_gAMA); |
656 } | 689 } |
657 | 690 |
658 return (0); | 691 return (0); |
659 } | 692 } |
660 # endif | 693 # endif |
661 | 694 |
662 # ifdef PNG_FLOATING_POINT_SUPPORTED | 695 # ifdef PNG_FLOATING_POINT_SUPPORTED |
663 png_uint_32 PNGAPI | 696 png_uint_32 PNGAPI |
664 png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr, | 697 png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr, |
665 double *file_gamma) | 698 double *file_gamma) |
666 { | 699 { |
667 png_debug1(1, "in %s retrieval function", "gAMA(float)"); | 700 png_debug1(1, "in %s retrieval function", "gAMA(float)"); |
668 | 701 |
669 if (png_ptr != NULL && info_ptr != NULL && | 702 if (png_ptr != NULL && info_ptr != NULL && |
670 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) && | 703 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 && |
671 file_gamma != NULL) | 704 file_gamma != NULL) |
672 { | 705 { |
673 *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma, | 706 *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma, |
674 "png_get_gAMA"); | 707 "png_get_gAMA"); |
675 return (PNG_INFO_gAMA); | 708 return (PNG_INFO_gAMA); |
676 } | 709 } |
677 | 710 |
678 return (0); | 711 return (0); |
679 } | 712 } |
680 # endif | 713 # endif |
681 #endif | 714 #endif |
682 | 715 |
683 #ifdef PNG_sRGB_SUPPORTED | 716 #ifdef PNG_sRGB_SUPPORTED |
684 png_uint_32 PNGAPI | 717 png_uint_32 PNGAPI |
685 png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr, | 718 png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr, |
686 int *file_srgb_intent) | 719 int *file_srgb_intent) |
687 { | 720 { |
688 png_debug1(1, "in %s retrieval function", "sRGB"); | 721 png_debug1(1, "in %s retrieval function", "sRGB"); |
689 | 722 |
690 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) | 723 if (png_ptr != NULL && info_ptr != NULL && |
691 && file_srgb_intent != NULL) | 724 (info_ptr->valid & PNG_INFO_sRGB) != 0 && file_srgb_intent != NULL) |
692 { | 725 { |
693 *file_srgb_intent = info_ptr->colorspace.rendering_intent; | 726 *file_srgb_intent = info_ptr->colorspace.rendering_intent; |
694 return (PNG_INFO_sRGB); | 727 return (PNG_INFO_sRGB); |
695 } | 728 } |
696 | 729 |
697 return (0); | 730 return (0); |
698 } | 731 } |
699 #endif | 732 #endif |
700 | 733 |
701 #ifdef PNG_iCCP_SUPPORTED | 734 #ifdef PNG_iCCP_SUPPORTED |
702 png_uint_32 PNGAPI | 735 png_uint_32 PNGAPI |
703 png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, | 736 png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, |
704 png_charpp name, int *compression_type, | 737 png_charpp name, int *compression_type, |
705 png_bytepp profile, png_uint_32 *proflen) | 738 png_bytepp profile, png_uint_32 *proflen) |
706 { | 739 { |
707 png_debug1(1, "in %s retrieval function", "iCCP"); | 740 png_debug1(1, "in %s retrieval function", "iCCP"); |
708 | 741 |
709 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) | 742 if (png_ptr != NULL && info_ptr != NULL && |
710 && name != NULL && compression_type != NULL && profile != NULL && | 743 (info_ptr->valid & PNG_INFO_iCCP) != 0 && |
711 » » proflen != NULL) | 744 name != NULL && compression_type != NULL && profile != NULL && |
| 745 proflen != NULL) |
712 { | 746 { |
713 *name = info_ptr->iccp_name; | 747 *name = info_ptr->iccp_name; |
714 *profile = info_ptr->iccp_profile; | 748 *profile = info_ptr->iccp_profile; |
715 *proflen = png_get_uint_32(info_ptr->iccp_profile); | 749 *proflen = png_get_uint_32(info_ptr->iccp_profile); |
716 /* This is somewhat irrelevant since the profile data returned has | 750 /* This is somewhat irrelevant since the profile data returned has |
717 * actually been uncompressed. | 751 * actually been uncompressed. |
718 */ | 752 */ |
719 *compression_type = PNG_COMPRESSION_TYPE_BASE; | 753 *compression_type = PNG_COMPRESSION_TYPE_BASE; |
720 return (PNG_INFO_iCCP); | 754 return (PNG_INFO_iCCP); |
721 } | 755 } |
(...skipping 17 matching lines...) Expand all Loading... |
739 } | 773 } |
740 #endif | 774 #endif |
741 | 775 |
742 #ifdef PNG_hIST_SUPPORTED | 776 #ifdef PNG_hIST_SUPPORTED |
743 png_uint_32 PNGAPI | 777 png_uint_32 PNGAPI |
744 png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr, | 778 png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr, |
745 png_uint_16p *hist) | 779 png_uint_16p *hist) |
746 { | 780 { |
747 png_debug1(1, "in %s retrieval function", "hIST"); | 781 png_debug1(1, "in %s retrieval function", "hIST"); |
748 | 782 |
749 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) | 783 if (png_ptr != NULL && info_ptr != NULL && |
750 && hist != NULL) | 784 (info_ptr->valid & PNG_INFO_hIST) != 0 && hist != NULL) |
751 { | 785 { |
752 *hist = info_ptr->hist; | 786 *hist = info_ptr->hist; |
753 return (PNG_INFO_hIST); | 787 return (PNG_INFO_hIST); |
754 } | 788 } |
755 | 789 |
756 return (0); | 790 return (0); |
757 } | 791 } |
758 #endif | 792 #endif |
759 | 793 |
760 png_uint_32 PNGAPI | 794 png_uint_32 PNGAPI |
761 png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr, | 795 png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr, |
762 png_uint_32 *width, png_uint_32 *height, int *bit_depth, | 796 png_uint_32 *width, png_uint_32 *height, int *bit_depth, |
763 int *color_type, int *interlace_type, int *compression_type, | 797 int *color_type, int *interlace_type, int *compression_type, |
764 int *filter_type) | 798 int *filter_type) |
765 { | 799 { |
766 png_debug1(1, "in %s retrieval function", "IHDR"); | 800 png_debug1(1, "in %s retrieval function", "IHDR"); |
767 | 801 |
768 if (png_ptr == NULL || info_ptr == NULL || width == NULL || | 802 if (png_ptr == NULL || info_ptr == NULL) |
769 height == NULL || bit_depth == NULL || color_type == NULL) | |
770 return (0); | 803 return (0); |
771 | 804 |
772 *width = info_ptr->width; | 805 if (width != NULL) |
773 *height = info_ptr->height; | 806 *width = info_ptr->width; |
774 *bit_depth = info_ptr->bit_depth; | 807 |
775 *color_type = info_ptr->color_type; | 808 if (height != NULL) |
| 809 *height = info_ptr->height; |
| 810 |
| 811 if (bit_depth != NULL) |
| 812 *bit_depth = info_ptr->bit_depth; |
| 813 |
| 814 if (color_type != NULL) |
| 815 *color_type = info_ptr->color_type; |
776 | 816 |
777 if (compression_type != NULL) | 817 if (compression_type != NULL) |
778 *compression_type = info_ptr->compression_type; | 818 *compression_type = info_ptr->compression_type; |
779 | 819 |
780 if (filter_type != NULL) | 820 if (filter_type != NULL) |
781 *filter_type = info_ptr->filter_type; | 821 *filter_type = info_ptr->filter_type; |
782 | 822 |
783 if (interlace_type != NULL) | 823 if (interlace_type != NULL) |
784 *interlace_type = info_ptr->interlace_type; | 824 *interlace_type = info_ptr->interlace_type; |
785 | 825 |
786 /* This is redundant if we can be sure that the info_ptr values were all | 826 /* This is redundant if we can be sure that the info_ptr values were all |
787 * assigned in png_set_IHDR(). We do the check anyhow in case an | 827 * assigned in png_set_IHDR(). We do the check anyhow in case an |
788 * application has ignored our advice not to mess with the members | 828 * application has ignored our advice not to mess with the members |
789 * of info_ptr directly. | 829 * of info_ptr directly. |
790 */ | 830 */ |
791 png_check_IHDR(png_ptr, info_ptr->width, info_ptr->height, | 831 png_check_IHDR(png_ptr, info_ptr->width, info_ptr->height, |
792 info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, | 832 info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, |
793 info_ptr->compression_type, info_ptr->filter_type); | 833 info_ptr->compression_type, info_ptr->filter_type); |
794 | 834 |
795 return (1); | 835 return (1); |
796 } | 836 } |
797 | 837 |
798 #ifdef PNG_oFFs_SUPPORTED | 838 #ifdef PNG_oFFs_SUPPORTED |
799 png_uint_32 PNGAPI | 839 png_uint_32 PNGAPI |
800 png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr, | 840 png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr, |
801 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) | 841 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) |
802 { | 842 { |
803 png_debug1(1, "in %s retrieval function", "oFFs"); | 843 png_debug1(1, "in %s retrieval function", "oFFs"); |
804 | 844 |
805 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) | 845 if (png_ptr != NULL && info_ptr != NULL && |
806 && offset_x != NULL && offset_y != NULL && unit_type != NULL) | 846 (info_ptr->valid & PNG_INFO_oFFs) != 0 && |
| 847 offset_x != NULL && offset_y != NULL && unit_type != NULL) |
807 { | 848 { |
808 *offset_x = info_ptr->x_offset; | 849 *offset_x = info_ptr->x_offset; |
809 *offset_y = info_ptr->y_offset; | 850 *offset_y = info_ptr->y_offset; |
810 *unit_type = (int)info_ptr->offset_unit_type; | 851 *unit_type = (int)info_ptr->offset_unit_type; |
811 return (PNG_INFO_oFFs); | 852 return (PNG_INFO_oFFs); |
812 } | 853 } |
813 | 854 |
814 return (0); | 855 return (0); |
815 } | 856 } |
816 #endif | 857 #endif |
817 | 858 |
818 #ifdef PNG_pCAL_SUPPORTED | 859 #ifdef PNG_pCAL_SUPPORTED |
819 png_uint_32 PNGAPI | 860 png_uint_32 PNGAPI |
820 png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, | 861 png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, |
821 png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, | 862 png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, |
822 png_charp *units, png_charpp *params) | 863 png_charp *units, png_charpp *params) |
823 { | 864 { |
824 png_debug1(1, "in %s retrieval function", "pCAL"); | 865 png_debug1(1, "in %s retrieval function", "pCAL"); |
825 | 866 |
826 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) | 867 if (png_ptr != NULL && info_ptr != NULL && |
827 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && | 868 (info_ptr->valid & PNG_INFO_pCAL) != 0 && |
| 869 purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && |
828 nparams != NULL && units != NULL && params != NULL) | 870 nparams != NULL && units != NULL && params != NULL) |
829 { | 871 { |
830 *purpose = info_ptr->pcal_purpose; | 872 *purpose = info_ptr->pcal_purpose; |
831 *X0 = info_ptr->pcal_X0; | 873 *X0 = info_ptr->pcal_X0; |
832 *X1 = info_ptr->pcal_X1; | 874 *X1 = info_ptr->pcal_X1; |
833 *type = (int)info_ptr->pcal_type; | 875 *type = (int)info_ptr->pcal_type; |
834 *nparams = (int)info_ptr->pcal_nparams; | 876 *nparams = (int)info_ptr->pcal_nparams; |
835 *units = info_ptr->pcal_units; | 877 *units = info_ptr->pcal_units; |
836 *params = info_ptr->pcal_params; | 878 *params = info_ptr->pcal_params; |
837 return (PNG_INFO_pCAL); | 879 return (PNG_INFO_pCAL); |
838 } | 880 } |
839 | 881 |
840 return (0); | 882 return (0); |
841 } | 883 } |
842 #endif | 884 #endif |
843 | 885 |
844 #ifdef PNG_sCAL_SUPPORTED | 886 #ifdef PNG_sCAL_SUPPORTED |
845 # ifdef PNG_FIXED_POINT_SUPPORTED | 887 # ifdef PNG_FIXED_POINT_SUPPORTED |
846 # if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ | 888 # if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ |
847 defined(PNG_FLOATING_POINT_SUPPORTED) | 889 defined(PNG_FLOATING_POINT_SUPPORTED) |
848 png_uint_32 PNGAPI | 890 png_uint_32 PNGAPI |
849 png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, | 891 png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, |
850 int *unit, png_fixed_point *width, png_fixed_point *height) | 892 int *unit, png_fixed_point *width, png_fixed_point *height) |
851 { | 893 { |
852 if (png_ptr != NULL && info_ptr != NULL && | 894 if (png_ptr != NULL && info_ptr != NULL && |
853 (info_ptr->valid & PNG_INFO_sCAL)) | 895 (info_ptr->valid & PNG_INFO_sCAL) != 0) |
854 { | 896 { |
855 *unit = info_ptr->scal_unit; | 897 *unit = info_ptr->scal_unit; |
856 /*TODO: make this work without FP support; the API is currently eliminated | 898 /*TODO: make this work without FP support; the API is currently eliminated |
857 * if neither floating point APIs nor internal floating point arithmetic | 899 * if neither floating point APIs nor internal floating point arithmetic |
858 * are enabled. | 900 * are enabled. |
859 */ | 901 */ |
860 *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width"); | 902 *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width"); |
861 *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height), | 903 *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height), |
862 "sCAL height"); | 904 "sCAL height"); |
863 return (PNG_INFO_sCAL); | 905 return (PNG_INFO_sCAL); |
864 } | 906 } |
865 | 907 |
866 return(0); | 908 return(0); |
867 } | 909 } |
868 # endif /* FLOATING_ARITHMETIC */ | 910 # endif /* FLOATING_ARITHMETIC */ |
869 # endif /* FIXED_POINT */ | 911 # endif /* FIXED_POINT */ |
870 # ifdef PNG_FLOATING_POINT_SUPPORTED | 912 # ifdef PNG_FLOATING_POINT_SUPPORTED |
871 png_uint_32 PNGAPI | 913 png_uint_32 PNGAPI |
872 png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr, | 914 png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr, |
873 int *unit, double *width, double *height) | 915 int *unit, double *width, double *height) |
874 { | 916 { |
875 if (png_ptr != NULL && info_ptr != NULL && | 917 if (png_ptr != NULL && info_ptr != NULL && |
876 (info_ptr->valid & PNG_INFO_sCAL)) | 918 (info_ptr->valid & PNG_INFO_sCAL) != 0) |
877 { | 919 { |
878 *unit = info_ptr->scal_unit; | 920 *unit = info_ptr->scal_unit; |
879 *width = atof(info_ptr->scal_s_width); | 921 *width = atof(info_ptr->scal_s_width); |
880 *height = atof(info_ptr->scal_s_height); | 922 *height = atof(info_ptr->scal_s_height); |
881 return (PNG_INFO_sCAL); | 923 return (PNG_INFO_sCAL); |
882 } | 924 } |
883 | 925 |
884 return(0); | 926 return(0); |
885 } | 927 } |
886 # endif /* FLOATING POINT */ | 928 # endif /* FLOATING POINT */ |
887 png_uint_32 PNGAPI | 929 png_uint_32 PNGAPI |
888 png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr, | 930 png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr, |
889 int *unit, png_charpp width, png_charpp height) | 931 int *unit, png_charpp width, png_charpp height) |
890 { | 932 { |
891 if (png_ptr != NULL && info_ptr != NULL && | 933 if (png_ptr != NULL && info_ptr != NULL && |
892 (info_ptr->valid & PNG_INFO_sCAL)) | 934 (info_ptr->valid & PNG_INFO_sCAL) != 0) |
893 { | 935 { |
894 *unit = info_ptr->scal_unit; | 936 *unit = info_ptr->scal_unit; |
895 *width = info_ptr->scal_s_width; | 937 *width = info_ptr->scal_s_width; |
896 *height = info_ptr->scal_s_height; | 938 *height = info_ptr->scal_s_height; |
897 return (PNG_INFO_sCAL); | 939 return (PNG_INFO_sCAL); |
898 } | 940 } |
899 | 941 |
900 return(0); | 942 return(0); |
901 } | 943 } |
902 #endif /* sCAL */ | 944 #endif /* sCAL */ |
903 | 945 |
904 #ifdef PNG_pHYs_SUPPORTED | 946 #ifdef PNG_pHYs_SUPPORTED |
905 png_uint_32 PNGAPI | 947 png_uint_32 PNGAPI |
906 png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr, | 948 png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr, |
907 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) | 949 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) |
908 { | 950 { |
909 png_uint_32 retval = 0; | 951 png_uint_32 retval = 0; |
910 | 952 |
911 png_debug1(1, "in %s retrieval function", "pHYs"); | 953 png_debug1(1, "in %s retrieval function", "pHYs"); |
912 | 954 |
913 if (png_ptr != NULL && info_ptr != NULL && | 955 if (png_ptr != NULL && info_ptr != NULL && |
914 (info_ptr->valid & PNG_INFO_pHYs)) | 956 (info_ptr->valid & PNG_INFO_pHYs) != 0) |
915 { | 957 { |
916 if (res_x != NULL) | 958 if (res_x != NULL) |
917 { | 959 { |
918 *res_x = info_ptr->x_pixels_per_unit; | 960 *res_x = info_ptr->x_pixels_per_unit; |
919 retval |= PNG_INFO_pHYs; | 961 retval |= PNG_INFO_pHYs; |
920 } | 962 } |
921 | 963 |
922 if (res_y != NULL) | 964 if (res_y != NULL) |
923 { | 965 { |
924 *res_y = info_ptr->y_pixels_per_unit; | 966 *res_y = info_ptr->y_pixels_per_unit; |
(...skipping 10 matching lines...) Expand all Loading... |
935 return (retval); | 977 return (retval); |
936 } | 978 } |
937 #endif /* pHYs */ | 979 #endif /* pHYs */ |
938 | 980 |
939 png_uint_32 PNGAPI | 981 png_uint_32 PNGAPI |
940 png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr, | 982 png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr, |
941 png_colorp *palette, int *num_palette) | 983 png_colorp *palette, int *num_palette) |
942 { | 984 { |
943 png_debug1(1, "in %s retrieval function", "PLTE"); | 985 png_debug1(1, "in %s retrieval function", "PLTE"); |
944 | 986 |
945 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) | 987 if (png_ptr != NULL && info_ptr != NULL && |
946 && palette != NULL) | 988 (info_ptr->valid & PNG_INFO_PLTE) != 0 && palette != NULL) |
947 { | 989 { |
948 *palette = info_ptr->palette; | 990 *palette = info_ptr->palette; |
949 *num_palette = info_ptr->num_palette; | 991 *num_palette = info_ptr->num_palette; |
950 png_debug1(3, "num_palette = %d", *num_palette); | 992 png_debug1(3, "num_palette = %d", *num_palette); |
951 return (PNG_INFO_PLTE); | 993 return (PNG_INFO_PLTE); |
952 } | 994 } |
953 | 995 |
954 return (0); | 996 return (0); |
955 } | 997 } |
956 | 998 |
957 #ifdef PNG_sBIT_SUPPORTED | 999 #ifdef PNG_sBIT_SUPPORTED |
958 png_uint_32 PNGAPI | 1000 png_uint_32 PNGAPI |
959 png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr, | 1001 png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr, |
960 png_color_8p *sig_bit) | 1002 png_color_8p *sig_bit) |
961 { | 1003 { |
962 png_debug1(1, "in %s retrieval function", "sBIT"); | 1004 png_debug1(1, "in %s retrieval function", "sBIT"); |
963 | 1005 |
964 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) | 1006 if (png_ptr != NULL && info_ptr != NULL && |
965 && sig_bit != NULL) | 1007 (info_ptr->valid & PNG_INFO_sBIT) != 0 && sig_bit != NULL) |
966 { | 1008 { |
967 *sig_bit = &(info_ptr->sig_bit); | 1009 *sig_bit = &(info_ptr->sig_bit); |
968 return (PNG_INFO_sBIT); | 1010 return (PNG_INFO_sBIT); |
969 } | 1011 } |
970 | 1012 |
971 return (0); | 1013 return (0); |
972 } | 1014 } |
973 #endif | 1015 #endif |
974 | 1016 |
975 #ifdef PNG_TEXT_SUPPORTED | 1017 #ifdef PNG_TEXT_SUPPORTED |
(...skipping 22 matching lines...) Expand all Loading... |
998 } | 1040 } |
999 #endif | 1041 #endif |
1000 | 1042 |
1001 #ifdef PNG_tIME_SUPPORTED | 1043 #ifdef PNG_tIME_SUPPORTED |
1002 png_uint_32 PNGAPI | 1044 png_uint_32 PNGAPI |
1003 png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr, | 1045 png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr, |
1004 png_timep *mod_time) | 1046 png_timep *mod_time) |
1005 { | 1047 { |
1006 png_debug1(1, "in %s retrieval function", "tIME"); | 1048 png_debug1(1, "in %s retrieval function", "tIME"); |
1007 | 1049 |
1008 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) | 1050 if (png_ptr != NULL && info_ptr != NULL && |
1009 && mod_time != NULL) | 1051 (info_ptr->valid & PNG_INFO_tIME) != 0 && mod_time != NULL) |
1010 { | 1052 { |
1011 *mod_time = &(info_ptr->mod_time); | 1053 *mod_time = &(info_ptr->mod_time); |
1012 return (PNG_INFO_tIME); | 1054 return (PNG_INFO_tIME); |
1013 } | 1055 } |
1014 | 1056 |
1015 return (0); | 1057 return (0); |
1016 } | 1058 } |
1017 #endif | 1059 #endif |
1018 | 1060 |
1019 #ifdef PNG_tRNS_SUPPORTED | 1061 #ifdef PNG_tRNS_SUPPORTED |
1020 png_uint_32 PNGAPI | 1062 png_uint_32 PNGAPI |
1021 png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr, | 1063 png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr, |
1022 png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color) | 1064 png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color) |
1023 { | 1065 { |
1024 png_uint_32 retval = 0; | 1066 png_uint_32 retval = 0; |
1025 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) | 1067 if (png_ptr != NULL && info_ptr != NULL && |
| 1068 (info_ptr->valid & PNG_INFO_tRNS) != 0) |
1026 { | 1069 { |
1027 png_debug1(1, "in %s retrieval function", "tRNS"); | 1070 png_debug1(1, "in %s retrieval function", "tRNS"); |
1028 | 1071 |
1029 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) | 1072 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) |
1030 { | 1073 { |
1031 if (trans_alpha != NULL) | 1074 if (trans_alpha != NULL) |
1032 { | 1075 { |
1033 *trans_alpha = info_ptr->trans_alpha; | 1076 *trans_alpha = info_ptr->trans_alpha; |
1034 retval |= PNG_INFO_tRNS; | 1077 retval |= PNG_INFO_tRNS; |
1035 } | 1078 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 return (png_ptr ? png_ptr->user_chunk_ptr : NULL); | 1134 return (png_ptr ? png_ptr->user_chunk_ptr : NULL); |
1092 } | 1135 } |
1093 #endif | 1136 #endif |
1094 | 1137 |
1095 png_size_t PNGAPI | 1138 png_size_t PNGAPI |
1096 png_get_compression_buffer_size(png_const_structrp png_ptr) | 1139 png_get_compression_buffer_size(png_const_structrp png_ptr) |
1097 { | 1140 { |
1098 if (png_ptr == NULL) | 1141 if (png_ptr == NULL) |
1099 return 0; | 1142 return 0; |
1100 | 1143 |
1101 # ifdef PNG_WRITE_SUPPORTED | 1144 #ifdef PNG_WRITE_SUPPORTED |
1102 if (png_ptr->mode & PNG_IS_READ_STRUCT) | 1145 if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0) |
1103 # endif | 1146 #endif |
1104 { | 1147 { |
1105 # ifdef PNG_SEQUENTIAL_READ_SUPPORTED | 1148 #ifdef PNG_SEQUENTIAL_READ_SUPPORTED |
1106 return png_ptr->IDAT_read_size; | 1149 return png_ptr->IDAT_read_size; |
1107 # else | 1150 #else |
1108 return PNG_IDAT_READ_SIZE; | 1151 return PNG_IDAT_READ_SIZE; |
1109 # endif | 1152 #endif |
1110 } | 1153 } |
1111 | 1154 |
1112 # ifdef PNG_WRITE_SUPPORTED | 1155 #ifdef PNG_WRITE_SUPPORTED |
1113 else | 1156 else |
1114 return png_ptr->zbuffer_size; | 1157 return png_ptr->zbuffer_size; |
1115 # endif | 1158 #endif |
1116 } | 1159 } |
1117 | 1160 |
1118 #ifdef PNG_SET_USER_LIMITS_SUPPORTED | 1161 #ifdef PNG_SET_USER_LIMITS_SUPPORTED |
1119 /* These functions were added to libpng 1.2.6 and were enabled | 1162 /* These functions were added to libpng 1.2.6 and were enabled |
1120 * by default in libpng-1.4.0 */ | 1163 * by default in libpng-1.4.0 */ |
1121 png_uint_32 PNGAPI | 1164 png_uint_32 PNGAPI |
1122 png_get_user_width_max (png_const_structrp png_ptr) | 1165 png_get_user_width_max (png_const_structrp png_ptr) |
1123 { | 1166 { |
1124 return (png_ptr ? png_ptr->user_width_max : 0); | 1167 return (png_ptr ? png_ptr->user_width_max : 0); |
1125 } | 1168 } |
(...skipping 10 matching lines...) Expand all Loading... |
1136 { | 1179 { |
1137 return (png_ptr ? png_ptr->user_chunk_cache_max : 0); | 1180 return (png_ptr ? png_ptr->user_chunk_cache_max : 0); |
1138 } | 1181 } |
1139 | 1182 |
1140 /* This function was added to libpng 1.4.1 */ | 1183 /* This function was added to libpng 1.4.1 */ |
1141 png_alloc_size_t PNGAPI | 1184 png_alloc_size_t PNGAPI |
1142 png_get_chunk_malloc_max (png_const_structrp png_ptr) | 1185 png_get_chunk_malloc_max (png_const_structrp png_ptr) |
1143 { | 1186 { |
1144 return (png_ptr ? png_ptr->user_chunk_malloc_max : 0); | 1187 return (png_ptr ? png_ptr->user_chunk_malloc_max : 0); |
1145 } | 1188 } |
1146 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ | 1189 #endif /* SET_USER_LIMITS */ |
1147 | 1190 |
1148 /* These functions were added to libpng 1.4.0 */ | 1191 /* These functions were added to libpng 1.4.0 */ |
1149 #ifdef PNG_IO_STATE_SUPPORTED | 1192 #ifdef PNG_IO_STATE_SUPPORTED |
1150 png_uint_32 PNGAPI | 1193 png_uint_32 PNGAPI |
1151 png_get_io_state (png_const_structrp png_ptr) | 1194 png_get_io_state (png_const_structrp png_ptr) |
1152 { | 1195 { |
1153 return png_ptr->io_state; | 1196 return png_ptr->io_state; |
1154 } | 1197 } |
1155 | 1198 |
1156 png_uint_32 PNGAPI | 1199 png_uint_32 PNGAPI |
1157 png_get_io_chunk_type (png_const_structrp png_ptr) | 1200 png_get_io_chunk_type (png_const_structrp png_ptr) |
1158 { | 1201 { |
1159 return png_ptr->chunk_name; | 1202 return png_ptr->chunk_name; |
1160 } | 1203 } |
1161 #endif /* ?PNG_IO_STATE_SUPPORTED */ | 1204 #endif /* IO_STATE */ |
1162 | 1205 |
1163 #ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED | 1206 #ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED |
1164 # ifdef PNG_GET_PALETTE_MAX_SUPPORTED | 1207 # ifdef PNG_GET_PALETTE_MAX_SUPPORTED |
1165 int PNGAPI | 1208 int PNGAPI |
1166 png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr) | 1209 png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr) |
1167 { | 1210 { |
1168 if (png_ptr != NULL && info_ptr != NULL) | 1211 if (png_ptr != NULL && info_ptr != NULL) |
1169 return png_ptr->num_palette_max; | 1212 return png_ptr->num_palette_max; |
1170 | 1213 |
1171 return (-1); | 1214 return (-1); |
1172 } | 1215 } |
1173 # endif | 1216 # endif |
1174 #endif | 1217 #endif |
1175 | 1218 |
1176 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ | 1219 #endif /* READ || WRITE */ |
OLD | NEW |