Support unrar64.dll
[xy_vsfilter.git] / src / libpng / pngget.c
blob3b89e6eb940803678017f0dd0058f8151d5593ba
2 /* pngget.c - retrieval of values from info struct
4 * Last changed in libpng 1.2.37 [June 4, 2009]
5 * For conditions of distribution and use, see copyright notice in png.h
6 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
9 */
11 #define PNG_INTERNAL
12 #include "png.h"
13 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
15 png_uint_32 PNGAPI
16 png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
18 if (png_ptr != NULL && info_ptr != NULL)
19 return(info_ptr->valid & flag);
21 else
22 return(0);
25 png_uint_32 PNGAPI
26 png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
28 if (png_ptr != NULL && info_ptr != NULL)
29 return(info_ptr->rowbytes);
31 else
32 return(0);
35 #if defined(PNG_INFO_IMAGE_SUPPORTED)
36 png_bytepp PNGAPI
37 png_get_rows(png_structp png_ptr, png_infop info_ptr)
39 if (png_ptr != NULL && info_ptr != NULL)
40 return(info_ptr->row_pointers);
42 else
43 return(0);
45 #endif
47 #ifdef PNG_EASY_ACCESS_SUPPORTED
48 /* Easy access to info, added in libpng-0.99 */
49 png_uint_32 PNGAPI
50 png_get_image_width(png_structp png_ptr, png_infop info_ptr)
52 if (png_ptr != NULL && info_ptr != NULL)
53 return info_ptr->width;
55 return (0);
58 png_uint_32 PNGAPI
59 png_get_image_height(png_structp png_ptr, png_infop info_ptr)
61 if (png_ptr != NULL && info_ptr != NULL)
62 return info_ptr->height;
64 return (0);
67 png_byte PNGAPI
68 png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
70 if (png_ptr != NULL && info_ptr != NULL)
71 return info_ptr->bit_depth;
73 return (0);
76 png_byte PNGAPI
77 png_get_color_type(png_structp png_ptr, png_infop info_ptr)
79 if (png_ptr != NULL && info_ptr != NULL)
80 return info_ptr->color_type;
82 return (0);
85 png_byte PNGAPI
86 png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
88 if (png_ptr != NULL && info_ptr != NULL)
89 return info_ptr->filter_type;
91 return (0);
94 png_byte PNGAPI
95 png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
97 if (png_ptr != NULL && info_ptr != NULL)
98 return info_ptr->interlace_type;
100 return (0);
103 png_byte PNGAPI
104 png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
106 if (png_ptr != NULL && info_ptr != NULL)
107 return info_ptr->compression_type;
109 return (0);
112 png_uint_32 PNGAPI
113 png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
115 if (png_ptr != NULL && info_ptr != NULL)
116 #if defined(PNG_pHYs_SUPPORTED)
117 if (info_ptr->valid & PNG_INFO_pHYs)
119 png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter");
121 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
122 return (0);
124 else
125 return (info_ptr->x_pixels_per_unit);
127 #else
128 return (0);
129 #endif
130 return (0);
133 png_uint_32 PNGAPI
134 png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
136 if (png_ptr != NULL && info_ptr != NULL)
137 #if defined(PNG_pHYs_SUPPORTED)
138 if (info_ptr->valid & PNG_INFO_pHYs)
140 png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter");
142 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
143 return (0);
145 else
146 return (info_ptr->y_pixels_per_unit);
148 #else
149 return (0);
150 #endif
151 return (0);
154 png_uint_32 PNGAPI
155 png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
157 if (png_ptr != NULL && info_ptr != NULL)
158 #if defined(PNG_pHYs_SUPPORTED)
159 if (info_ptr->valid & PNG_INFO_pHYs)
161 png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
163 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
164 info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
165 return (0);
167 else
168 return (info_ptr->x_pixels_per_unit);
170 #else
171 return (0);
172 #endif
173 return (0);
176 #ifdef PNG_FLOATING_POINT_SUPPORTED
177 float PNGAPI
178 png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
180 if (png_ptr != NULL && info_ptr != NULL)
181 #if defined(PNG_pHYs_SUPPORTED)
183 if (info_ptr->valid & PNG_INFO_pHYs)
185 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
186 if (info_ptr->x_pixels_per_unit == 0)
187 return ((float)0.0);
188 else
189 return ((float)((float)info_ptr->y_pixels_per_unit
190 /(float)info_ptr->x_pixels_per_unit));
192 #else
193 return (0.0);
194 #endif
195 return ((float)0.0);
197 #endif
199 png_int_32 PNGAPI
200 png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
202 if (png_ptr != NULL && info_ptr != NULL)
203 #if defined(PNG_oFFs_SUPPORTED)
205 if (info_ptr->valid & PNG_INFO_oFFs)
207 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
209 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
210 return (0);
212 else
213 return (info_ptr->x_offset);
215 #else
216 return (0);
217 #endif
218 return (0);
221 png_int_32 PNGAPI
222 png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
224 if (png_ptr != NULL && info_ptr != NULL)
226 #if defined(PNG_oFFs_SUPPORTED)
227 if (info_ptr->valid & PNG_INFO_oFFs)
229 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
231 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
232 return (0);
234 else
235 return (info_ptr->y_offset);
237 #else
238 return (0);
239 #endif
240 return (0);
243 png_int_32 PNGAPI
244 png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
246 if (png_ptr != NULL && info_ptr != NULL)
248 #if defined(PNG_oFFs_SUPPORTED)
249 if (info_ptr->valid & PNG_INFO_oFFs)
251 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
253 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
254 return (0);
256 else
257 return (info_ptr->x_offset);
259 #else
260 return (0);
261 #endif
262 return (0);
265 png_int_32 PNGAPI
266 png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
268 if (png_ptr != NULL && info_ptr != NULL)
270 #if defined(PNG_oFFs_SUPPORTED)
271 if (info_ptr->valid & PNG_INFO_oFFs)
273 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
275 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
276 return (0);
278 else
279 return (info_ptr->y_offset);
281 #else
282 return (0);
283 #endif
284 return (0);
287 #if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
288 png_uint_32 PNGAPI
289 png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
291 return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr)
292 *.0254 +.5));
295 png_uint_32 PNGAPI
296 png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
298 return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr)
299 *.0254 +.5));
302 png_uint_32 PNGAPI
303 png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
305 return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr)
306 *.0254 +.5));
309 float PNGAPI
310 png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
312 return ((float)png_get_x_offset_microns(png_ptr, info_ptr)
313 *.00003937);
316 float PNGAPI
317 png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
319 return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
320 *.00003937);
323 #if defined(PNG_pHYs_SUPPORTED)
324 png_uint_32 PNGAPI
325 png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
326 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
328 png_uint_32 retval = 0;
330 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
332 png_debug1(1, "in %s retrieval function", "pHYs");
333 if (res_x != NULL)
335 *res_x = info_ptr->x_pixels_per_unit;
336 retval |= PNG_INFO_pHYs;
338 if (res_y != NULL)
340 *res_y = info_ptr->y_pixels_per_unit;
341 retval |= PNG_INFO_pHYs;
343 if (unit_type != NULL)
345 *unit_type = (int)info_ptr->phys_unit_type;
346 retval |= PNG_INFO_pHYs;
347 if (*unit_type == 1)
349 if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
350 if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
354 return (retval);
356 #endif /* PNG_pHYs_SUPPORTED */
357 #endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
359 /* png_get_channels really belongs in here, too, but it's been around longer */
361 #endif /* PNG_EASY_ACCESS_SUPPORTED */
363 png_byte PNGAPI
364 png_get_channels(png_structp png_ptr, png_infop info_ptr)
366 if (png_ptr != NULL && info_ptr != NULL)
367 return(info_ptr->channels);
368 else
369 return (0);
372 png_bytep PNGAPI
373 png_get_signature(png_structp png_ptr, png_infop info_ptr)
375 if (png_ptr != NULL && info_ptr != NULL)
376 return(info_ptr->signature);
377 else
378 return (NULL);
381 #if defined(PNG_bKGD_SUPPORTED)
382 png_uint_32 PNGAPI
383 png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
384 png_color_16p *background)
386 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
387 && background != NULL)
389 png_debug1(1, "in %s retrieval function", "bKGD");
390 *background = &(info_ptr->background);
391 return (PNG_INFO_bKGD);
393 return (0);
395 #endif
397 #if defined(PNG_cHRM_SUPPORTED)
398 #ifdef PNG_FLOATING_POINT_SUPPORTED
399 png_uint_32 PNGAPI
400 png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
401 double *white_x, double *white_y, double *red_x, double *red_y,
402 double *green_x, double *green_y, double *blue_x, double *blue_y)
404 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
406 png_debug1(1, "in %s retrieval function", "cHRM");
407 if (white_x != NULL)
408 *white_x = (double)info_ptr->x_white;
409 if (white_y != NULL)
410 *white_y = (double)info_ptr->y_white;
411 if (red_x != NULL)
412 *red_x = (double)info_ptr->x_red;
413 if (red_y != NULL)
414 *red_y = (double)info_ptr->y_red;
415 if (green_x != NULL)
416 *green_x = (double)info_ptr->x_green;
417 if (green_y != NULL)
418 *green_y = (double)info_ptr->y_green;
419 if (blue_x != NULL)
420 *blue_x = (double)info_ptr->x_blue;
421 if (blue_y != NULL)
422 *blue_y = (double)info_ptr->y_blue;
423 return (PNG_INFO_cHRM);
425 return (0);
427 #endif
428 #ifdef PNG_FIXED_POINT_SUPPORTED
429 png_uint_32 PNGAPI
430 png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
431 png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
432 png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
433 png_fixed_point *blue_x, png_fixed_point *blue_y)
435 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
437 png_debug1(1, "in %s retrieval function", "cHRM");
438 if (white_x != NULL)
439 *white_x = info_ptr->int_x_white;
440 if (white_y != NULL)
441 *white_y = info_ptr->int_y_white;
442 if (red_x != NULL)
443 *red_x = info_ptr->int_x_red;
444 if (red_y != NULL)
445 *red_y = info_ptr->int_y_red;
446 if (green_x != NULL)
447 *green_x = info_ptr->int_x_green;
448 if (green_y != NULL)
449 *green_y = info_ptr->int_y_green;
450 if (blue_x != NULL)
451 *blue_x = info_ptr->int_x_blue;
452 if (blue_y != NULL)
453 *blue_y = info_ptr->int_y_blue;
454 return (PNG_INFO_cHRM);
456 return (0);
458 #endif
459 #endif
461 #if defined(PNG_gAMA_SUPPORTED)
462 #ifdef PNG_FLOATING_POINT_SUPPORTED
463 png_uint_32 PNGAPI
464 png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
466 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
467 && file_gamma != NULL)
469 png_debug1(1, "in %s retrieval function", "gAMA");
470 *file_gamma = (double)info_ptr->gamma;
471 return (PNG_INFO_gAMA);
473 return (0);
475 #endif
476 #ifdef PNG_FIXED_POINT_SUPPORTED
477 png_uint_32 PNGAPI
478 png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
479 png_fixed_point *int_file_gamma)
481 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
482 && int_file_gamma != NULL)
484 png_debug1(1, "in %s retrieval function", "gAMA");
485 *int_file_gamma = info_ptr->int_gamma;
486 return (PNG_INFO_gAMA);
488 return (0);
490 #endif
491 #endif
493 #if defined(PNG_sRGB_SUPPORTED)
494 png_uint_32 PNGAPI
495 png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
497 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
498 && file_srgb_intent != NULL)
500 png_debug1(1, "in %s retrieval function", "sRGB");
501 *file_srgb_intent = (int)info_ptr->srgb_intent;
502 return (PNG_INFO_sRGB);
504 return (0);
506 #endif
508 #if defined(PNG_iCCP_SUPPORTED)
509 png_uint_32 PNGAPI
510 png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
511 png_charpp name, int *compression_type,
512 png_charpp profile, png_uint_32 *proflen)
514 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
515 && name != NULL && profile != NULL && proflen != NULL)
517 png_debug1(1, "in %s retrieval function", "iCCP");
518 *name = info_ptr->iccp_name;
519 *profile = info_ptr->iccp_profile;
520 /* Compression_type is a dummy so the API won't have to change
521 * if we introduce multiple compression types later.
523 *proflen = (int)info_ptr->iccp_proflen;
524 *compression_type = (int)info_ptr->iccp_compression;
525 return (PNG_INFO_iCCP);
527 return (0);
529 #endif
531 #if defined(PNG_sPLT_SUPPORTED)
532 png_uint_32 PNGAPI
533 png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
534 png_sPLT_tpp spalettes)
536 if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
538 *spalettes = info_ptr->splt_palettes;
539 return ((png_uint_32)info_ptr->splt_palettes_num);
541 return (0);
543 #endif
545 #if defined(PNG_hIST_SUPPORTED)
546 png_uint_32 PNGAPI
547 png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
549 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
550 && hist != NULL)
552 png_debug1(1, "in %s retrieval function", "hIST");
553 *hist = info_ptr->hist;
554 return (PNG_INFO_hIST);
556 return (0);
558 #endif
560 png_uint_32 PNGAPI
561 png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
562 png_uint_32 *width, png_uint_32 *height, int *bit_depth,
563 int *color_type, int *interlace_type, int *compression_type,
564 int *filter_type)
567 if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
568 bit_depth != NULL && color_type != NULL)
570 png_debug1(1, "in %s retrieval function", "IHDR");
571 *width = info_ptr->width;
572 *height = info_ptr->height;
573 *bit_depth = info_ptr->bit_depth;
574 if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16)
575 png_error(png_ptr, "Invalid bit depth");
577 *color_type = info_ptr->color_type;
579 if (info_ptr->color_type > 6)
580 png_error(png_ptr, "Invalid color type");
582 if (compression_type != NULL)
583 *compression_type = info_ptr->compression_type;
585 if (filter_type != NULL)
586 *filter_type = info_ptr->filter_type;
588 if (interlace_type != NULL)
589 *interlace_type = info_ptr->interlace_type;
591 /* Check for potential overflow of rowbytes */
592 if (*width == 0 || *width > PNG_UINT_31_MAX)
593 png_error(png_ptr, "Invalid image width");
595 if (*height == 0 || *height > PNG_UINT_31_MAX)
596 png_error(png_ptr, "Invalid image height");
598 if (info_ptr->width > (PNG_UINT_32_MAX
599 >> 3) /* 8-byte RGBA pixels */
600 - 64 /* bigrowbuf hack */
601 - 1 /* filter byte */
602 - 7*8 /* rounding of width to multiple of 8 pixels */
603 - 8) /* extra max_pixel_depth pad */
605 png_warning(png_ptr,
606 "Width too large for libpng to process image data.");
609 return (1);
611 return (0);
614 #if defined(PNG_oFFs_SUPPORTED)
615 png_uint_32 PNGAPI
616 png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
617 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
619 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
620 && offset_x != NULL && offset_y != NULL && unit_type != NULL)
622 png_debug1(1, "in %s retrieval function", "oFFs");
623 *offset_x = info_ptr->x_offset;
624 *offset_y = info_ptr->y_offset;
625 *unit_type = (int)info_ptr->offset_unit_type;
626 return (PNG_INFO_oFFs);
628 return (0);
630 #endif
632 #if defined(PNG_pCAL_SUPPORTED)
633 png_uint_32 PNGAPI
634 png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
635 png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
636 png_charp *units, png_charpp *params)
638 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
639 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
640 nparams != NULL && units != NULL && params != NULL)
642 png_debug1(1, "in %s retrieval function", "pCAL");
643 *purpose = info_ptr->pcal_purpose;
644 *X0 = info_ptr->pcal_X0;
645 *X1 = info_ptr->pcal_X1;
646 *type = (int)info_ptr->pcal_type;
647 *nparams = (int)info_ptr->pcal_nparams;
648 *units = info_ptr->pcal_units;
649 *params = info_ptr->pcal_params;
650 return (PNG_INFO_pCAL);
652 return (0);
654 #endif
656 #if defined(PNG_sCAL_SUPPORTED)
657 #ifdef PNG_FLOATING_POINT_SUPPORTED
658 png_uint_32 PNGAPI
659 png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
660 int *unit, double *width, double *height)
662 if (png_ptr != NULL && info_ptr != NULL &&
663 (info_ptr->valid & PNG_INFO_sCAL))
665 *unit = info_ptr->scal_unit;
666 *width = info_ptr->scal_pixel_width;
667 *height = info_ptr->scal_pixel_height;
668 return (PNG_INFO_sCAL);
670 return(0);
672 #else
673 #ifdef PNG_FIXED_POINT_SUPPORTED
674 png_uint_32 PNGAPI
675 png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
676 int *unit, png_charpp width, png_charpp height)
678 if (png_ptr != NULL && info_ptr != NULL &&
679 (info_ptr->valid & PNG_INFO_sCAL))
681 *unit = info_ptr->scal_unit;
682 *width = info_ptr->scal_s_width;
683 *height = info_ptr->scal_s_height;
684 return (PNG_INFO_sCAL);
686 return(0);
688 #endif
689 #endif
690 #endif
692 #if defined(PNG_pHYs_SUPPORTED)
693 png_uint_32 PNGAPI
694 png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
695 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
697 png_uint_32 retval = 0;
699 if (png_ptr != NULL && info_ptr != NULL &&
700 (info_ptr->valid & PNG_INFO_pHYs))
702 png_debug1(1, "in %s retrieval function", "pHYs");
704 if (res_x != NULL)
706 *res_x = info_ptr->x_pixels_per_unit;
707 retval |= PNG_INFO_pHYs;
710 if (res_y != NULL)
712 *res_y = info_ptr->y_pixels_per_unit;
713 retval |= PNG_INFO_pHYs;
716 if (unit_type != NULL)
718 *unit_type = (int)info_ptr->phys_unit_type;
719 retval |= PNG_INFO_pHYs;
722 return (retval);
724 #endif
726 png_uint_32 PNGAPI
727 png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
728 int *num_palette)
730 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
731 && palette != NULL)
733 png_debug1(1, "in %s retrieval function", "PLTE");
734 *palette = info_ptr->palette;
735 *num_palette = info_ptr->num_palette;
736 png_debug1(3, "num_palette = %d", *num_palette);
737 return (PNG_INFO_PLTE);
739 return (0);
742 #if defined(PNG_sBIT_SUPPORTED)
743 png_uint_32 PNGAPI
744 png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
746 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
747 && sig_bit != NULL)
749 png_debug1(1, "in %s retrieval function", "sBIT");
750 *sig_bit = &(info_ptr->sig_bit);
751 return (PNG_INFO_sBIT);
753 return (0);
755 #endif
757 #if defined(PNG_TEXT_SUPPORTED)
758 png_uint_32 PNGAPI
759 png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
760 int *num_text)
762 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
764 png_debug1(1, "in %s retrieval function",
765 (png_ptr->chunk_name[0] == '\0' ? "text"
766 : (png_const_charp)png_ptr->chunk_name));
768 if (text_ptr != NULL)
769 *text_ptr = info_ptr->text;
771 if (num_text != NULL)
772 *num_text = info_ptr->num_text;
774 return ((png_uint_32)info_ptr->num_text);
776 if (num_text != NULL)
777 *num_text = 0;
778 return(0);
780 #endif
782 #if defined(PNG_tIME_SUPPORTED)
783 png_uint_32 PNGAPI
784 png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
786 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
787 && mod_time != NULL)
789 png_debug1(1, "in %s retrieval function", "tIME");
790 *mod_time = &(info_ptr->mod_time);
791 return (PNG_INFO_tIME);
793 return (0);
795 #endif
797 #if defined(PNG_tRNS_SUPPORTED)
798 png_uint_32 PNGAPI
799 png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
800 png_bytep *trans, int *num_trans, png_color_16p *trans_values)
802 png_uint_32 retval = 0;
803 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
805 png_debug1(1, "in %s retrieval function", "tRNS");
806 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
808 if (trans != NULL)
810 *trans = info_ptr->trans;
811 retval |= PNG_INFO_tRNS;
814 if (trans_values != NULL)
815 *trans_values = &(info_ptr->trans_values);
817 else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
819 if (trans_values != NULL)
821 *trans_values = &(info_ptr->trans_values);
822 retval |= PNG_INFO_tRNS;
825 if (trans != NULL)
826 *trans = NULL;
828 if (num_trans != NULL)
830 *num_trans = info_ptr->num_trans;
831 retval |= PNG_INFO_tRNS;
834 return (retval);
836 #endif
838 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
839 png_uint_32 PNGAPI
840 png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
841 png_unknown_chunkpp unknowns)
843 if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
845 *unknowns = info_ptr->unknown_chunks;
846 return ((png_uint_32)info_ptr->unknown_chunks_num);
848 return (0);
850 #endif
852 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
853 png_byte PNGAPI
854 png_get_rgb_to_gray_status (png_structp png_ptr)
856 return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0);
858 #endif
860 #if defined(PNG_USER_CHUNKS_SUPPORTED)
861 png_voidp PNGAPI
862 png_get_user_chunk_ptr(png_structp png_ptr)
864 return (png_ptr? png_ptr->user_chunk_ptr : NULL);
866 #endif
868 #ifdef PNG_WRITE_SUPPORTED
869 png_uint_32 PNGAPI
870 png_get_compression_buffer_size(png_structp png_ptr)
872 return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L);
874 #endif
876 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
877 #ifndef PNG_1_0_X
878 /* This function was added to libpng 1.2.0 and should exist by default */
879 png_uint_32 PNGAPI
880 png_get_asm_flags (png_structp png_ptr)
882 /* Obsolete, to be removed from libpng-1.4.0 */
883 return (png_ptr? 0L: 0L);
886 /* This function was added to libpng 1.2.0 and should exist by default */
887 png_uint_32 PNGAPI
888 png_get_asm_flagmask (int flag_select)
890 /* Obsolete, to be removed from libpng-1.4.0 */
891 flag_select=flag_select;
892 return 0L;
895 /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
896 /* This function was added to libpng 1.2.0 */
897 png_uint_32 PNGAPI
898 png_get_mmx_flagmask (int flag_select, int *compilerID)
900 /* Obsolete, to be removed from libpng-1.4.0 */
901 flag_select=flag_select;
902 *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */
903 return 0L;
906 /* This function was added to libpng 1.2.0 */
907 png_byte PNGAPI
908 png_get_mmx_bitdepth_threshold (png_structp png_ptr)
910 /* Obsolete, to be removed from libpng-1.4.0 */
911 return (png_ptr? 0: 0);
914 /* This function was added to libpng 1.2.0 */
915 png_uint_32 PNGAPI
916 png_get_mmx_rowbytes_threshold (png_structp png_ptr)
918 /* Obsolete, to be removed from libpng-1.4.0 */
919 return (png_ptr? 0L: 0L);
921 #endif /* ?PNG_1_0_X */
922 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
924 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
925 /* These functions were added to libpng 1.2.6 */
926 png_uint_32 PNGAPI
927 png_get_user_width_max (png_structp png_ptr)
929 return (png_ptr? png_ptr->user_width_max : 0);
931 png_uint_32 PNGAPI
932 png_get_user_height_max (png_structp png_ptr)
934 return (png_ptr? png_ptr->user_height_max : 0);
936 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
939 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */