Rev 1897 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1897 | serge | 1 | |
2 | * |
||
3 | * Last changed in libpng 1.6.1 [March 28, 2013] |
||
3928 | Serge | 4 | * Copyright (c) 1998-2013 Glenn Randers-Pehrson |
5 | * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) |
||
1897 | serge | 6 | * (Version 0.88 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 | |||
15 | |||
16 | |||
17 | |||
18 | |||
19 | png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr, |
||
3928 | Serge | 20 | png_uint_32 flag) |
1897 | serge | 21 | { |
22 | if (png_ptr != NULL && info_ptr != NULL) |
||
23 | return(info_ptr->valid & flag); |
||
24 | |||
25 | |||
26 | } |
||
27 | |||
28 | |||
29 | png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr) |
||
3928 | Serge | 30 | { |
1897 | serge | 31 | if (png_ptr != NULL && info_ptr != NULL) |
32 | return(info_ptr->rowbytes); |
||
33 | |||
34 | |||
35 | } |
||
36 | |||
37 | |||
38 | png_bytepp PNGAPI |
||
39 | png_get_rows(png_const_structrp png_ptr, png_const_inforp info_ptr) |
||
3928 | Serge | 40 | { |
1897 | serge | 41 | if (png_ptr != NULL && info_ptr != NULL) |
42 | return(info_ptr->row_pointers); |
||
43 | |||
44 | |||
45 | } |
||
46 | #endif |
||
47 | |||
48 | |||
49 | /* Easy access to info, added in libpng-0.99 */ |
||
50 | png_uint_32 PNGAPI |
||
51 | png_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr) |
||
3928 | Serge | 52 | { |
1897 | serge | 53 | if (png_ptr != NULL && info_ptr != NULL) |
54 | return info_ptr->width; |
||
55 | |||
56 | |||
57 | } |
||
58 | |||
59 | |||
60 | png_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr) |
||
3928 | Serge | 61 | { |
1897 | serge | 62 | if (png_ptr != NULL && info_ptr != NULL) |
63 | return info_ptr->height; |
||
64 | |||
65 | |||
66 | } |
||
67 | |||
68 | |||
69 | png_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr) |
||
3928 | Serge | 70 | { |
1897 | serge | 71 | if (png_ptr != NULL && info_ptr != NULL) |
72 | return info_ptr->bit_depth; |
||
73 | |||
74 | |||
75 | } |
||
76 | |||
77 | |||
78 | png_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr) |
||
3928 | Serge | 79 | { |
1897 | serge | 80 | if (png_ptr != NULL && info_ptr != NULL) |
81 | return info_ptr->color_type; |
||
82 | |||
83 | |||
84 | } |
||
85 | |||
86 | |||
87 | png_get_filter_type(png_const_structrp png_ptr, png_const_inforp info_ptr) |
||
3928 | Serge | 88 | { |
1897 | serge | 89 | if (png_ptr != NULL && info_ptr != NULL) |
90 | return info_ptr->filter_type; |
||
91 | |||
92 | |||
93 | } |
||
94 | |||
95 | |||
96 | png_get_interlace_type(png_const_structrp png_ptr, png_const_inforp info_ptr) |
||
3928 | Serge | 97 | { |
1897 | serge | 98 | if (png_ptr != NULL && info_ptr != NULL) |
99 | return info_ptr->interlace_type; |
||
100 | |||
101 | |||
102 | } |
||
103 | |||
104 | |||
105 | png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr) |
||
3928 | Serge | 106 | { |
1897 | serge | 107 | if (png_ptr != NULL && info_ptr != NULL) |
108 | return info_ptr->compression_type; |
||
109 | |||
110 | |||
111 | } |
||
112 | |||
113 | |||
114 | png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp |
||
3928 | Serge | 115 | info_ptr) |
116 | { |
||
1897 | serge | 117 | #ifdef PNG_pHYs_SUPPORTED |
118 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) |
||
119 | { |
||
120 | png_debug1(1, "in %s retrieval function", |
||
121 | "png_get_x_pixels_per_meter"); |
||
122 | |||
123 | |||
124 | return (info_ptr->x_pixels_per_unit); |
||
125 | } |
||
126 | #endif |
||
127 | |||
128 | |||
129 | } |
||
130 | |||
131 | |||
132 | png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp |
||
3928 | Serge | 133 | info_ptr) |
134 | { |
||
1897 | serge | 135 | #ifdef PNG_pHYs_SUPPORTED |
136 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) |
||
137 | { |
||
138 | png_debug1(1, "in %s retrieval function", |
||
139 | "png_get_y_pixels_per_meter"); |
||
140 | |||
141 | |||
142 | return (info_ptr->y_pixels_per_unit); |
||
143 | } |
||
144 | #endif |
||
145 | |||
146 | |||
147 | } |
||
148 | |||
149 | |||
150 | png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr) |
||
3928 | Serge | 151 | { |
1897 | serge | 152 | #ifdef PNG_pHYs_SUPPORTED |
153 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) |
||
154 | { |
||
155 | png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter"); |
||
156 | |||
157 | |||
158 | info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit) |
||
159 | return (info_ptr->x_pixels_per_unit); |
||
160 | } |
||
161 | #endif |
||
162 | |||
163 | |||
164 | } |
||
165 | |||
166 | |||
167 | float PNGAPI |
||
168 | png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp |
||
3928 | Serge | 169 | info_ptr) |
170 | { |
||
1897 | serge | 171 | #ifdef PNG_READ_pHYs_SUPPORTED |
172 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) |
||
173 | { |
||
174 | png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); |
||
175 | |||
176 | |||
177 | return ((float)((float)info_ptr->y_pixels_per_unit |
||
178 | /(float)info_ptr->x_pixels_per_unit)); |
||
179 | } |
||
180 | #else |
||
3928 | Serge | 181 | PNG_UNUSED(png_ptr) |
182 | PNG_UNUSED(info_ptr) |
||
183 | #endif |
||
1897 | serge | 184 | |
185 | |||
186 | } |
||
187 | #endif |
||
188 | |||
189 | |||
190 | png_fixed_point PNGAPI |
||
191 | png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr, |
||
3928 | Serge | 192 | png_const_inforp info_ptr) |
193 | { |
||
1897 | serge | 194 | #ifdef PNG_READ_pHYs_SUPPORTED |
195 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs) |
||
196 | && info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 |
||
197 | && info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX |
||
198 | && info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX) |
||
199 | { |
||
200 | png_fixed_point res; |
||
201 | |||
202 | |||
203 | |||
204 | |||
205 | * range of 0..2^31-1; otherwise the cast might overflow. |
||
206 | */ |
||
207 | 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)) |
||
209 | return res; |
||
210 | } |
||
211 | #else |
||
3928 | Serge | 212 | PNG_UNUSED(png_ptr) |
213 | PNG_UNUSED(info_ptr) |
||
214 | #endif |
||
1897 | serge | 215 | |
216 | |||
217 | } |
||
218 | #endif |
||
219 | |||
220 | |||
221 | png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) |
||
3928 | Serge | 222 | { |
1897 | serge | 223 | #ifdef PNG_oFFs_SUPPORTED |
224 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) |
||
225 | { |
||
226 | png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); |
||
227 | |||
228 | |||
229 | return (info_ptr->x_offset); |
||
230 | } |
||
231 | #endif |
||
232 | |||
233 | |||
234 | } |
||
235 | |||
236 | |||
237 | png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) |
||
3928 | Serge | 238 | { |
1897 | serge | 239 | #ifdef PNG_oFFs_SUPPORTED |
240 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) |
||
241 | { |
||
242 | png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); |
||
243 | |||
244 | |||
245 | return (info_ptr->y_offset); |
||
246 | } |
||
247 | #endif |
||
248 | |||
249 | |||
250 | } |
||
251 | |||
252 | |||
253 | png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) |
||
3928 | Serge | 254 | { |
1897 | serge | 255 | #ifdef PNG_oFFs_SUPPORTED |
256 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) |
||
257 | { |
||
258 | png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels"); |
||
259 | |||
260 | |||
261 | return (info_ptr->x_offset); |
||
262 | } |
||
263 | #endif |
||
264 | |||
265 | |||
266 | } |
||
267 | |||
268 | |||
269 | png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) |
||
3928 | Serge | 270 | { |
1897 | serge | 271 | #ifdef PNG_oFFs_SUPPORTED |
272 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) |
||
273 | { |
||
274 | png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels"); |
||
275 | |||
276 | |||
277 | return (info_ptr->y_offset); |
||
278 | } |
||
279 | #endif |
||
280 | |||
281 | |||
282 | } |
||
283 | |||
284 | |||
285 | static png_uint_32 |
||
286 | ppi_from_ppm(png_uint_32 ppm) |
||
287 | { |
||
288 | #if 0 |
||
289 | /* The conversion is *(2.54/100), in binary (32 digits): |
||
290 | * .00000110100000001001110101001001 |
||
291 | */ |
||
292 | png_uint_32 t1001, t1101; |
||
293 | ppm >>= 1; /* .1 */ |
||
294 | t1001 = ppm + (ppm >> 3); /* .1001 */ |
||
295 | t1101 = t1001 + (ppm >> 1); /* .1101 */ |
||
296 | ppm >>= 20; /* .000000000000000000001 */ |
||
297 | t1101 += t1101 >> 15; /* .1101000000000001101 */ |
||
298 | t1001 >>= 11; /* .000000000001001 */ |
||
299 | t1001 += t1001 >> 12; /* .000000000001001000000001001 */ |
||
300 | ppm += t1001; /* .000000000001001000001001001 */ |
||
301 | ppm += t1101; /* .110100000001001110101001001 */ |
||
302 | return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */ |
||
303 | #else |
||
304 | /* The argument is a PNG unsigned integer, so it is not permitted |
||
305 | * to be bigger than 2^31. |
||
306 | */ |
||
307 | png_fixed_point result; |
||
308 | if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127, |
||
309 | 5000)) |
||
310 | return result; |
||
311 | |||
312 | |||
313 | return 0; |
||
314 | #endif |
||
315 | } |
||
316 | |||
317 | |||
318 | png_get_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) |
||
3928 | Serge | 319 | { |
1897 | serge | 320 | return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr)); |
321 | } |
||
322 | |||
323 | |||
324 | png_get_x_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) |
||
3928 | Serge | 325 | { |
1897 | serge | 326 | return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr)); |
327 | } |
||
328 | |||
329 | |||
330 | png_get_y_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) |
||
3928 | Serge | 331 | { |
1897 | serge | 332 | return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr)); |
333 | } |
||
334 | |||
335 | |||
336 | static png_fixed_point |
||
337 | png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns) |
||
3928 | Serge | 338 | { |
1897 | serge | 339 | /* Convert from metres * 1,000,000 to inches * 100,000, meters to |
340 | * inches is simply *(100/2.54), so we want *(10/2.54) == 500/127. |
||
341 | * Notice that this can overflow - a warning is output and 0 is |
||
342 | * returned. |
||
343 | */ |
||
344 | return png_muldiv_warn(png_ptr, microns, 500, 127); |
||
345 | } |
||
346 | |||
347 | |||
348 | png_get_x_offset_inches_fixed(png_const_structrp png_ptr, |
||
3928 | Serge | 349 | png_const_inforp info_ptr) |
350 | { |
||
1897 | serge | 351 | return png_fixed_inches_from_microns(png_ptr, |
352 | png_get_x_offset_microns(png_ptr, info_ptr)); |
||
353 | } |
||
354 | #endif |
||
355 | |||
356 | |||
357 | png_fixed_point PNGAPI |
||
358 | png_get_y_offset_inches_fixed(png_const_structrp png_ptr, |
||
3928 | Serge | 359 | png_const_inforp info_ptr) |
360 | { |
||
1897 | serge | 361 | return png_fixed_inches_from_microns(png_ptr, |
362 | png_get_y_offset_microns(png_ptr, info_ptr)); |
||
363 | } |
||
364 | #endif |
||
365 | |||
366 | |||
367 | float PNGAPI |
||
368 | png_get_x_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr) |
||
3928 | Serge | 369 | { |
1897 | serge | 370 | /* To avoid the overflow do the conversion directly in floating |
371 | * point. |
||
372 | */ |
||
373 | return (float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937); |
||
374 | } |
||
375 | #endif |
||
376 | |||
377 | |||
378 | float PNGAPI |
||
379 | png_get_y_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr) |
||
3928 | Serge | 380 | { |
1897 | serge | 381 | /* To avoid the overflow do the conversion directly in floating |
382 | * point. |
||
383 | */ |
||
384 | return (float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937); |
||
385 | } |
||
386 | #endif |
||
387 | |||
388 | |||
389 | png_uint_32 PNGAPI |
||
390 | png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr, |
||
3928 | Serge | 391 | png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) |
1897 | serge | 392 | { |
393 | png_uint_32 retval = 0; |
||
394 | |||
395 | |||
396 | { |
||
397 | png_debug1(1, "in %s retrieval function", "pHYs"); |
||
398 | |||
399 | |||
400 | { |
||
401 | *res_x = info_ptr->x_pixels_per_unit; |
||
402 | retval |= PNG_INFO_pHYs; |
||
403 | } |
||
404 | |||
405 | |||
406 | { |
||
407 | *res_y = info_ptr->y_pixels_per_unit; |
||
408 | retval |= PNG_INFO_pHYs; |
||
409 | } |
||
410 | |||
411 | |||
412 | { |
||
413 | *unit_type = (int)info_ptr->phys_unit_type; |
||
414 | retval |= PNG_INFO_pHYs; |
||
415 | |||
416 | |||
417 | { |
||
418 | 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); |
||
420 | } |
||
421 | } |
||
422 | } |
||
423 | |||
424 | |||
425 | } |
||
426 | #endif /* PNG_pHYs_SUPPORTED */ |
||
427 | #endif /* PNG_INCH_CONVERSIONS_SUPPORTED */ |
||
428 | |||
429 | |||
430 | |||
431 | |||
432 | |||
433 | |||
3928 | Serge | 434 | |
1897 | serge | 435 | png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr) |
3928 | Serge | 436 | { |
1897 | serge | 437 | if (png_ptr != NULL && info_ptr != NULL) |
438 | return(info_ptr->channels); |
||
439 | |||
440 | |||
441 | } |
||
442 | |||
443 | |||
3928 | Serge | 444 | png_const_bytep PNGAPI |
1897 | serge | 445 | png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr) |
3928 | Serge | 446 | { |
1897 | serge | 447 | if (png_ptr != NULL && info_ptr != NULL) |
448 | return(info_ptr->signature); |
||
449 | |||
450 | |||
451 | } |
||
452 | #endif |
||
3928 | Serge | 453 | |
1897 | serge | 454 | |
455 | png_uint_32 PNGAPI |
||
456 | png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr, |
||
3928 | Serge | 457 | png_color_16p *background) |
1897 | serge | 458 | { |
459 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) |
||
460 | && background != NULL) |
||
461 | { |
||
462 | png_debug1(1, "in %s retrieval function", "bKGD"); |
||
463 | |||
464 | |||
465 | return (PNG_INFO_bKGD); |
||
466 | } |
||
467 | |||
468 | |||
469 | } |
||
470 | #endif |
||
471 | |||
472 | |||
473 | /* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the |
||
3928 | Serge | 474 | * same time to correct the rgb grayscale coefficient defaults obtained from the |
475 | * cHRM chunk in 1.5.4 |
||
476 | */ |
||
477 | # ifdef PNG_FLOATING_POINT_SUPPORTED |
||
1897 | serge | 478 | png_uint_32 PNGAPI |
479 | png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr, |
||
3928 | Serge | 480 | double *white_x, double *white_y, double *red_x, double *red_y, |
1897 | serge | 481 | double *green_x, double *green_y, double *blue_x, double *blue_y) |
482 | { |
||
483 | /* Quiet API change: this code used to only return the end points if a cHRM |
||
3928 | Serge | 484 | * 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 |
||
486 | * the png_set_ APIs merely check that set end points are mutually |
||
487 | * consistent. |
||
488 | */ |
||
489 | if (png_ptr != NULL && info_ptr != NULL && |
||
490 | (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) |
||
491 | { |
||
1897 | serge | 492 | png_debug1(1, "in %s retrieval function", "cHRM"); |
493 | |||
494 | |||
495 | *white_x = png_float(png_ptr, |
||
3928 | Serge | 496 | info_ptr->colorspace.end_points_xy.whitex, "cHRM white X"); |
497 | if (white_y != NULL) |
||
1897 | serge | 498 | *white_y = png_float(png_ptr, |
3928 | Serge | 499 | info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y"); |
500 | if (red_x != NULL) |
||
1897 | serge | 501 | *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx, |
3928 | Serge | 502 | "cHRM red X"); |
503 | if (red_y != NULL) |
||
1897 | serge | 504 | *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy, |
3928 | Serge | 505 | "cHRM red Y"); |
506 | if (green_x != NULL) |
||
1897 | serge | 507 | *green_x = png_float(png_ptr, |
3928 | Serge | 508 | info_ptr->colorspace.end_points_xy.greenx, "cHRM green X"); |
509 | if (green_y != NULL) |
||
1897 | serge | 510 | *green_y = png_float(png_ptr, |
3928 | Serge | 511 | info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y"); |
512 | if (blue_x != NULL) |
||
1897 | serge | 513 | *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex, |
3928 | Serge | 514 | "cHRM blue X"); |
515 | if (blue_y != NULL) |
||
1897 | serge | 516 | *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey, |
3928 | Serge | 517 | "cHRM blue Y"); |
518 | return (PNG_INFO_cHRM); |
||
1897 | serge | 519 | } |
520 | |||
521 | |||
522 | } |
||
523 | |||
3928 | Serge | 524 | |
525 | 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, |
||
527 | double *green_Y, double *green_Z, double *blue_X, double *blue_Y, |
||
528 | double *blue_Z) |
||
529 | { |
||
530 | if (png_ptr != NULL && info_ptr != NULL && |
||
531 | (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) |
||
532 | { |
||
533 | png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)"); |
||
534 | |||
535 | |||
536 | *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X, |
||
537 | "cHRM red X"); |
||
538 | if (red_Y != NULL) |
||
539 | *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y, |
||
540 | "cHRM red Y"); |
||
541 | if (red_Z != NULL) |
||
542 | *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z, |
||
543 | "cHRM red Z"); |
||
544 | if (green_X != NULL) |
||
545 | *green_X = png_float(png_ptr, |
||
546 | info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X"); |
||
547 | if (green_Y != NULL) |
||
548 | *green_Y = png_float(png_ptr, |
||
549 | info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y"); |
||
550 | if (green_Z != NULL) |
||
551 | *green_Z = png_float(png_ptr, |
||
552 | info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z"); |
||
553 | if (blue_X != NULL) |
||
554 | *blue_X = png_float(png_ptr, |
||
555 | info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X"); |
||
556 | if (blue_Y != NULL) |
||
557 | *blue_Y = png_float(png_ptr, |
||
558 | info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y"); |
||
559 | if (blue_Z != NULL) |
||
560 | *blue_Z = png_float(png_ptr, |
||
561 | info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z"); |
||
562 | return (PNG_INFO_cHRM); |
||
563 | } |
||
564 | |||
565 | |||
566 | } |
||
567 | # endif |
||
1897 | serge | 568 | |
569 | |||
570 | png_uint_32 PNGAPI |
||
571 | png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, |
||
3928 | Serge | 572 | 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, |
||
574 | 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, |
||
576 | png_fixed_point *int_blue_Z) |
||
577 | { |
||
578 | if (png_ptr != NULL && info_ptr != NULL && |
||
579 | (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) |
||
580 | { |
||
581 | png_debug1(1, "in %s retrieval function", "cHRM_XYZ"); |
||
582 | |||
583 | |||
584 | *int_red_X = info_ptr->colorspace.end_points_XYZ.red_X; |
||
585 | if (int_red_Y != NULL) |
||
586 | *int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y; |
||
587 | if (int_red_Z != NULL) |
||
588 | *int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z; |
||
589 | if (int_green_X != NULL) |
||
590 | *int_green_X = info_ptr->colorspace.end_points_XYZ.green_X; |
||
591 | if (int_green_Y != NULL) |
||
592 | *int_green_Y = info_ptr->colorspace.end_points_XYZ.green_Y; |
||
593 | if (int_green_Z != NULL) |
||
594 | *int_green_Z = info_ptr->colorspace.end_points_XYZ.green_Z; |
||
595 | if (int_blue_X != NULL) |
||
596 | *int_blue_X = info_ptr->colorspace.end_points_XYZ.blue_X; |
||
597 | if (int_blue_Y != NULL) |
||
598 | *int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y; |
||
599 | if (int_blue_Z != NULL) |
||
600 | *int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z; |
||
601 | return (PNG_INFO_cHRM); |
||
602 | } |
||
603 | |||
604 | |||
605 | } |
||
606 | |||
607 | |||
608 | 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, |
||
1897 | serge | 610 | 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) |
||
612 | { |
||
613 | png_debug1(1, "in %s retrieval function", "cHRM"); |
||
614 | |||
615 | |||
3928 | Serge | 616 | (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) |
617 | { |
||
1897 | serge | 618 | if (white_x != NULL) |
619 | *white_x = info_ptr->colorspace.end_points_xy.whitex; |
||
3928 | Serge | 620 | if (white_y != NULL) |
1897 | serge | 621 | *white_y = info_ptr->colorspace.end_points_xy.whitey; |
3928 | Serge | 622 | if (red_x != NULL) |
1897 | serge | 623 | *red_x = info_ptr->colorspace.end_points_xy.redx; |
3928 | Serge | 624 | if (red_y != NULL) |
1897 | serge | 625 | *red_y = info_ptr->colorspace.end_points_xy.redy; |
3928 | Serge | 626 | if (green_x != NULL) |
1897 | serge | 627 | *green_x = info_ptr->colorspace.end_points_xy.greenx; |
3928 | Serge | 628 | if (green_y != NULL) |
1897 | serge | 629 | *green_y = info_ptr->colorspace.end_points_xy.greeny; |
3928 | Serge | 630 | if (blue_x != NULL) |
1897 | serge | 631 | *blue_x = info_ptr->colorspace.end_points_xy.bluex; |
3928 | Serge | 632 | if (blue_y != NULL) |
1897 | serge | 633 | *blue_y = info_ptr->colorspace.end_points_xy.bluey; |
3928 | Serge | 634 | return (PNG_INFO_cHRM); |
1897 | serge | 635 | } |
636 | |||
637 | |||
638 | } |
||
639 | # endif |
||
640 | #endif |
||
641 | |||
642 | |||
643 | # ifdef PNG_FIXED_POINT_SUPPORTED |
||
3928 | Serge | 644 | png_uint_32 PNGAPI |
645 | png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, |
||
646 | png_fixed_point *file_gamma) |
||
1897 | serge | 647 | { |
648 | png_debug1(1, "in %s retrieval function", "gAMA"); |
||
649 | |||
650 | |||
3928 | Serge | 651 | (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) && |
652 | file_gamma != NULL) |
||
653 | { |
||
1897 | serge | 654 | *file_gamma = info_ptr->colorspace.gamma; |
3928 | Serge | 655 | return (PNG_INFO_gAMA); |
1897 | serge | 656 | } |
657 | |||
658 | |||
659 | } |
||
660 | # endif |
||
3928 | Serge | 661 | |
662 | |||
1897 | serge | 663 | png_uint_32 PNGAPI |
664 | png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr, |
||
3928 | Serge | 665 | double *file_gamma) |
1897 | serge | 666 | { |
667 | png_debug1(1, "in %s retrieval function", "gAMA(float)"); |
||
3928 | Serge | 668 | |
1897 | serge | 669 | |
3928 | Serge | 670 | (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) && |
671 | file_gamma != NULL) |
||
672 | { |
||
673 | *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma, |
||
674 | "png_get_gAMA"); |
||
675 | return (PNG_INFO_gAMA); |
||
676 | } |
||
677 | |||
1897 | serge | 678 | |
3928 | Serge | 679 | } |
1897 | serge | 680 | # endif |
681 | #endif |
||
682 | |||
683 | |||
684 | png_uint_32 PNGAPI |
||
685 | png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr, |
||
3928 | Serge | 686 | int *file_srgb_intent) |
1897 | serge | 687 | { |
688 | png_debug1(1, "in %s retrieval function", "sRGB"); |
||
689 | |||
690 | |||
691 | && file_srgb_intent != NULL) |
||
692 | { |
||
693 | *file_srgb_intent = info_ptr->colorspace.rendering_intent; |
||
3928 | Serge | 694 | return (PNG_INFO_sRGB); |
1897 | serge | 695 | } |
696 | |||
697 | |||
698 | } |
||
699 | #endif |
||
700 | |||
701 | |||
702 | png_uint_32 PNGAPI |
||
703 | png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, |
||
3928 | Serge | 704 | png_charpp name, int *compression_type, |
1897 | serge | 705 | png_bytepp profile, png_uint_32 *proflen) |
706 | { |
||
707 | png_debug1(1, "in %s retrieval function", "iCCP"); |
||
708 | |||
709 | |||
710 | && name != NULL && compression_type != NULL && profile != NULL && |
||
3928 | Serge | 711 | proflen != NULL) |
712 | { |
||
1897 | serge | 713 | *name = info_ptr->iccp_name; |
714 | *profile = info_ptr->iccp_profile; |
||
715 | *proflen = png_get_uint_32(info_ptr->iccp_profile); |
||
3928 | Serge | 716 | /* This is somewhat irrelevant since the profile data returned has |
717 | * actually been uncompressed. |
||
718 | */ |
||
1897 | serge | 719 | *compression_type = PNG_COMPRESSION_TYPE_BASE; |
3928 | Serge | 720 | return (PNG_INFO_iCCP); |
1897 | serge | 721 | } |
722 | |||
723 | |||
724 | } |
||
725 | #endif |
||
726 | |||
727 | |||
728 | int PNGAPI |
||
3928 | Serge | 729 | png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr, |
730 | png_sPLT_tpp spalettes) |
||
1897 | serge | 731 | { |
732 | if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) |
||
733 | { |
||
734 | *spalettes = info_ptr->splt_palettes; |
||
735 | return info_ptr->splt_palettes_num; |
||
3928 | Serge | 736 | } |
1897 | serge | 737 | |
738 | |||
739 | } |
||
740 | #endif |
||
741 | |||
742 | |||
743 | png_uint_32 PNGAPI |
||
744 | png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr, |
||
3928 | Serge | 745 | png_uint_16p *hist) |
1897 | serge | 746 | { |
747 | png_debug1(1, "in %s retrieval function", "hIST"); |
||
748 | |||
749 | |||
750 | && hist != NULL) |
||
751 | { |
||
752 | *hist = info_ptr->hist; |
||
753 | return (PNG_INFO_hIST); |
||
754 | } |
||
755 | |||
756 | |||
757 | } |
||
758 | #endif |
||
759 | |||
760 | |||
761 | png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr, |
||
3928 | Serge | 762 | png_uint_32 *width, png_uint_32 *height, int *bit_depth, |
1897 | serge | 763 | int *color_type, int *interlace_type, int *compression_type, |
764 | int *filter_type) |
||
765 | { |
||
766 | png_debug1(1, "in %s retrieval function", "IHDR"); |
||
767 | |||
768 | |||
769 | height == NULL || bit_depth == NULL || color_type == NULL) |
||
770 | return (0); |
||
771 | |||
772 | |||
773 | *height = info_ptr->height; |
||
774 | *bit_depth = info_ptr->bit_depth; |
||
775 | *color_type = info_ptr->color_type; |
||
776 | |||
777 | |||
778 | *compression_type = info_ptr->compression_type; |
||
779 | |||
780 | |||
781 | *filter_type = info_ptr->filter_type; |
||
782 | |||
783 | |||
784 | *interlace_type = info_ptr->interlace_type; |
||
785 | |||
786 | |||
787 | * 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 |
||
789 | * of info_ptr directly. |
||
790 | */ |
||
791 | png_check_IHDR(png_ptr, info_ptr->width, info_ptr->height, |
||
3928 | Serge | 792 | info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, |
1897 | serge | 793 | info_ptr->compression_type, info_ptr->filter_type); |
794 | |||
795 | |||
796 | } |
||
797 | |||
798 | |||
799 | png_uint_32 PNGAPI |
||
800 | png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr, |
||
3928 | Serge | 801 | png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) |
1897 | serge | 802 | { |
803 | png_debug1(1, "in %s retrieval function", "oFFs"); |
||
804 | |||
805 | |||
806 | && offset_x != NULL && offset_y != NULL && unit_type != NULL) |
||
807 | { |
||
808 | *offset_x = info_ptr->x_offset; |
||
809 | *offset_y = info_ptr->y_offset; |
||
810 | *unit_type = (int)info_ptr->offset_unit_type; |
||
811 | return (PNG_INFO_oFFs); |
||
812 | } |
||
813 | |||
814 | |||
815 | } |
||
816 | #endif |
||
817 | |||
818 | |||
819 | png_uint_32 PNGAPI |
||
820 | png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, |
||
3928 | Serge | 821 | png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, |
1897 | serge | 822 | png_charp *units, png_charpp *params) |
823 | { |
||
824 | png_debug1(1, "in %s retrieval function", "pCAL"); |
||
825 | |||
826 | |||
827 | && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && |
||
828 | nparams != NULL && units != NULL && params != NULL) |
||
829 | { |
||
830 | *purpose = info_ptr->pcal_purpose; |
||
831 | *X0 = info_ptr->pcal_X0; |
||
832 | *X1 = info_ptr->pcal_X1; |
||
833 | *type = (int)info_ptr->pcal_type; |
||
834 | *nparams = (int)info_ptr->pcal_nparams; |
||
835 | *units = info_ptr->pcal_units; |
||
836 | *params = info_ptr->pcal_params; |
||
837 | return (PNG_INFO_pCAL); |
||
838 | } |
||
839 | |||
840 | |||
841 | } |
||
842 | #endif |
||
843 | |||
844 | |||
845 | # ifdef PNG_FIXED_POINT_SUPPORTED |
||
846 | # if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ |
||
3928 | Serge | 847 | defined(PNG_FLOATING_POINT_SUPPORTED) |
848 | png_uint_32 PNGAPI |
||
1897 | serge | 849 | png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, |
3928 | Serge | 850 | int *unit, png_fixed_point *width, png_fixed_point *height) |
1897 | serge | 851 | { |
852 | if (png_ptr != NULL && info_ptr != NULL && |
||
853 | (info_ptr->valid & PNG_INFO_sCAL)) |
||
854 | { |
||
855 | *unit = info_ptr->scal_unit; |
||
856 | /*TODO: make this work without FP support; the API is currently eliminated |
||
3928 | Serge | 857 | * if neither floating point APIs nor internal floating point arithmetic |
858 | * are enabled. |
||
859 | */ |
||
860 | *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width"); |
||
1897 | serge | 861 | *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height), |
862 | "sCAL height"); |
||
863 | return (PNG_INFO_sCAL); |
||
864 | } |
||
865 | |||
866 | |||
867 | } |
||
868 | # endif /* FLOATING_ARITHMETIC */ |
||
869 | # endif /* FIXED_POINT */ |
||
870 | # ifdef PNG_FLOATING_POINT_SUPPORTED |
||
871 | png_uint_32 PNGAPI |
||
872 | png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr, |
||
3928 | Serge | 873 | int *unit, double *width, double *height) |
1897 | serge | 874 | { |
875 | if (png_ptr != NULL && info_ptr != NULL && |
||
876 | (info_ptr->valid & PNG_INFO_sCAL)) |
||
877 | { |
||
878 | *unit = info_ptr->scal_unit; |
||
879 | *width = atof(info_ptr->scal_s_width); |
||
880 | *height = atof(info_ptr->scal_s_height); |
||
881 | return (PNG_INFO_sCAL); |
||
882 | } |
||
883 | |||
884 | |||
885 | } |
||
886 | # endif /* FLOATING POINT */ |
||
887 | png_uint_32 PNGAPI |
||
888 | png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr, |
||
3928 | Serge | 889 | int *unit, png_charpp width, png_charpp height) |
1897 | serge | 890 | { |
891 | if (png_ptr != NULL && info_ptr != NULL && |
||
892 | (info_ptr->valid & PNG_INFO_sCAL)) |
||
893 | { |
||
894 | *unit = info_ptr->scal_unit; |
||
895 | *width = info_ptr->scal_s_width; |
||
896 | *height = info_ptr->scal_s_height; |
||
897 | return (PNG_INFO_sCAL); |
||
898 | } |
||
899 | |||
900 | |||
901 | } |
||
902 | #endif /* sCAL */ |
||
903 | |||
904 | |||
905 | png_uint_32 PNGAPI |
||
906 | png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr, |
||
3928 | Serge | 907 | png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) |
1897 | serge | 908 | { |
909 | png_uint_32 retval = 0; |
||
910 | |||
911 | |||
912 | |||
913 | |||
914 | (info_ptr->valid & PNG_INFO_pHYs)) |
||
915 | { |
||
916 | if (res_x != NULL) |
||
917 | { |
||
918 | *res_x = info_ptr->x_pixels_per_unit; |
||
919 | retval |= PNG_INFO_pHYs; |
||
920 | } |
||
921 | |||
922 | |||
923 | { |
||
924 | *res_y = info_ptr->y_pixels_per_unit; |
||
925 | retval |= PNG_INFO_pHYs; |
||
926 | } |
||
927 | |||
928 | |||
929 | { |
||
930 | *unit_type = (int)info_ptr->phys_unit_type; |
||
931 | retval |= PNG_INFO_pHYs; |
||
932 | } |
||
933 | } |
||
934 | |||
935 | |||
936 | } |
||
937 | #endif /* pHYs */ |
||
938 | |||
939 | |||
940 | png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr, |
||
3928 | Serge | 941 | png_colorp *palette, int *num_palette) |
1897 | serge | 942 | { |
943 | png_debug1(1, "in %s retrieval function", "PLTE"); |
||
944 | |||
945 | |||
946 | && palette != NULL) |
||
947 | { |
||
948 | *palette = info_ptr->palette; |
||
949 | *num_palette = info_ptr->num_palette; |
||
950 | png_debug1(3, "num_palette = %d", *num_palette); |
||
951 | return (PNG_INFO_PLTE); |
||
952 | } |
||
953 | |||
954 | |||
955 | } |
||
956 | |||
957 | |||
958 | png_uint_32 PNGAPI |
||
959 | png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr, |
||
3928 | Serge | 960 | png_color_8p *sig_bit) |
1897 | serge | 961 | { |
962 | png_debug1(1, "in %s retrieval function", "sBIT"); |
||
963 | |||
964 | |||
965 | && sig_bit != NULL) |
||
966 | { |
||
967 | *sig_bit = &(info_ptr->sig_bit); |
||
968 | return (PNG_INFO_sBIT); |
||
969 | } |
||
970 | |||
971 | |||
972 | } |
||
973 | #endif |
||
974 | |||
975 | |||
976 | int PNGAPI |
||
3928 | Serge | 977 | png_get_text(png_const_structrp png_ptr, png_inforp info_ptr, |
978 | png_textp *text_ptr, int *num_text) |
||
1897 | serge | 979 | { |
980 | if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) |
||
981 | { |
||
982 | png_debug1(1, "in 0x%lx retrieval function", |
||
3928 | Serge | 983 | (unsigned long)png_ptr->chunk_name); |
984 | |||
1897 | serge | 985 | |
986 | *text_ptr = info_ptr->text; |
||
987 | |||
988 | |||
989 | *num_text = info_ptr->num_text; |
||
990 | |||
991 | |||
3928 | Serge | 992 | } |
1897 | serge | 993 | |
994 | |||
995 | *num_text = 0; |
||
996 | |||
997 | |||
998 | } |
||
999 | #endif |
||
1000 | |||
1001 | |||
1002 | png_uint_32 PNGAPI |
||
1003 | png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr, |
||
3928 | Serge | 1004 | png_timep *mod_time) |
1005 | { |
||
1897 | serge | 1006 | png_debug1(1, "in %s retrieval function", "tIME"); |
1007 | |||
1008 | |||
1009 | && mod_time != NULL) |
||
1010 | { |
||
1011 | *mod_time = &(info_ptr->mod_time); |
||
1012 | return (PNG_INFO_tIME); |
||
1013 | } |
||
1014 | |||
1015 | |||
1016 | } |
||
1017 | #endif |
||
1018 | |||
1019 | |||
1020 | png_uint_32 PNGAPI |
||
1021 | png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr, |
||
3928 | Serge | 1022 | png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color) |
1897 | serge | 1023 | { |
1024 | png_uint_32 retval = 0; |
||
1025 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) |
||
1026 | { |
||
1027 | png_debug1(1, "in %s retrieval function", "tRNS"); |
||
1028 | |||
1029 | |||
1030 | { |
||
1031 | if (trans_alpha != NULL) |
||
1032 | { |
||
1033 | *trans_alpha = info_ptr->trans_alpha; |
||
1034 | retval |= PNG_INFO_tRNS; |
||
1035 | } |
||
1036 | |||
1037 | |||
1038 | *trans_color = &(info_ptr->trans_color); |
||
1039 | } |
||
1040 | |||
1041 | |||
1042 | { |
||
1043 | if (trans_color != NULL) |
||
1044 | { |
||
1045 | *trans_color = &(info_ptr->trans_color); |
||
1046 | retval |= PNG_INFO_tRNS; |
||
1047 | } |
||
1048 | |||
1049 | |||
1050 | *trans_alpha = NULL; |
||
1051 | } |
||
1052 | |||
1053 | |||
1054 | { |
||
1055 | *num_trans = info_ptr->num_trans; |
||
1056 | retval |= PNG_INFO_tRNS; |
||
1057 | } |
||
1058 | } |
||
1059 | |||
1060 | |||
1061 | } |
||
1062 | #endif |
||
1063 | |||
1064 | |||
3928 | Serge | 1065 | int PNGAPI |
1897 | serge | 1066 | png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr, |
3928 | Serge | 1067 | png_unknown_chunkpp unknowns) |
1897 | serge | 1068 | { |
1069 | if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL) |
||
1070 | { |
||
1071 | *unknowns = info_ptr->unknown_chunks; |
||
1072 | return info_ptr->unknown_chunks_num; |
||
1073 | } |
||
1074 | |||
1075 | |||
1076 | } |
||
1077 | #endif |
||
1078 | |||
1079 | |||
1080 | png_byte PNGAPI |
||
1081 | png_get_rgb_to_gray_status (png_const_structrp png_ptr) |
||
3928 | Serge | 1082 | { |
1897 | serge | 1083 | return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0); |
1084 | } |
||
1085 | #endif |
||
1086 | |||
1087 | |||
1088 | png_voidp PNGAPI |
||
1089 | png_get_user_chunk_ptr(png_const_structrp png_ptr) |
||
3928 | Serge | 1090 | { |
1897 | serge | 1091 | return (png_ptr ? png_ptr->user_chunk_ptr : NULL); |
1092 | } |
||
1093 | #endif |
||
1094 | |||
1095 | |||
1096 | png_get_compression_buffer_size(png_const_structrp png_ptr) |
||
3928 | Serge | 1097 | { |
1897 | serge | 1098 | if (png_ptr == NULL) |
3928 | Serge | 1099 | return 0; |
1100 | |||
1101 | |||
1102 | if (png_ptr->mode & PNG_IS_READ_STRUCT) |
||
1103 | # endif |
||
1104 | { |
||
1105 | # ifdef PNG_SEQUENTIAL_READ_SUPPORTED |
||
1106 | return png_ptr->IDAT_read_size; |
||
1107 | # else |
||
1108 | return PNG_IDAT_READ_SIZE; |
||
1109 | # endif |
||
1110 | } |
||
1111 | |||
1112 | |||
1113 | else |
||
1114 | return png_ptr->zbuffer_size; |
||
1115 | # endif |
||
1116 | } |
||
1897 | serge | 1117 | |
1118 | |||
1119 | /* These functions were added to libpng 1.2.6 and were enabled |
||
1120 | * by default in libpng-1.4.0 */ |
||
1121 | png_uint_32 PNGAPI |
||
1122 | png_get_user_width_max (png_const_structrp png_ptr) |
||
3928 | Serge | 1123 | { |
1897 | serge | 1124 | return (png_ptr ? png_ptr->user_width_max : 0); |
1125 | } |
||
1126 | |||
1127 | |||
1128 | png_get_user_height_max (png_const_structrp png_ptr) |
||
3928 | Serge | 1129 | { |
1897 | serge | 1130 | return (png_ptr ? png_ptr->user_height_max : 0); |
1131 | } |
||
1132 | |||
1133 | |||
1134 | png_uint_32 PNGAPI |
||
1135 | png_get_chunk_cache_max (png_const_structrp png_ptr) |
||
3928 | Serge | 1136 | { |
1897 | serge | 1137 | return (png_ptr ? png_ptr->user_chunk_cache_max : 0); |
1138 | } |
||
1139 | |||
1140 | |||
1141 | png_alloc_size_t PNGAPI |
||
1142 | png_get_chunk_malloc_max (png_const_structrp png_ptr) |
||
3928 | Serge | 1143 | { |
1897 | serge | 1144 | return (png_ptr ? png_ptr->user_chunk_malloc_max : 0); |
1145 | } |
||
1146 | #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ |
||
1147 | |||
1148 | |||
1149 | #ifdef PNG_IO_STATE_SUPPORTED |
||
1150 | png_uint_32 PNGAPI |
||
1151 | png_get_io_state (png_const_structrp png_ptr) |
||
3928 | Serge | 1152 | { |
1897 | serge | 1153 | return png_ptr->io_state; |
1154 | } |
||
1155 | |||
1156 | |||
1157 | png_get_io_chunk_type (png_const_structrp png_ptr) |
||
3928 | Serge | 1158 | { |
1897 | serge | 1159 | return png_ptr->chunk_name; |
3928 | Serge | 1160 | } |
1897 | serge | 1161 | #endif /* ?PNG_IO_STATE_SUPPORTED */ |
3928 | Serge | 1162 | |
1897 | serge | 1163 | |
3928 | Serge | 1164 | # ifdef PNG_GET_PALETTE_MAX_SUPPORTED |
1165 | int PNGAPI |
||
1166 | png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr) |
||
1167 | { |
||
1897 | serge | 1168 | if (png_ptr != NULL && info_ptr != NULL) |
3928 | Serge | 1169 | return png_ptr->num_palette_max; |
1170 | |||
1171 | |||
1172 | } |
||
1897 | serge | 1173 | # endif |
3928 | Serge | 1174 | #endif |
1175 | |||
1897 | serge | 1176 | |
1177 |