Line | Count | Source |
1 | | /* pngget.c - retrieval of values from info struct |
2 | | * |
3 | | * Copyright (c) 2018-2025 Cosmin Truta |
4 | | * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson |
5 | | * Copyright (c) 1996-1997 Andreas Dilger |
6 | | * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. |
7 | | * |
8 | | * This code is released under the libpng license. |
9 | | * For conditions of distribution and use, see the disclaimer |
10 | | * and license in png.h |
11 | | * |
12 | | */ |
13 | | |
14 | | #include "pngpriv.h" |
15 | | |
16 | | #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) |
17 | | |
18 | | png_uint_32 |
19 | | png_get_valid(const png_struct *png_ptr, const png_info *info_ptr, |
20 | | png_uint_32 flag) |
21 | 1.08M | { |
22 | 1.08M | if (png_ptr != NULL && info_ptr != NULL) |
23 | 1.08M | { |
24 | 1.08M | #ifdef PNG_READ_tRNS_SUPPORTED |
25 | | /* png_handle_PLTE() may have canceled a valid tRNS chunk but left the |
26 | | * 'valid' flag for the detection of duplicate chunks. Do not report a |
27 | | * valid tRNS chunk in this case. |
28 | | */ |
29 | 1.08M | if (flag == PNG_INFO_tRNS && png_ptr->num_trans == 0) |
30 | 201k | return 0; |
31 | 885k | #endif |
32 | | |
33 | 885k | return info_ptr->valid & flag; |
34 | 1.08M | } |
35 | | |
36 | 0 | return 0; |
37 | 1.08M | } |
38 | | |
39 | | size_t |
40 | | png_get_rowbytes(const png_struct *png_ptr, const png_info *info_ptr) |
41 | 92.2k | { |
42 | 92.2k | if (png_ptr != NULL && info_ptr != NULL) |
43 | 92.2k | return info_ptr->rowbytes; |
44 | | |
45 | 0 | return 0; |
46 | 92.2k | } |
47 | | |
48 | | #ifdef PNG_INFO_IMAGE_SUPPORTED |
49 | | png_byte ** |
50 | | png_get_rows(const png_struct *png_ptr, const png_info *info_ptr) |
51 | 0 | { |
52 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
53 | 0 | return info_ptr->row_pointers; |
54 | | |
55 | 0 | return 0; |
56 | 0 | } |
57 | | #endif |
58 | | |
59 | | #ifdef PNG_EASY_ACCESS_SUPPORTED |
60 | | /* Easy access to info, added in libpng-0.99 */ |
61 | | png_uint_32 |
62 | | png_get_image_width(const png_struct *png_ptr, const png_info *info_ptr) |
63 | 0 | { |
64 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
65 | 0 | return info_ptr->width; |
66 | | |
67 | 0 | return 0; |
68 | 0 | } |
69 | | |
70 | | png_uint_32 |
71 | | png_get_image_height(const png_struct *png_ptr, const png_info *info_ptr) |
72 | 0 | { |
73 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
74 | 0 | return info_ptr->height; |
75 | | |
76 | 0 | return 0; |
77 | 0 | } |
78 | | |
79 | | png_byte |
80 | | png_get_bit_depth(const png_struct *png_ptr, const png_info *info_ptr) |
81 | 0 | { |
82 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
83 | 0 | return info_ptr->bit_depth; |
84 | | |
85 | 0 | return 0; |
86 | 0 | } |
87 | | |
88 | | png_byte |
89 | | png_get_color_type(const png_struct *png_ptr, const png_info *info_ptr) |
90 | 0 | { |
91 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
92 | 0 | return info_ptr->color_type; |
93 | | |
94 | 0 | return 0; |
95 | 0 | } |
96 | | |
97 | | png_byte |
98 | | png_get_filter_type(const png_struct *png_ptr, const png_info *info_ptr) |
99 | 0 | { |
100 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
101 | 0 | return info_ptr->filter_type; |
102 | | |
103 | 0 | return 0; |
104 | 0 | } |
105 | | |
106 | | png_byte |
107 | | png_get_interlace_type(const png_struct *png_ptr, const png_info *info_ptr) |
108 | 0 | { |
109 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
110 | 0 | return info_ptr->interlace_type; |
111 | | |
112 | 0 | return 0; |
113 | 0 | } |
114 | | |
115 | | png_byte |
116 | | png_get_compression_type(const png_struct *png_ptr, const png_info *info_ptr) |
117 | 0 | { |
118 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
119 | 0 | return info_ptr->compression_type; |
120 | | |
121 | 0 | return 0; |
122 | 0 | } |
123 | | |
124 | | png_uint_32 |
125 | | png_get_x_pixels_per_meter(const png_struct *png_ptr, |
126 | | const png_info *info_ptr) |
127 | 0 | { |
128 | 0 | #ifdef PNG_pHYs_SUPPORTED |
129 | 0 | png_debug(1, "in png_get_x_pixels_per_meter"); |
130 | |
|
131 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
132 | 0 | (info_ptr->valid & PNG_INFO_pHYs) != 0) |
133 | 0 | { |
134 | 0 | if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) |
135 | 0 | return info_ptr->x_pixels_per_unit; |
136 | 0 | } |
137 | | #else |
138 | | PNG_UNUSED(png_ptr) |
139 | | PNG_UNUSED(info_ptr) |
140 | | #endif |
141 | | |
142 | 0 | return 0; |
143 | 0 | } |
144 | | |
145 | | png_uint_32 |
146 | | png_get_y_pixels_per_meter(const png_struct *png_ptr, |
147 | | const png_info *info_ptr) |
148 | 0 | { |
149 | 0 | #ifdef PNG_pHYs_SUPPORTED |
150 | 0 | png_debug(1, "in png_get_y_pixels_per_meter"); |
151 | |
|
152 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
153 | 0 | (info_ptr->valid & PNG_INFO_pHYs) != 0) |
154 | 0 | { |
155 | 0 | if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) |
156 | 0 | return info_ptr->y_pixels_per_unit; |
157 | 0 | } |
158 | | #else |
159 | | PNG_UNUSED(png_ptr) |
160 | | PNG_UNUSED(info_ptr) |
161 | | #endif |
162 | | |
163 | 0 | return 0; |
164 | 0 | } |
165 | | |
166 | | png_uint_32 |
167 | | png_get_pixels_per_meter(const png_struct *png_ptr, const png_info *info_ptr) |
168 | 0 | { |
169 | 0 | #ifdef PNG_pHYs_SUPPORTED |
170 | 0 | png_debug(1, "in png_get_pixels_per_meter"); |
171 | |
|
172 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
173 | 0 | (info_ptr->valid & PNG_INFO_pHYs) != 0) |
174 | 0 | { |
175 | 0 | if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER && |
176 | 0 | info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit) |
177 | 0 | return info_ptr->x_pixels_per_unit; |
178 | 0 | } |
179 | | #else |
180 | | PNG_UNUSED(png_ptr) |
181 | | PNG_UNUSED(info_ptr) |
182 | | #endif |
183 | | |
184 | 0 | return 0; |
185 | 0 | } |
186 | | |
187 | | #ifdef PNG_FLOATING_POINT_SUPPORTED |
188 | | float |
189 | | png_get_pixel_aspect_ratio(const png_struct *png_ptr, |
190 | | const png_info *info_ptr) |
191 | 0 | { |
192 | 0 | #ifdef PNG_READ_pHYs_SUPPORTED |
193 | 0 | png_debug(1, "in png_get_pixel_aspect_ratio"); |
194 | |
|
195 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
196 | 0 | (info_ptr->valid & PNG_INFO_pHYs) != 0) |
197 | 0 | { |
198 | 0 | if (info_ptr->x_pixels_per_unit != 0) |
199 | 0 | return (float)info_ptr->y_pixels_per_unit |
200 | 0 | / (float)info_ptr->x_pixels_per_unit; |
201 | 0 | } |
202 | | #else |
203 | | PNG_UNUSED(png_ptr) |
204 | | PNG_UNUSED(info_ptr) |
205 | | #endif |
206 | | |
207 | 0 | return (float)0.0; |
208 | 0 | } |
209 | | #endif |
210 | | |
211 | | #ifdef PNG_FIXED_POINT_SUPPORTED |
212 | | png_fixed_point |
213 | | png_get_pixel_aspect_ratio_fixed(const png_struct *png_ptr, |
214 | | const png_info *info_ptr) |
215 | 0 | { |
216 | 0 | #ifdef PNG_READ_pHYs_SUPPORTED |
217 | 0 | png_debug(1, "in png_get_pixel_aspect_ratio_fixed"); |
218 | |
|
219 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
220 | 0 | (info_ptr->valid & PNG_INFO_pHYs) != 0 && |
221 | 0 | info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 && |
222 | 0 | info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX && |
223 | 0 | info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX) |
224 | 0 | { |
225 | 0 | png_fixed_point res; |
226 | | |
227 | | /* The following casts work because a PNG 4 byte integer only has a valid |
228 | | * range of 0..2^31-1; otherwise the cast might overflow. |
229 | | */ |
230 | 0 | if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1, |
231 | 0 | (png_int_32)info_ptr->x_pixels_per_unit) != 0) |
232 | 0 | return res; |
233 | 0 | } |
234 | | #else |
235 | | PNG_UNUSED(png_ptr) |
236 | | PNG_UNUSED(info_ptr) |
237 | | #endif |
238 | | |
239 | 0 | return 0; |
240 | 0 | } |
241 | | #endif |
242 | | |
243 | | png_int_32 |
244 | | png_get_x_offset_microns(const png_struct *png_ptr, const png_info *info_ptr) |
245 | 0 | { |
246 | 0 | #ifdef PNG_oFFs_SUPPORTED |
247 | 0 | png_debug(1, "in png_get_x_offset_microns"); |
248 | |
|
249 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
250 | 0 | (info_ptr->valid & PNG_INFO_oFFs) != 0) |
251 | 0 | { |
252 | 0 | if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) |
253 | 0 | return info_ptr->x_offset; |
254 | 0 | } |
255 | | #else |
256 | | PNG_UNUSED(png_ptr) |
257 | | PNG_UNUSED(info_ptr) |
258 | | #endif |
259 | | |
260 | 0 | return 0; |
261 | 0 | } |
262 | | |
263 | | png_int_32 |
264 | | png_get_y_offset_microns(const png_struct *png_ptr, const png_info *info_ptr) |
265 | 0 | { |
266 | 0 | #ifdef PNG_oFFs_SUPPORTED |
267 | 0 | png_debug(1, "in png_get_y_offset_microns"); |
268 | |
|
269 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
270 | 0 | (info_ptr->valid & PNG_INFO_oFFs) != 0) |
271 | 0 | { |
272 | 0 | if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) |
273 | 0 | return info_ptr->y_offset; |
274 | 0 | } |
275 | | #else |
276 | | PNG_UNUSED(png_ptr) |
277 | | PNG_UNUSED(info_ptr) |
278 | | #endif |
279 | | |
280 | 0 | return 0; |
281 | 0 | } |
282 | | |
283 | | png_int_32 |
284 | | png_get_x_offset_pixels(const png_struct *png_ptr, const png_info *info_ptr) |
285 | 734 | { |
286 | 734 | #ifdef PNG_oFFs_SUPPORTED |
287 | 734 | png_debug(1, "in png_get_x_offset_pixels"); |
288 | | |
289 | 734 | if (png_ptr != NULL && info_ptr != NULL && |
290 | 734 | (info_ptr->valid & PNG_INFO_oFFs) != 0) |
291 | 734 | { |
292 | 734 | if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) |
293 | 627 | return info_ptr->x_offset; |
294 | 734 | } |
295 | | #else |
296 | | PNG_UNUSED(png_ptr) |
297 | | PNG_UNUSED(info_ptr) |
298 | | #endif |
299 | | |
300 | 107 | return 0; |
301 | 734 | } |
302 | | |
303 | | png_int_32 |
304 | | png_get_y_offset_pixels(const png_struct *png_ptr, const png_info *info_ptr) |
305 | 734 | { |
306 | 734 | #ifdef PNG_oFFs_SUPPORTED |
307 | 734 | png_debug(1, "in png_get_y_offset_pixels"); |
308 | | |
309 | 734 | if (png_ptr != NULL && info_ptr != NULL && |
310 | 734 | (info_ptr->valid & PNG_INFO_oFFs) != 0) |
311 | 734 | { |
312 | 734 | if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) |
313 | 627 | return info_ptr->y_offset; |
314 | 734 | } |
315 | | #else |
316 | | PNG_UNUSED(png_ptr) |
317 | | PNG_UNUSED(info_ptr) |
318 | | #endif |
319 | | |
320 | 107 | return 0; |
321 | 734 | } |
322 | | |
323 | | #ifdef PNG_INCH_CONVERSIONS_SUPPORTED |
324 | | static png_uint_32 |
325 | | ppi_from_ppm(png_uint_32 ppm) |
326 | 0 | { |
327 | | #if 0 |
328 | | /* The conversion is *(2.54/100), in binary (32 digits): |
329 | | * .00000110100000001001110101001001 |
330 | | */ |
331 | | png_uint_32 t1001, t1101; |
332 | | ppm >>= 1; /* .1 */ |
333 | | t1001 = ppm + (ppm >> 3); /* .1001 */ |
334 | | t1101 = t1001 + (ppm >> 1); /* .1101 */ |
335 | | ppm >>= 20; /* .000000000000000000001 */ |
336 | | t1101 += t1101 >> 15; /* .1101000000000001101 */ |
337 | | t1001 >>= 11; /* .000000000001001 */ |
338 | | t1001 += t1001 >> 12; /* .000000000001001000000001001 */ |
339 | | ppm += t1001; /* .000000000001001000001001001 */ |
340 | | ppm += t1101; /* .110100000001001110101001001 */ |
341 | | return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */ |
342 | | #else |
343 | | /* The argument is a PNG unsigned integer, so it is not permitted |
344 | | * to be bigger than 2^31. |
345 | | */ |
346 | 0 | png_fixed_point result; |
347 | 0 | if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127, |
348 | 0 | 5000) != 0) |
349 | 0 | return (png_uint_32)result; |
350 | | |
351 | | /* Overflow. */ |
352 | 0 | return 0; |
353 | 0 | #endif |
354 | 0 | } |
355 | | |
356 | | png_uint_32 |
357 | | png_get_pixels_per_inch(const png_struct *png_ptr, const png_info *info_ptr) |
358 | 0 | { |
359 | 0 | return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr)); |
360 | 0 | } |
361 | | |
362 | | png_uint_32 |
363 | | png_get_x_pixels_per_inch(const png_struct *png_ptr, const png_info *info_ptr) |
364 | 0 | { |
365 | 0 | return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr)); |
366 | 0 | } |
367 | | |
368 | | png_uint_32 |
369 | | png_get_y_pixels_per_inch(const png_struct *png_ptr, const png_info *info_ptr) |
370 | 0 | { |
371 | 0 | return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr)); |
372 | 0 | } |
373 | | |
374 | | #ifdef PNG_FIXED_POINT_SUPPORTED |
375 | | static png_fixed_point |
376 | | png_fixed_inches_from_microns(const png_struct *png_ptr, png_int_32 microns) |
377 | 0 | { |
378 | | /* Convert from meters * 1,000,000 to inches * 100,000, meters to |
379 | | * inches is simply *(100/2.54), so we want *(10/2.54) == 500/127. |
380 | | * Notice that this can overflow - a warning is output and 0 is |
381 | | * returned. |
382 | | */ |
383 | 0 | png_fixed_point result; |
384 | |
|
385 | 0 | if (png_muldiv(&result, microns, 500, 127) != 0) |
386 | 0 | return result; |
387 | | |
388 | 0 | png_warning(png_ptr, "fixed point overflow ignored"); |
389 | 0 | return 0; |
390 | 0 | } |
391 | | |
392 | | png_fixed_point |
393 | | png_get_x_offset_inches_fixed(const png_struct *png_ptr, |
394 | | const png_info *info_ptr) |
395 | 0 | { |
396 | 0 | return png_fixed_inches_from_microns(png_ptr, |
397 | 0 | png_get_x_offset_microns(png_ptr, info_ptr)); |
398 | 0 | } |
399 | | #endif /* FIXED_POINT */ |
400 | | |
401 | | #ifdef PNG_FIXED_POINT_SUPPORTED |
402 | | png_fixed_point |
403 | | png_get_y_offset_inches_fixed(const png_struct *png_ptr, |
404 | | const png_info *info_ptr) |
405 | 0 | { |
406 | 0 | return png_fixed_inches_from_microns(png_ptr, |
407 | 0 | png_get_y_offset_microns(png_ptr, info_ptr)); |
408 | 0 | } |
409 | | #endif |
410 | | |
411 | | #ifdef PNG_FLOATING_POINT_SUPPORTED |
412 | | float |
413 | | png_get_x_offset_inches(const png_struct *png_ptr, const png_info *info_ptr) |
414 | 0 | { |
415 | | /* To avoid the overflow do the conversion directly in floating |
416 | | * point. |
417 | | */ |
418 | 0 | return (float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937); |
419 | 0 | } |
420 | | #endif |
421 | | |
422 | | #ifdef PNG_FLOATING_POINT_SUPPORTED |
423 | | float |
424 | | png_get_y_offset_inches(const png_struct *png_ptr, const png_info *info_ptr) |
425 | 0 | { |
426 | | /* To avoid the overflow do the conversion directly in floating |
427 | | * point. |
428 | | */ |
429 | 0 | return (float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937); |
430 | 0 | } |
431 | | #endif |
432 | | |
433 | | #ifdef PNG_pHYs_SUPPORTED |
434 | | png_uint_32 |
435 | | png_get_pHYs_dpi(const png_struct *png_ptr, const png_info *info_ptr, |
436 | | png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) |
437 | 0 | { |
438 | 0 | png_uint_32 retval = 0; |
439 | |
|
440 | 0 | png_debug1(1, "in %s retrieval function", "pHYs"); |
441 | |
|
442 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
443 | 0 | (info_ptr->valid & PNG_INFO_pHYs) != 0) |
444 | 0 | { |
445 | 0 | if (res_x != NULL) |
446 | 0 | { |
447 | 0 | *res_x = info_ptr->x_pixels_per_unit; |
448 | 0 | retval |= PNG_INFO_pHYs; |
449 | 0 | } |
450 | |
|
451 | 0 | if (res_y != NULL) |
452 | 0 | { |
453 | 0 | *res_y = info_ptr->y_pixels_per_unit; |
454 | 0 | retval |= PNG_INFO_pHYs; |
455 | 0 | } |
456 | |
|
457 | 0 | if (unit_type != NULL) |
458 | 0 | { |
459 | 0 | *unit_type = (int)info_ptr->phys_unit_type; |
460 | 0 | retval |= PNG_INFO_pHYs; |
461 | |
|
462 | 0 | if (*unit_type == 1) |
463 | 0 | { |
464 | 0 | if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); |
465 | 0 | if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); |
466 | 0 | } |
467 | 0 | } |
468 | 0 | } |
469 | |
|
470 | 0 | return retval; |
471 | 0 | } |
472 | | #endif /* pHYs */ |
473 | | #endif /* INCH_CONVERSIONS */ |
474 | | |
475 | | /* png_get_channels really belongs in here, too, but it's been around longer */ |
476 | | |
477 | | #endif /* EASY_ACCESS */ |
478 | | |
479 | | |
480 | | png_byte |
481 | | png_get_channels(const png_struct *png_ptr, const png_info *info_ptr) |
482 | 0 | { |
483 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
484 | 0 | return info_ptr->channels; |
485 | | |
486 | 0 | return 0; |
487 | 0 | } |
488 | | |
489 | | #ifdef PNG_READ_SUPPORTED |
490 | | const png_byte * |
491 | | png_get_signature(const png_struct *png_ptr, const png_info *info_ptr) |
492 | 0 | { |
493 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
494 | 0 | return info_ptr->signature; |
495 | | |
496 | 0 | return NULL; |
497 | 0 | } |
498 | | #endif |
499 | | |
500 | | #ifdef PNG_bKGD_SUPPORTED |
501 | | png_uint_32 |
502 | | png_get_bKGD(const png_struct *png_ptr, png_info *info_ptr, |
503 | | png_color_16 **background) |
504 | 92.2k | { |
505 | 92.2k | png_debug1(1, "in %s retrieval function", "bKGD"); |
506 | | |
507 | 92.2k | if (png_ptr != NULL && info_ptr != NULL && |
508 | 92.2k | (info_ptr->valid & PNG_INFO_bKGD) != 0 && |
509 | 3.67k | background != NULL) |
510 | 3.67k | { |
511 | 3.67k | *background = &(info_ptr->background); |
512 | 3.67k | return PNG_INFO_bKGD; |
513 | 3.67k | } |
514 | | |
515 | 88.5k | return 0; |
516 | 92.2k | } |
517 | | #endif |
518 | | |
519 | | #ifdef PNG_cHRM_SUPPORTED |
520 | | /* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the |
521 | | * same time to correct the rgb grayscale coefficient defaults obtained from the |
522 | | * cHRM chunk in 1.5.4 |
523 | | */ |
524 | | # ifdef PNG_FLOATING_POINT_SUPPORTED |
525 | | png_uint_32 |
526 | | png_get_cHRM(const png_struct *png_ptr, const png_info *info_ptr, |
527 | | double *whitex, double *whitey, double *redx, double *redy, |
528 | | double *greenx, double *greeny, double *bluex, double *bluey) |
529 | 5.61k | { |
530 | 5.61k | png_debug1(1, "in %s retrieval function", "cHRM"); |
531 | | |
532 | | /* PNGv3: this just returns the values store from the cHRM, if any. */ |
533 | 5.61k | if (png_ptr != NULL && info_ptr != NULL && |
534 | 5.61k | (info_ptr->valid & PNG_INFO_cHRM) != 0) |
535 | 5.61k | { |
536 | 5.61k | if (whitex != NULL) |
537 | 5.61k | *whitex = png_float(png_ptr, info_ptr->cHRM.whitex, "cHRM wx"); |
538 | 5.61k | if (whitey != NULL) |
539 | 5.61k | *whitey = png_float(png_ptr, info_ptr->cHRM.whitey, "cHRM wy"); |
540 | 5.61k | if (redx != NULL) |
541 | 5.61k | *redx = png_float(png_ptr, info_ptr->cHRM.redx, "cHRM rx"); |
542 | 5.61k | if (redy != NULL) |
543 | 5.61k | *redy = png_float(png_ptr, info_ptr->cHRM.redy, "cHRM ry"); |
544 | 5.61k | if (greenx != NULL) |
545 | 5.61k | *greenx = png_float(png_ptr, info_ptr->cHRM.greenx, "cHRM gx"); |
546 | 5.61k | if (greeny != NULL) |
547 | 5.61k | *greeny = png_float(png_ptr, info_ptr->cHRM.greeny, "cHRM gy"); |
548 | 5.61k | if (bluex != NULL) |
549 | 5.61k | *bluex = png_float(png_ptr, info_ptr->cHRM.bluex, "cHRM bx"); |
550 | 5.61k | if (bluey != NULL) |
551 | 5.61k | *bluey = png_float(png_ptr, info_ptr->cHRM.bluey, "cHRM by"); |
552 | 5.61k | return PNG_INFO_cHRM; |
553 | 5.61k | } |
554 | | |
555 | 0 | return 0; |
556 | 5.61k | } |
557 | | |
558 | | png_uint_32 |
559 | | png_get_cHRM_XYZ(const png_struct *png_ptr, const png_info *info_ptr, |
560 | | double *red_X, double *red_Y, double *red_Z, double *green_X, |
561 | | double *green_Y, double *green_Z, double *blue_X, double *blue_Y, |
562 | | double *blue_Z) |
563 | 0 | { |
564 | 0 | png_XYZ XYZ; |
565 | 0 | png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)"); |
566 | |
|
567 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
568 | 0 | (info_ptr->valid & PNG_INFO_cHRM) != 0 && |
569 | 0 | png_XYZ_from_xy(&XYZ, &info_ptr->cHRM) == 0) |
570 | 0 | { |
571 | 0 | if (red_X != NULL) |
572 | 0 | *red_X = png_float(png_ptr, XYZ.red_X, "cHRM red X"); |
573 | 0 | if (red_Y != NULL) |
574 | 0 | *red_Y = png_float(png_ptr, XYZ.red_Y, "cHRM red Y"); |
575 | 0 | if (red_Z != NULL) |
576 | 0 | *red_Z = png_float(png_ptr, XYZ.red_Z, "cHRM red Z"); |
577 | 0 | if (green_X != NULL) |
578 | 0 | *green_X = png_float(png_ptr, XYZ.green_X, "cHRM green X"); |
579 | 0 | if (green_Y != NULL) |
580 | 0 | *green_Y = png_float(png_ptr, XYZ.green_Y, "cHRM green Y"); |
581 | 0 | if (green_Z != NULL) |
582 | 0 | *green_Z = png_float(png_ptr, XYZ.green_Z, "cHRM green Z"); |
583 | 0 | if (blue_X != NULL) |
584 | 0 | *blue_X = png_float(png_ptr, XYZ.blue_X, "cHRM blue X"); |
585 | 0 | if (blue_Y != NULL) |
586 | 0 | *blue_Y = png_float(png_ptr, XYZ.blue_Y, "cHRM blue Y"); |
587 | 0 | if (blue_Z != NULL) |
588 | 0 | *blue_Z = png_float(png_ptr, XYZ.blue_Z, "cHRM blue Z"); |
589 | 0 | return PNG_INFO_cHRM; |
590 | 0 | } |
591 | | |
592 | 0 | return 0; |
593 | 0 | } |
594 | | # endif |
595 | | |
596 | | # ifdef PNG_FIXED_POINT_SUPPORTED |
597 | | png_uint_32 |
598 | | png_get_cHRM_XYZ_fixed(const png_struct *png_ptr, const png_info *info_ptr, |
599 | | png_fixed_point *int_red_X, png_fixed_point *int_red_Y, |
600 | | png_fixed_point *int_red_Z, png_fixed_point *int_green_X, |
601 | | png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, |
602 | | png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, |
603 | | png_fixed_point *int_blue_Z) |
604 | 0 | { |
605 | 0 | png_XYZ XYZ; |
606 | 0 | png_debug1(1, "in %s retrieval function", "cHRM_XYZ"); |
607 | |
|
608 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
609 | 0 | (info_ptr->valid & PNG_INFO_cHRM) != 0U && |
610 | 0 | png_XYZ_from_xy(&XYZ, &info_ptr->cHRM) == 0) |
611 | 0 | { |
612 | 0 | if (int_red_X != NULL) *int_red_X = XYZ.red_X; |
613 | 0 | if (int_red_Y != NULL) *int_red_Y = XYZ.red_Y; |
614 | 0 | if (int_red_Z != NULL) *int_red_Z = XYZ.red_Z; |
615 | 0 | if (int_green_X != NULL) *int_green_X = XYZ.green_X; |
616 | 0 | if (int_green_Y != NULL) *int_green_Y = XYZ.green_Y; |
617 | 0 | if (int_green_Z != NULL) *int_green_Z = XYZ.green_Z; |
618 | 0 | if (int_blue_X != NULL) *int_blue_X = XYZ.blue_X; |
619 | 0 | if (int_blue_Y != NULL) *int_blue_Y = XYZ.blue_Y; |
620 | 0 | if (int_blue_Z != NULL) *int_blue_Z = XYZ.blue_Z; |
621 | 0 | return PNG_INFO_cHRM; |
622 | 0 | } |
623 | | |
624 | 0 | return 0; |
625 | 0 | } |
626 | | |
627 | | png_uint_32 |
628 | | png_get_cHRM_fixed(const png_struct *png_ptr, const png_info *info_ptr, |
629 | | png_fixed_point *whitex, png_fixed_point *whitey, png_fixed_point *redx, |
630 | | png_fixed_point *redy, png_fixed_point *greenx, png_fixed_point *greeny, |
631 | | png_fixed_point *bluex, png_fixed_point *bluey) |
632 | 0 | { |
633 | 0 | png_debug1(1, "in %s retrieval function", "cHRM"); |
634 | | |
635 | | /* PNGv3: this just returns the values store from the cHRM, if any. */ |
636 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
637 | 0 | (info_ptr->valid & PNG_INFO_cHRM) != 0) |
638 | 0 | { |
639 | 0 | if (whitex != NULL) *whitex = info_ptr->cHRM.whitex; |
640 | 0 | if (whitey != NULL) *whitey = info_ptr->cHRM.whitey; |
641 | 0 | if (redx != NULL) *redx = info_ptr->cHRM.redx; |
642 | 0 | if (redy != NULL) *redy = info_ptr->cHRM.redy; |
643 | 0 | if (greenx != NULL) *greenx = info_ptr->cHRM.greenx; |
644 | 0 | if (greeny != NULL) *greeny = info_ptr->cHRM.greeny; |
645 | 0 | if (bluex != NULL) *bluex = info_ptr->cHRM.bluex; |
646 | 0 | if (bluey != NULL) *bluey = info_ptr->cHRM.bluey; |
647 | 0 | return PNG_INFO_cHRM; |
648 | 0 | } |
649 | | |
650 | 0 | return 0; |
651 | 0 | } |
652 | | # endif |
653 | | #endif |
654 | | |
655 | | #ifdef PNG_gAMA_SUPPORTED |
656 | | # ifdef PNG_FIXED_POINT_SUPPORTED |
657 | | png_uint_32 |
658 | | png_get_gAMA_fixed(const png_struct *png_ptr, const png_info *info_ptr, |
659 | | png_fixed_point *file_gamma) |
660 | 0 | { |
661 | 0 | png_debug1(1, "in %s retrieval function", "gAMA"); |
662 | | |
663 | | /* PNGv3 compatibility: only report gAMA if it is really present. */ |
664 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
665 | 0 | (info_ptr->valid & PNG_INFO_gAMA) != 0) |
666 | 0 | { |
667 | 0 | if (file_gamma != NULL) *file_gamma = info_ptr->gamma; |
668 | 0 | return PNG_INFO_gAMA; |
669 | 0 | } |
670 | | |
671 | 0 | return 0; |
672 | 0 | } |
673 | | # endif |
674 | | |
675 | | # ifdef PNG_FLOATING_POINT_SUPPORTED |
676 | | png_uint_32 |
677 | | png_get_gAMA(const png_struct *png_ptr, const png_info *info_ptr, |
678 | | double *file_gamma) |
679 | 184k | { |
680 | 184k | png_debug1(1, "in %s retrieval function", "gAMA(float)"); |
681 | | |
682 | | /* PNGv3 compatibility: only report gAMA if it is really present. */ |
683 | 184k | if (png_ptr != NULL && info_ptr != NULL && |
684 | 184k | (info_ptr->valid & PNG_INFO_gAMA) != 0) |
685 | 2.14k | { |
686 | 2.14k | if (file_gamma != NULL) |
687 | 2.14k | *file_gamma = png_float(png_ptr, info_ptr->gamma, "gAMA"); |
688 | | |
689 | 2.14k | return PNG_INFO_gAMA; |
690 | 2.14k | } |
691 | | |
692 | 182k | return 0; |
693 | 184k | } |
694 | | # endif |
695 | | #endif |
696 | | |
697 | | #ifdef PNG_sRGB_SUPPORTED |
698 | | png_uint_32 |
699 | | png_get_sRGB(const png_struct *png_ptr, const png_info *info_ptr, |
700 | | int *file_srgb_intent) |
701 | 184k | { |
702 | 184k | png_debug1(1, "in %s retrieval function", "sRGB"); |
703 | | |
704 | 184k | if (png_ptr != NULL && info_ptr != NULL && |
705 | 184k | (info_ptr->valid & PNG_INFO_sRGB) != 0) |
706 | 7.95k | { |
707 | 7.95k | if (file_srgb_intent != NULL) |
708 | 7.95k | *file_srgb_intent = info_ptr->rendering_intent; |
709 | 7.95k | return PNG_INFO_sRGB; |
710 | 7.95k | } |
711 | | |
712 | 176k | return 0; |
713 | 184k | } |
714 | | #endif |
715 | | |
716 | | #ifdef PNG_iCCP_SUPPORTED |
717 | | png_uint_32 |
718 | | png_get_iCCP(const png_struct *png_ptr, png_info *info_ptr, |
719 | | char **name, int *compression_type, |
720 | | png_byte **profile, png_uint_32 *proflen) |
721 | 194 | { |
722 | 194 | png_debug1(1, "in %s retrieval function", "iCCP"); |
723 | | |
724 | 194 | if (png_ptr != NULL && info_ptr != NULL && |
725 | 194 | (info_ptr->valid & PNG_INFO_iCCP) != 0 && |
726 | 194 | name != NULL && profile != NULL && proflen != NULL) |
727 | 194 | { |
728 | 194 | *name = info_ptr->iccp_name; |
729 | 194 | *profile = info_ptr->iccp_profile; |
730 | 194 | *proflen = png_get_uint_32(info_ptr->iccp_profile); |
731 | | /* This is somewhat irrelevant since the profile data returned has |
732 | | * actually been uncompressed. |
733 | | */ |
734 | 194 | if (compression_type != NULL) |
735 | 194 | *compression_type = PNG_COMPRESSION_TYPE_BASE; |
736 | 194 | return PNG_INFO_iCCP; |
737 | 194 | } |
738 | | |
739 | 0 | return 0; |
740 | 194 | } |
741 | | #endif |
742 | | |
743 | | #ifdef PNG_sPLT_SUPPORTED |
744 | | int |
745 | | png_get_sPLT(const png_struct *png_ptr, png_info *info_ptr, |
746 | | png_sPLT_t **spalettes) |
747 | 0 | { |
748 | 0 | png_debug1(1, "in %s retrieval function", "sPLT"); |
749 | |
|
750 | 0 | if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) |
751 | 0 | { |
752 | 0 | *spalettes = info_ptr->splt_palettes; |
753 | 0 | return info_ptr->splt_palettes_num; |
754 | 0 | } |
755 | | |
756 | 0 | return 0; |
757 | 0 | } |
758 | | #endif |
759 | | |
760 | | #ifdef PNG_cICP_SUPPORTED |
761 | | png_uint_32 |
762 | | png_get_cICP(const png_struct *png_ptr, |
763 | | const png_info *info_ptr, png_byte *colour_primaries, |
764 | | png_byte *transfer_function, png_byte *matrix_coefficients, |
765 | | png_byte *video_full_range_flag) |
766 | 0 | { |
767 | 0 | png_debug1(1, "in %s retrieval function", "cICP"); |
768 | |
|
769 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
770 | 0 | (info_ptr->valid & PNG_INFO_cICP) != 0 && |
771 | 0 | colour_primaries != NULL && transfer_function != NULL && |
772 | 0 | matrix_coefficients != NULL && video_full_range_flag != NULL) |
773 | 0 | { |
774 | 0 | *colour_primaries = info_ptr->cicp_colour_primaries; |
775 | 0 | *transfer_function = info_ptr->cicp_transfer_function; |
776 | 0 | *matrix_coefficients = info_ptr->cicp_matrix_coefficients; |
777 | 0 | *video_full_range_flag = info_ptr->cicp_video_full_range_flag; |
778 | 0 | return (PNG_INFO_cICP); |
779 | 0 | } |
780 | | |
781 | 0 | return 0; |
782 | 0 | } |
783 | | #endif |
784 | | |
785 | | #ifdef PNG_cLLI_SUPPORTED |
786 | | # ifdef PNG_FIXED_POINT_SUPPORTED |
787 | | png_uint_32 |
788 | | png_get_cLLI_fixed(const png_struct *png_ptr, const png_info *info_ptr, |
789 | | png_uint_32 *maxCLL, |
790 | | png_uint_32 *maxFALL) |
791 | 0 | { |
792 | 0 | png_debug1(1, "in %s retrieval function", "cLLI"); |
793 | |
|
794 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
795 | 0 | (info_ptr->valid & PNG_INFO_cLLI) != 0) |
796 | 0 | { |
797 | 0 | if (maxCLL != NULL) *maxCLL = info_ptr->maxCLL; |
798 | 0 | if (maxFALL != NULL) *maxFALL = info_ptr->maxFALL; |
799 | 0 | return PNG_INFO_cLLI; |
800 | 0 | } |
801 | | |
802 | 0 | return 0; |
803 | 0 | } |
804 | | # endif |
805 | | |
806 | | # ifdef PNG_FLOATING_POINT_SUPPORTED |
807 | | png_uint_32 |
808 | | png_get_cLLI(const png_struct *png_ptr, const png_info *info_ptr, |
809 | | double *maxCLL, double *maxFALL) |
810 | 0 | { |
811 | 0 | png_debug1(1, "in %s retrieval function", "cLLI(float)"); |
812 | |
|
813 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
814 | 0 | (info_ptr->valid & PNG_INFO_cLLI) != 0) |
815 | 0 | { |
816 | 0 | if (maxCLL != NULL) *maxCLL = info_ptr->maxCLL * .0001; |
817 | 0 | if (maxFALL != NULL) *maxFALL = info_ptr->maxFALL * .0001; |
818 | 0 | return PNG_INFO_cLLI; |
819 | 0 | } |
820 | | |
821 | 0 | return 0; |
822 | 0 | } |
823 | | # endif |
824 | | #endif /* cLLI */ |
825 | | |
826 | | #ifdef PNG_mDCV_SUPPORTED |
827 | | # ifdef PNG_FIXED_POINT_SUPPORTED |
828 | | png_uint_32 |
829 | | png_get_mDCV_fixed(const png_struct *png_ptr, const png_info *info_ptr, |
830 | | png_fixed_point *white_x, png_fixed_point *white_y, |
831 | | png_fixed_point *red_x, png_fixed_point *red_y, |
832 | | png_fixed_point *green_x, png_fixed_point *green_y, |
833 | | png_fixed_point *blue_x, png_fixed_point *blue_y, |
834 | | png_uint_32 *mastering_maxDL, png_uint_32 *mastering_minDL) |
835 | 0 | { |
836 | 0 | png_debug1(1, "in %s retrieval function", "mDCV"); |
837 | |
|
838 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
839 | 0 | (info_ptr->valid & PNG_INFO_mDCV) != 0) |
840 | 0 | { |
841 | 0 | if (white_x != NULL) *white_x = info_ptr->mastering_white_x * 2; |
842 | 0 | if (white_y != NULL) *white_y = info_ptr->mastering_white_y * 2; |
843 | 0 | if (red_x != NULL) *red_x = info_ptr->mastering_red_x * 2; |
844 | 0 | if (red_y != NULL) *red_y = info_ptr->mastering_red_y * 2; |
845 | 0 | if (green_x != NULL) *green_x = info_ptr->mastering_green_x * 2; |
846 | 0 | if (green_y != NULL) *green_y = info_ptr->mastering_green_y * 2; |
847 | 0 | if (blue_x != NULL) *blue_x = info_ptr->mastering_blue_x * 2; |
848 | 0 | if (blue_y != NULL) *blue_y = info_ptr->mastering_blue_y * 2; |
849 | 0 | if (mastering_maxDL != NULL) *mastering_maxDL = info_ptr->mastering_maxDL; |
850 | 0 | if (mastering_minDL != NULL) *mastering_minDL = info_ptr->mastering_minDL; |
851 | 0 | return PNG_INFO_mDCV; |
852 | 0 | } |
853 | | |
854 | 0 | return 0; |
855 | 0 | } |
856 | | # endif |
857 | | |
858 | | # ifdef PNG_FLOATING_POINT_SUPPORTED |
859 | | png_uint_32 |
860 | | png_get_mDCV(const png_struct *png_ptr, const png_info *info_ptr, |
861 | | double *white_x, double *white_y, double *red_x, double *red_y, |
862 | | double *green_x, double *green_y, double *blue_x, double *blue_y, |
863 | | double *mastering_maxDL, double *mastering_minDL) |
864 | 0 | { |
865 | 0 | png_debug1(1, "in %s retrieval function", "mDCV(float)"); |
866 | |
|
867 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
868 | 0 | (info_ptr->valid & PNG_INFO_mDCV) != 0) |
869 | 0 | { |
870 | 0 | if (white_x != NULL) *white_x = info_ptr->mastering_white_x * .00002; |
871 | 0 | if (white_y != NULL) *white_y = info_ptr->mastering_white_y * .00002; |
872 | 0 | if (red_x != NULL) *red_x = info_ptr->mastering_red_x * .00002; |
873 | 0 | if (red_y != NULL) *red_y = info_ptr->mastering_red_y * .00002; |
874 | 0 | if (green_x != NULL) *green_x = info_ptr->mastering_green_x * .00002; |
875 | 0 | if (green_y != NULL) *green_y = info_ptr->mastering_green_y * .00002; |
876 | 0 | if (blue_x != NULL) *blue_x = info_ptr->mastering_blue_x * .00002; |
877 | 0 | if (blue_y != NULL) *blue_y = info_ptr->mastering_blue_y * .00002; |
878 | 0 | if (mastering_maxDL != NULL) |
879 | 0 | *mastering_maxDL = info_ptr->mastering_maxDL * .0001; |
880 | 0 | if (mastering_minDL != NULL) |
881 | 0 | *mastering_minDL = info_ptr->mastering_minDL * .0001; |
882 | 0 | return PNG_INFO_mDCV; |
883 | 0 | } |
884 | | |
885 | 0 | return 0; |
886 | 0 | } |
887 | | # endif /* FLOATING_POINT */ |
888 | | #endif /* mDCV */ |
889 | | |
890 | | #ifdef PNG_eXIf_SUPPORTED |
891 | | png_uint_32 |
892 | | png_get_eXIf_1(const png_struct *png_ptr, const png_info *info_ptr, |
893 | | png_uint_32 *num_exif, png_byte **exif) |
894 | 0 | { |
895 | 0 | png_debug1(1, "in %s retrieval function", "eXIf"); |
896 | |
|
897 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
898 | 0 | (info_ptr->valid & PNG_INFO_eXIf) != 0 && exif != NULL) |
899 | 0 | { |
900 | 0 | *num_exif = info_ptr->num_exif; |
901 | 0 | *exif = info_ptr->exif; |
902 | 0 | return PNG_INFO_eXIf; |
903 | 0 | } |
904 | | |
905 | 0 | return 0; |
906 | 0 | } |
907 | | #endif |
908 | | |
909 | | #ifdef PNG_hIST_SUPPORTED |
910 | | png_uint_32 |
911 | | png_get_hIST(const png_struct *png_ptr, png_info *info_ptr, |
912 | | png_uint_16 **hist) |
913 | 0 | { |
914 | 0 | png_debug1(1, "in %s retrieval function", "hIST"); |
915 | |
|
916 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
917 | 0 | (info_ptr->valid & PNG_INFO_hIST) != 0 && hist != NULL) |
918 | 0 | { |
919 | 0 | *hist = info_ptr->hist; |
920 | 0 | return PNG_INFO_hIST; |
921 | 0 | } |
922 | | |
923 | 0 | return 0; |
924 | 0 | } |
925 | | #endif |
926 | | |
927 | | png_uint_32 |
928 | | png_get_IHDR(const png_struct *png_ptr, const png_info *info_ptr, |
929 | | png_uint_32 *width, png_uint_32 *height, int *bit_depth, |
930 | | int *color_type, int *interlace_type, int *compression_type, |
931 | | int *filter_type) |
932 | 92.2k | { |
933 | 92.2k | png_debug1(1, "in %s retrieval function", "IHDR"); |
934 | | |
935 | 92.2k | if (png_ptr == NULL || info_ptr == NULL) |
936 | 0 | return 0; |
937 | | |
938 | 92.2k | if (width != NULL) |
939 | 92.2k | *width = info_ptr->width; |
940 | | |
941 | 92.2k | if (height != NULL) |
942 | 92.2k | *height = info_ptr->height; |
943 | | |
944 | 92.2k | if (bit_depth != NULL) |
945 | 92.2k | *bit_depth = info_ptr->bit_depth; |
946 | | |
947 | 92.2k | if (color_type != NULL) |
948 | 92.2k | *color_type = info_ptr->color_type; |
949 | | |
950 | 92.2k | if (compression_type != NULL) |
951 | 92.2k | *compression_type = info_ptr->compression_type; |
952 | | |
953 | 92.2k | if (filter_type != NULL) |
954 | 92.2k | *filter_type = info_ptr->filter_type; |
955 | | |
956 | 92.2k | if (interlace_type != NULL) |
957 | 92.2k | *interlace_type = info_ptr->interlace_type; |
958 | | |
959 | | /* This is redundant if we can be sure that the info_ptr values were all |
960 | | * assigned in png_set_IHDR(). We do the check anyhow in case an |
961 | | * application has ignored our advice not to mess with the members |
962 | | * of info_ptr directly. |
963 | | */ |
964 | 92.2k | png_check_IHDR(png_ptr, info_ptr->width, info_ptr->height, |
965 | 92.2k | info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, |
966 | 92.2k | info_ptr->compression_type, info_ptr->filter_type); |
967 | | |
968 | 92.2k | return 1; |
969 | 92.2k | } |
970 | | |
971 | | #ifdef PNG_oFFs_SUPPORTED |
972 | | png_uint_32 |
973 | | png_get_oFFs(const png_struct *png_ptr, const png_info *info_ptr, |
974 | | png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) |
975 | 0 | { |
976 | 0 | png_debug1(1, "in %s retrieval function", "oFFs"); |
977 | |
|
978 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
979 | 0 | (info_ptr->valid & PNG_INFO_oFFs) != 0 && |
980 | 0 | offset_x != NULL && offset_y != NULL && unit_type != NULL) |
981 | 0 | { |
982 | 0 | *offset_x = info_ptr->x_offset; |
983 | 0 | *offset_y = info_ptr->y_offset; |
984 | 0 | *unit_type = (int)info_ptr->offset_unit_type; |
985 | 0 | return PNG_INFO_oFFs; |
986 | 0 | } |
987 | | |
988 | 0 | return 0; |
989 | 0 | } |
990 | | #endif |
991 | | |
992 | | #ifdef PNG_pCAL_SUPPORTED |
993 | | png_uint_32 |
994 | | png_get_pCAL(const png_struct *png_ptr, png_info *info_ptr, |
995 | | char **purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, |
996 | | char **units, char ***params) |
997 | 0 | { |
998 | 0 | png_debug1(1, "in %s retrieval function", "pCAL"); |
999 | |
|
1000 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
1001 | 0 | (info_ptr->valid & PNG_INFO_pCAL) != 0 && |
1002 | 0 | purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && |
1003 | 0 | nparams != NULL && units != NULL && params != NULL) |
1004 | 0 | { |
1005 | 0 | *purpose = info_ptr->pcal_purpose; |
1006 | 0 | *X0 = info_ptr->pcal_X0; |
1007 | 0 | *X1 = info_ptr->pcal_X1; |
1008 | 0 | *type = (int)info_ptr->pcal_type; |
1009 | 0 | *nparams = (int)info_ptr->pcal_nparams; |
1010 | 0 | *units = info_ptr->pcal_units; |
1011 | 0 | *params = info_ptr->pcal_params; |
1012 | 0 | return PNG_INFO_pCAL; |
1013 | 0 | } |
1014 | | |
1015 | 0 | return 0; |
1016 | 0 | } |
1017 | | #endif |
1018 | | |
1019 | | #ifdef PNG_sCAL_SUPPORTED |
1020 | | # ifdef PNG_FIXED_POINT_SUPPORTED |
1021 | | # if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ |
1022 | | defined(PNG_FLOATING_POINT_SUPPORTED) |
1023 | | png_uint_32 |
1024 | | png_get_sCAL_fixed(const png_struct *png_ptr, const png_info *info_ptr, |
1025 | | int *unit, png_fixed_point *width, png_fixed_point *height) |
1026 | 0 | { |
1027 | 0 | png_debug1(1, "in %s retrieval function", "sCAL"); |
1028 | |
|
1029 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
1030 | 0 | (info_ptr->valid & PNG_INFO_sCAL) != 0) |
1031 | 0 | { |
1032 | 0 | *unit = info_ptr->scal_unit; |
1033 | | /*TODO: make this work without FP support; the API is currently eliminated |
1034 | | * if neither floating point APIs nor internal floating point arithmetic |
1035 | | * are enabled. |
1036 | | */ |
1037 | 0 | *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width"); |
1038 | 0 | *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height), |
1039 | 0 | "sCAL height"); |
1040 | 0 | return PNG_INFO_sCAL; |
1041 | 0 | } |
1042 | | |
1043 | 0 | return 0; |
1044 | 0 | } |
1045 | | # endif /* FLOATING_ARITHMETIC */ |
1046 | | # endif /* FIXED_POINT */ |
1047 | | # ifdef PNG_FLOATING_POINT_SUPPORTED |
1048 | | png_uint_32 |
1049 | | png_get_sCAL(const png_struct *png_ptr, const png_info *info_ptr, |
1050 | | int *unit, double *width, double *height) |
1051 | 0 | { |
1052 | 0 | png_debug1(1, "in %s retrieval function", "sCAL(float)"); |
1053 | |
|
1054 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
1055 | 0 | (info_ptr->valid & PNG_INFO_sCAL) != 0) |
1056 | 0 | { |
1057 | 0 | *unit = info_ptr->scal_unit; |
1058 | 0 | *width = atof(info_ptr->scal_s_width); |
1059 | 0 | *height = atof(info_ptr->scal_s_height); |
1060 | 0 | return PNG_INFO_sCAL; |
1061 | 0 | } |
1062 | | |
1063 | 0 | return 0; |
1064 | 0 | } |
1065 | | # endif /* FLOATING POINT */ |
1066 | | png_uint_32 |
1067 | | png_get_sCAL_s(const png_struct *png_ptr, const png_info *info_ptr, |
1068 | | int *unit, char **width, char **height) |
1069 | 0 | { |
1070 | 0 | png_debug1(1, "in %s retrieval function", "sCAL(str)"); |
1071 | |
|
1072 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
1073 | 0 | (info_ptr->valid & PNG_INFO_sCAL) != 0) |
1074 | 0 | { |
1075 | 0 | *unit = info_ptr->scal_unit; |
1076 | 0 | *width = info_ptr->scal_s_width; |
1077 | 0 | *height = info_ptr->scal_s_height; |
1078 | 0 | return PNG_INFO_sCAL; |
1079 | 0 | } |
1080 | | |
1081 | 0 | return 0; |
1082 | 0 | } |
1083 | | #endif /* sCAL */ |
1084 | | |
1085 | | #ifdef PNG_pHYs_SUPPORTED |
1086 | | png_uint_32 |
1087 | | png_get_pHYs(const png_struct *png_ptr, const png_info *info_ptr, |
1088 | | png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) |
1089 | 6.20k | { |
1090 | 6.20k | png_uint_32 retval = 0; |
1091 | | |
1092 | 6.20k | png_debug1(1, "in %s retrieval function", "pHYs"); |
1093 | | |
1094 | 6.20k | if (png_ptr != NULL && info_ptr != NULL && |
1095 | 6.20k | (info_ptr->valid & PNG_INFO_pHYs) != 0) |
1096 | 6.20k | { |
1097 | 6.20k | if (res_x != NULL) |
1098 | 6.20k | { |
1099 | 6.20k | *res_x = info_ptr->x_pixels_per_unit; |
1100 | 6.20k | retval |= PNG_INFO_pHYs; |
1101 | 6.20k | } |
1102 | | |
1103 | 6.20k | if (res_y != NULL) |
1104 | 6.20k | { |
1105 | 6.20k | *res_y = info_ptr->y_pixels_per_unit; |
1106 | 6.20k | retval |= PNG_INFO_pHYs; |
1107 | 6.20k | } |
1108 | | |
1109 | 6.20k | if (unit_type != NULL) |
1110 | 6.20k | { |
1111 | 6.20k | *unit_type = (int)info_ptr->phys_unit_type; |
1112 | 6.20k | retval |= PNG_INFO_pHYs; |
1113 | 6.20k | } |
1114 | 6.20k | } |
1115 | | |
1116 | 6.20k | return retval; |
1117 | 6.20k | } |
1118 | | #endif /* pHYs */ |
1119 | | |
1120 | | png_uint_32 |
1121 | | png_get_PLTE(const png_struct *png_ptr, png_info *info_ptr, |
1122 | | png_color **palette, int *num_palette) |
1123 | 24.6k | { |
1124 | 24.6k | png_debug1(1, "in %s retrieval function", "PLTE"); |
1125 | | |
1126 | 24.6k | if (png_ptr != NULL && info_ptr != NULL && |
1127 | 24.6k | (info_ptr->valid & PNG_INFO_PLTE) != 0 && palette != NULL) |
1128 | 24.6k | { |
1129 | 24.6k | *palette = info_ptr->palette; |
1130 | 24.6k | *num_palette = info_ptr->num_palette; |
1131 | 24.6k | png_debug1(3, "num_palette = %d", *num_palette); |
1132 | 24.6k | return PNG_INFO_PLTE; |
1133 | 24.6k | } |
1134 | | |
1135 | 0 | return 0; |
1136 | 24.6k | } |
1137 | | |
1138 | | #ifdef PNG_sBIT_SUPPORTED |
1139 | | png_uint_32 |
1140 | | png_get_sBIT(const png_struct *png_ptr, png_info *info_ptr, |
1141 | | png_color_8 **sig_bit) |
1142 | 0 | { |
1143 | 0 | png_debug1(1, "in %s retrieval function", "sBIT"); |
1144 | |
|
1145 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
1146 | 0 | (info_ptr->valid & PNG_INFO_sBIT) != 0 && sig_bit != NULL) |
1147 | 0 | { |
1148 | 0 | *sig_bit = &(info_ptr->sig_bit); |
1149 | 0 | return PNG_INFO_sBIT; |
1150 | 0 | } |
1151 | | |
1152 | 0 | return 0; |
1153 | 0 | } |
1154 | | #endif |
1155 | | |
1156 | | #ifdef PNG_TEXT_SUPPORTED |
1157 | | int |
1158 | | png_get_text(const png_struct *png_ptr, png_info *info_ptr, |
1159 | | png_text **text_ptr, int *num_text) |
1160 | 58.7k | { |
1161 | 58.7k | if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) |
1162 | 13.2k | { |
1163 | 13.2k | png_debug1(1, "in text retrieval function, chunk typeid = 0x%lx", |
1164 | 13.2k | (unsigned long)png_ptr->chunk_name); |
1165 | | |
1166 | 13.2k | if (text_ptr != NULL) |
1167 | 13.2k | *text_ptr = info_ptr->text; |
1168 | | |
1169 | 13.2k | if (num_text != NULL) |
1170 | 13.2k | *num_text = info_ptr->num_text; |
1171 | | |
1172 | 13.2k | return info_ptr->num_text; |
1173 | 13.2k | } |
1174 | | |
1175 | 45.4k | if (num_text != NULL) |
1176 | 45.4k | *num_text = 0; |
1177 | | |
1178 | 45.4k | return 0; |
1179 | 58.7k | } |
1180 | | #endif |
1181 | | |
1182 | | #ifdef PNG_tIME_SUPPORTED |
1183 | | png_uint_32 |
1184 | | png_get_tIME(const png_struct *png_ptr, png_info *info_ptr, |
1185 | | png_time **mod_time) |
1186 | 0 | { |
1187 | 0 | png_debug1(1, "in %s retrieval function", "tIME"); |
1188 | |
|
1189 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
1190 | 0 | (info_ptr->valid & PNG_INFO_tIME) != 0 && mod_time != NULL) |
1191 | 0 | { |
1192 | 0 | *mod_time = &(info_ptr->mod_time); |
1193 | 0 | return PNG_INFO_tIME; |
1194 | 0 | } |
1195 | | |
1196 | 0 | return 0; |
1197 | 0 | } |
1198 | | #endif |
1199 | | |
1200 | | #ifdef PNG_tRNS_SUPPORTED |
1201 | | png_uint_32 |
1202 | | png_get_tRNS(const png_struct *png_ptr, png_info *info_ptr, |
1203 | | png_byte **trans_alpha, int *num_trans, png_color_16 **trans_color) |
1204 | 92.2k | { |
1205 | 92.2k | png_uint_32 retval = 0; |
1206 | | |
1207 | 92.2k | png_debug1(1, "in %s retrieval function", "tRNS"); |
1208 | | |
1209 | 92.2k | if (png_ptr != NULL && info_ptr != NULL && |
1210 | 92.2k | (info_ptr->valid & PNG_INFO_tRNS) != 0) |
1211 | 14.9k | { |
1212 | 14.9k | if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) |
1213 | 4.24k | { |
1214 | 4.24k | if (trans_alpha != NULL) |
1215 | 4.24k | { |
1216 | 4.24k | *trans_alpha = info_ptr->trans_alpha; |
1217 | 4.24k | retval |= PNG_INFO_tRNS; |
1218 | 4.24k | } |
1219 | | |
1220 | 4.24k | if (trans_color != NULL) |
1221 | 4.24k | *trans_color = &(info_ptr->trans_color); |
1222 | 4.24k | } |
1223 | | |
1224 | 10.6k | else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ |
1225 | 10.6k | { |
1226 | 10.6k | if (trans_color != NULL) |
1227 | 10.6k | { |
1228 | 10.6k | *trans_color = &(info_ptr->trans_color); |
1229 | 10.6k | retval |= PNG_INFO_tRNS; |
1230 | 10.6k | } |
1231 | | |
1232 | 10.6k | if (trans_alpha != NULL) |
1233 | 10.6k | *trans_alpha = NULL; |
1234 | 10.6k | } |
1235 | | |
1236 | 14.9k | if (num_trans != NULL) |
1237 | 14.9k | { |
1238 | 14.9k | *num_trans = info_ptr->num_trans; |
1239 | 14.9k | retval |= PNG_INFO_tRNS; |
1240 | 14.9k | } |
1241 | 14.9k | } |
1242 | | |
1243 | 92.2k | return retval; |
1244 | 92.2k | } |
1245 | | #endif |
1246 | | |
1247 | | #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED |
1248 | | int |
1249 | | png_get_unknown_chunks(const png_struct *png_ptr, png_info *info_ptr, |
1250 | | png_unknown_chunk **unknowns) |
1251 | 0 | { |
1252 | 0 | if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL) |
1253 | 0 | { |
1254 | 0 | *unknowns = info_ptr->unknown_chunks; |
1255 | 0 | return info_ptr->unknown_chunks_num; |
1256 | 0 | } |
1257 | | |
1258 | 0 | return 0; |
1259 | 0 | } |
1260 | | #endif |
1261 | | |
1262 | | #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED |
1263 | | png_byte |
1264 | | png_get_rgb_to_gray_status(const png_struct *png_ptr) |
1265 | 0 | { |
1266 | 0 | return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0); |
1267 | 0 | } |
1268 | | #endif |
1269 | | |
1270 | | #ifdef PNG_USER_CHUNKS_SUPPORTED |
1271 | | void * |
1272 | | png_get_user_chunk_ptr(const png_struct *png_ptr) |
1273 | 133k | { |
1274 | 133k | return (png_ptr ? png_ptr->user_chunk_ptr : NULL); |
1275 | 133k | } |
1276 | | #endif |
1277 | | |
1278 | | size_t |
1279 | | png_get_compression_buffer_size(const png_struct *png_ptr) |
1280 | 0 | { |
1281 | 0 | if (png_ptr == NULL) |
1282 | 0 | return 0; |
1283 | | |
1284 | 0 | #ifdef PNG_WRITE_SUPPORTED |
1285 | 0 | if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0) |
1286 | 0 | #endif |
1287 | 0 | { |
1288 | 0 | #ifdef PNG_SEQUENTIAL_READ_SUPPORTED |
1289 | 0 | return png_ptr->IDAT_read_size; |
1290 | | #else |
1291 | | return PNG_IDAT_READ_SIZE; |
1292 | | #endif |
1293 | 0 | } |
1294 | | |
1295 | 0 | #ifdef PNG_WRITE_SUPPORTED |
1296 | 0 | else |
1297 | 0 | return png_ptr->zbuffer_size; |
1298 | 0 | #endif |
1299 | 0 | } |
1300 | | |
1301 | | #ifdef PNG_SET_USER_LIMITS_SUPPORTED |
1302 | | /* These functions were added to libpng 1.2.6 and were enabled |
1303 | | * by default in libpng-1.4.0 */ |
1304 | | png_uint_32 |
1305 | | png_get_user_width_max(const png_struct *png_ptr) |
1306 | 0 | { |
1307 | 0 | return (png_ptr ? png_ptr->user_width_max : 0); |
1308 | 0 | } |
1309 | | |
1310 | | png_uint_32 |
1311 | | png_get_user_height_max(const png_struct *png_ptr) |
1312 | 0 | { |
1313 | 0 | return (png_ptr ? png_ptr->user_height_max : 0); |
1314 | 0 | } |
1315 | | |
1316 | | /* This function was added to libpng 1.4.0 */ |
1317 | | png_uint_32 |
1318 | | png_get_chunk_cache_max(const png_struct *png_ptr) |
1319 | 0 | { |
1320 | 0 | return (png_ptr ? png_ptr->user_chunk_cache_max : 0); |
1321 | 0 | } |
1322 | | |
1323 | | /* This function was added to libpng 1.4.1 */ |
1324 | | png_alloc_size_t |
1325 | | png_get_chunk_malloc_max(const png_struct *png_ptr) |
1326 | 0 | { |
1327 | 0 | return (png_ptr ? png_ptr->user_chunk_malloc_max : 0); |
1328 | 0 | } |
1329 | | #endif /* SET_USER_LIMITS */ |
1330 | | |
1331 | | /* These functions were added to libpng 1.4.0 */ |
1332 | | #ifdef PNG_IO_STATE_SUPPORTED |
1333 | | png_uint_32 |
1334 | | png_get_io_state(const png_struct *png_ptr) |
1335 | 0 | { |
1336 | 0 | return png_ptr->io_state; |
1337 | 0 | } |
1338 | | |
1339 | | png_uint_32 |
1340 | | png_get_io_chunk_type(const png_struct *png_ptr) |
1341 | 0 | { |
1342 | 0 | return png_ptr->chunk_name; |
1343 | 0 | } |
1344 | | #endif /* IO_STATE */ |
1345 | | |
1346 | | #ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED |
1347 | | # ifdef PNG_GET_PALETTE_MAX_SUPPORTED |
1348 | | int |
1349 | | png_get_palette_max(const png_struct *png_ptr, const png_info *info_ptr) |
1350 | 0 | { |
1351 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
1352 | 0 | return png_ptr->num_palette_max; |
1353 | | |
1354 | 0 | return -1; |
1355 | 0 | } |
1356 | | # endif |
1357 | | #endif |
1358 | | |
1359 | | #ifdef PNG_APNG_SUPPORTED |
1360 | | png_uint_32 PNGAPI |
1361 | | png_get_acTL(png_struct *png_ptr, png_info *info_ptr, |
1362 | | png_uint_32 *num_frames, png_uint_32 *num_plays) |
1363 | 0 | { |
1364 | 0 | png_debug1(1, "in %s retrieval function", "acTL"); |
1365 | |
|
1366 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
1367 | 0 | (info_ptr->valid & PNG_INFO_acTL) && |
1368 | 0 | num_frames != NULL && num_plays != NULL) |
1369 | 0 | { |
1370 | 0 | *num_frames = info_ptr->num_frames; |
1371 | 0 | *num_plays = info_ptr->num_plays; |
1372 | 0 | return 1; |
1373 | 0 | } |
1374 | | |
1375 | 0 | return 0; |
1376 | 0 | } |
1377 | | |
1378 | | png_uint_32 PNGAPI |
1379 | | png_get_num_frames(png_struct *png_ptr, png_info *info_ptr) |
1380 | 0 | { |
1381 | 0 | png_debug(1, "in png_get_num_frames"); |
1382 | |
|
1383 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
1384 | 0 | return info_ptr->num_frames; |
1385 | 0 | return 0; |
1386 | 0 | } |
1387 | | |
1388 | | png_uint_32 PNGAPI |
1389 | | png_get_num_plays(png_struct *png_ptr, png_info *info_ptr) |
1390 | 0 | { |
1391 | 0 | png_debug(1, "in png_get_num_plays"); |
1392 | |
|
1393 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
1394 | 0 | return info_ptr->num_plays; |
1395 | 0 | return 0; |
1396 | 0 | } |
1397 | | |
1398 | | png_uint_32 PNGAPI |
1399 | | png_get_next_frame_fcTL(png_struct *png_ptr, png_info *info_ptr, |
1400 | | png_uint_32 *width, png_uint_32 *height, |
1401 | | png_uint_32 *x_offset, png_uint_32 *y_offset, |
1402 | | png_uint_16 *delay_num, png_uint_16 *delay_den, |
1403 | | png_byte *dispose_op, png_byte *blend_op) |
1404 | 0 | { |
1405 | 0 | png_debug1(1, "in %s retrieval function", "fcTL"); |
1406 | |
|
1407 | 0 | if (png_ptr != NULL && info_ptr != NULL && |
1408 | 0 | (info_ptr->valid & PNG_INFO_fcTL) && |
1409 | 0 | width != NULL && height != NULL && |
1410 | 0 | x_offset != NULL && y_offset != NULL && |
1411 | 0 | delay_num != NULL && delay_den != NULL && |
1412 | 0 | dispose_op != NULL && blend_op != NULL) |
1413 | 0 | { |
1414 | 0 | *width = info_ptr->next_frame_width; |
1415 | 0 | *height = info_ptr->next_frame_height; |
1416 | 0 | *x_offset = info_ptr->next_frame_x_offset; |
1417 | 0 | *y_offset = info_ptr->next_frame_y_offset; |
1418 | 0 | *delay_num = info_ptr->next_frame_delay_num; |
1419 | 0 | *delay_den = info_ptr->next_frame_delay_den; |
1420 | 0 | *dispose_op = info_ptr->next_frame_dispose_op; |
1421 | 0 | *blend_op = info_ptr->next_frame_blend_op; |
1422 | 0 | return 1; |
1423 | 0 | } |
1424 | | |
1425 | 0 | return 0; |
1426 | 0 | } |
1427 | | |
1428 | | png_uint_32 PNGAPI |
1429 | | png_get_next_frame_width(png_struct *png_ptr, png_info *info_ptr) |
1430 | 0 | { |
1431 | 0 | png_debug(1, "in png_get_next_frame_width"); |
1432 | |
|
1433 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
1434 | 0 | return info_ptr->next_frame_width; |
1435 | 0 | return 0; |
1436 | 0 | } |
1437 | | |
1438 | | png_uint_32 PNGAPI |
1439 | | png_get_next_frame_height(png_struct *png_ptr, png_info *info_ptr) |
1440 | 0 | { |
1441 | 0 | png_debug(1, "in png_get_next_frame_height"); |
1442 | |
|
1443 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
1444 | 0 | return info_ptr->next_frame_height; |
1445 | 0 | return 0; |
1446 | 0 | } |
1447 | | |
1448 | | png_uint_32 PNGAPI |
1449 | | png_get_next_frame_x_offset(png_struct *png_ptr, png_info *info_ptr) |
1450 | 0 | { |
1451 | 0 | png_debug(1, "in png_get_next_frame_x_offset"); |
1452 | |
|
1453 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
1454 | 0 | return info_ptr->next_frame_x_offset; |
1455 | 0 | return 0; |
1456 | 0 | } |
1457 | | |
1458 | | png_uint_32 PNGAPI |
1459 | | png_get_next_frame_y_offset(png_struct *png_ptr, png_info *info_ptr) |
1460 | 0 | { |
1461 | 0 | png_debug(1, "in png_get_next_frame_y_offset"); |
1462 | |
|
1463 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
1464 | 0 | return info_ptr->next_frame_y_offset; |
1465 | 0 | return 0; |
1466 | 0 | } |
1467 | | |
1468 | | png_uint_16 PNGAPI |
1469 | | png_get_next_frame_delay_num(png_struct *png_ptr, png_info *info_ptr) |
1470 | 0 | { |
1471 | 0 | png_debug(1, "in png_get_next_frame_delay_num"); |
1472 | |
|
1473 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
1474 | 0 | return info_ptr->next_frame_delay_num; |
1475 | 0 | return 0; |
1476 | 0 | } |
1477 | | |
1478 | | png_uint_16 PNGAPI |
1479 | | png_get_next_frame_delay_den(png_struct *png_ptr, png_info *info_ptr) |
1480 | 0 | { |
1481 | 0 | png_debug(1, "in png_get_next_frame_delay_den"); |
1482 | |
|
1483 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
1484 | 0 | return info_ptr->next_frame_delay_den; |
1485 | 0 | return 0; |
1486 | 0 | } |
1487 | | |
1488 | | png_byte PNGAPI |
1489 | | png_get_next_frame_dispose_op(png_struct *png_ptr, png_info *info_ptr) |
1490 | 0 | { |
1491 | 0 | png_debug(1, "in png_get_next_frame_dispose_op"); |
1492 | |
|
1493 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
1494 | 0 | return info_ptr->next_frame_dispose_op; |
1495 | 0 | return 0; |
1496 | 0 | } |
1497 | | |
1498 | | png_byte PNGAPI |
1499 | | png_get_next_frame_blend_op(png_struct *png_ptr, png_info *info_ptr) |
1500 | 0 | { |
1501 | 0 | png_debug(1, "in png_get_next_frame_blend_op"); |
1502 | |
|
1503 | 0 | if (png_ptr != NULL && info_ptr != NULL) |
1504 | 0 | return info_ptr->next_frame_blend_op; |
1505 | 0 | return 0; |
1506 | 0 | } |
1507 | | |
1508 | | png_byte PNGAPI |
1509 | | png_get_first_frame_is_hidden(png_struct *png_ptr, png_info *info_ptr) |
1510 | 0 | { |
1511 | 0 | png_debug(1, "in png_first_frame_is_hidden"); |
1512 | |
|
1513 | 0 | if (png_ptr != NULL) |
1514 | 0 | return (png_byte)(png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN); |
1515 | | |
1516 | 0 | PNG_UNUSED(info_ptr) |
1517 | |
|
1518 | 0 | return 0; |
1519 | 0 | } |
1520 | | #endif /* PNG_APNG_SUPPORTED */ |
1521 | | #endif /* READ || WRITE */ |