remove duplicate friend declaration
[chromium-blink-merge.git] / third_party / libpng / pngget.c
blobd397329a53cd07e4c85dc8b263447c7ea960ea53
2 /* pngget.c - retrieval of values from info struct
4 * Last changed in libpng 1.2.43 [February 25, 2010]
5 * Copyright (c) 1998-2010 Glenn Randers-Pehrson
6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
9 * This code is released under the libpng license.
10 * For conditions of distribution and use, see the disclaimer
11 * and license in png.h
15 #define PNG_INTERNAL
16 #define PNG_NO_PEDANTIC_WARNINGS
17 #include "png.h"
18 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
20 png_uint_32 PNGAPI
21 png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
23 if (png_ptr != NULL && info_ptr != NULL)
24 return(info_ptr->valid & flag);
26 else
27 return(0);
30 png_uint_32 PNGAPI
31 png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
33 if (png_ptr != NULL && info_ptr != NULL)
34 return(info_ptr->rowbytes);
36 else
37 return(0);
40 #ifdef PNG_INFO_IMAGE_SUPPORTED
41 png_bytepp PNGAPI
42 png_get_rows(png_structp png_ptr, png_infop info_ptr)
44 if (png_ptr != NULL && info_ptr != NULL)
45 return(info_ptr->row_pointers);
47 else
48 return(0);
50 #endif
52 #ifdef PNG_EASY_ACCESS_SUPPORTED
53 /* Easy access to info, added in libpng-0.99 */
54 png_uint_32 PNGAPI
55 png_get_image_width(png_structp png_ptr, png_infop info_ptr)
57 if (png_ptr != NULL && info_ptr != NULL)
58 return info_ptr->width;
60 return (0);
63 png_uint_32 PNGAPI
64 png_get_image_height(png_structp png_ptr, png_infop info_ptr)
66 if (png_ptr != NULL && info_ptr != NULL)
67 return info_ptr->height;
69 return (0);
72 png_byte PNGAPI
73 png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
75 if (png_ptr != NULL && info_ptr != NULL)
76 return info_ptr->bit_depth;
78 return (0);
81 png_byte PNGAPI
82 png_get_color_type(png_structp png_ptr, png_infop info_ptr)
84 if (png_ptr != NULL && info_ptr != NULL)
85 return info_ptr->color_type;
87 return (0);
90 png_byte PNGAPI
91 png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
93 if (png_ptr != NULL && info_ptr != NULL)
94 return info_ptr->filter_type;
96 return (0);
99 png_byte PNGAPI
100 png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
102 if (png_ptr != NULL && info_ptr != NULL)
103 return info_ptr->interlace_type;
105 return (0);
108 png_byte PNGAPI
109 png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
111 if (png_ptr != NULL && info_ptr != NULL)
112 return info_ptr->compression_type;
114 return (0);
117 png_uint_32 PNGAPI
118 png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
120 if (png_ptr != NULL && info_ptr != NULL)
121 #ifdef PNG_pHYs_SUPPORTED
122 if (info_ptr->valid & PNG_INFO_pHYs)
124 png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter");
126 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
127 return (0);
129 else
130 return (info_ptr->x_pixels_per_unit);
132 #else
133 return (0);
134 #endif
135 return (0);
138 png_uint_32 PNGAPI
139 png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
141 if (png_ptr != NULL && info_ptr != NULL)
142 #ifdef PNG_pHYs_SUPPORTED
143 if (info_ptr->valid & PNG_INFO_pHYs)
145 png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter");
147 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
148 return (0);
150 else
151 return (info_ptr->y_pixels_per_unit);
153 #else
154 return (0);
155 #endif
156 return (0);
159 png_uint_32 PNGAPI
160 png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
162 if (png_ptr != NULL && info_ptr != NULL)
163 #ifdef PNG_pHYs_SUPPORTED
164 if (info_ptr->valid & PNG_INFO_pHYs)
166 png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
168 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
169 info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
170 return (0);
172 else
173 return (info_ptr->x_pixels_per_unit);
175 #else
176 return (0);
177 #endif
178 return (0);
181 #ifdef PNG_FLOATING_POINT_SUPPORTED
182 float PNGAPI
183 png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
185 if (png_ptr != NULL && info_ptr != NULL)
186 #ifdef PNG_pHYs_SUPPORTED
188 if (info_ptr->valid & PNG_INFO_pHYs)
190 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
192 if (info_ptr->x_pixels_per_unit == 0)
193 return ((float)0.0);
195 else
196 return ((float)((float)info_ptr->y_pixels_per_unit
197 /(float)info_ptr->x_pixels_per_unit));
199 #else
200 return (0.0);
201 #endif
202 return ((float)0.0);
204 #endif
206 png_int_32 PNGAPI
207 png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
209 if (png_ptr != NULL && info_ptr != NULL)
210 #ifdef PNG_oFFs_SUPPORTED
212 if (info_ptr->valid & PNG_INFO_oFFs)
214 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
216 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
217 return (0);
219 else
220 return (info_ptr->x_offset);
222 #else
223 return (0);
224 #endif
225 return (0);
228 png_int_32 PNGAPI
229 png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
231 if (png_ptr != NULL && info_ptr != NULL)
233 #ifdef PNG_oFFs_SUPPORTED
234 if (info_ptr->valid & PNG_INFO_oFFs)
236 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
238 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
239 return (0);
241 else
242 return (info_ptr->y_offset);
244 #else
245 return (0);
246 #endif
247 return (0);
250 png_int_32 PNGAPI
251 png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
253 if (png_ptr != NULL && info_ptr != NULL)
255 #ifdef PNG_oFFs_SUPPORTED
256 if (info_ptr->valid & PNG_INFO_oFFs)
258 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
260 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
261 return (0);
263 else
264 return (info_ptr->x_offset);
266 #else
267 return (0);
268 #endif
269 return (0);
272 png_int_32 PNGAPI
273 png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
275 if (png_ptr != NULL && info_ptr != NULL)
277 #ifdef PNG_oFFs_SUPPORTED
278 if (info_ptr->valid & PNG_INFO_oFFs)
280 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
282 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
283 return (0);
285 else
286 return (info_ptr->y_offset);
288 #else
289 return (0);
290 #endif
291 return (0);
294 #if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
295 png_uint_32 PNGAPI
296 png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
298 return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr)
299 *.0254 +.5));
302 png_uint_32 PNGAPI
303 png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
305 return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr)
306 *.0254 +.5));
309 png_uint_32 PNGAPI
310 png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
312 return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr)
313 *.0254 +.5));
316 float PNGAPI
317 png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
319 return ((float)png_get_x_offset_microns(png_ptr, info_ptr)
320 *.00003937);
323 float PNGAPI
324 png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
326 return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
327 *.00003937);
330 #ifdef PNG_pHYs_SUPPORTED
331 png_uint_32 PNGAPI
332 png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
333 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
335 png_uint_32 retval = 0;
337 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
339 png_debug1(1, "in %s retrieval function", "pHYs");
341 if (res_x != NULL)
343 *res_x = info_ptr->x_pixels_per_unit;
344 retval |= PNG_INFO_pHYs;
346 if (res_y != NULL)
348 *res_y = info_ptr->y_pixels_per_unit;
349 retval |= PNG_INFO_pHYs;
351 if (unit_type != NULL)
353 *unit_type = (int)info_ptr->phys_unit_type;
354 retval |= PNG_INFO_pHYs;
355 if (*unit_type == 1)
357 if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
358 if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
362 return (retval);
364 #endif /* PNG_pHYs_SUPPORTED */
365 #endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
367 /* png_get_channels really belongs in here, too, but it's been around longer */
369 #endif /* PNG_EASY_ACCESS_SUPPORTED */
371 png_byte PNGAPI
372 png_get_channels(png_structp png_ptr, png_infop info_ptr)
374 if (png_ptr != NULL && info_ptr != NULL)
375 return(info_ptr->channels);
376 else
377 return (0);
380 png_bytep PNGAPI
381 png_get_signature(png_structp png_ptr, png_infop info_ptr)
383 if (png_ptr != NULL && info_ptr != NULL)
384 return(info_ptr->signature);
385 else
386 return (NULL);
389 #ifdef PNG_bKGD_SUPPORTED
390 png_uint_32 PNGAPI
391 png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
392 png_color_16p *background)
394 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
395 && background != NULL)
397 png_debug1(1, "in %s retrieval function", "bKGD");
399 *background = &(info_ptr->background);
400 return (PNG_INFO_bKGD);
402 return (0);
404 #endif
406 #ifdef PNG_cHRM_SUPPORTED
407 #ifdef PNG_FLOATING_POINT_SUPPORTED
408 png_uint_32 PNGAPI
409 png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
410 double *white_x, double *white_y, double *red_x, double *red_y,
411 double *green_x, double *green_y, double *blue_x, double *blue_y)
413 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
415 png_debug1(1, "in %s retrieval function", "cHRM");
417 if (white_x != NULL)
418 *white_x = (double)info_ptr->x_white;
419 if (white_y != NULL)
420 *white_y = (double)info_ptr->y_white;
421 if (red_x != NULL)
422 *red_x = (double)info_ptr->x_red;
423 if (red_y != NULL)
424 *red_y = (double)info_ptr->y_red;
425 if (green_x != NULL)
426 *green_x = (double)info_ptr->x_green;
427 if (green_y != NULL)
428 *green_y = (double)info_ptr->y_green;
429 if (blue_x != NULL)
430 *blue_x = (double)info_ptr->x_blue;
431 if (blue_y != NULL)
432 *blue_y = (double)info_ptr->y_blue;
433 return (PNG_INFO_cHRM);
435 return (0);
437 #endif
438 #ifdef PNG_FIXED_POINT_SUPPORTED
439 png_uint_32 PNGAPI
440 png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
441 png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
442 png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
443 png_fixed_point *blue_x, png_fixed_point *blue_y)
445 png_debug1(1, "in %s retrieval function", "cHRM");
447 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
449 if (white_x != NULL)
450 *white_x = info_ptr->int_x_white;
451 if (white_y != NULL)
452 *white_y = info_ptr->int_y_white;
453 if (red_x != NULL)
454 *red_x = info_ptr->int_x_red;
455 if (red_y != NULL)
456 *red_y = info_ptr->int_y_red;
457 if (green_x != NULL)
458 *green_x = info_ptr->int_x_green;
459 if (green_y != NULL)
460 *green_y = info_ptr->int_y_green;
461 if (blue_x != NULL)
462 *blue_x = info_ptr->int_x_blue;
463 if (blue_y != NULL)
464 *blue_y = info_ptr->int_y_blue;
465 return (PNG_INFO_cHRM);
467 return (0);
469 #endif
470 #endif
472 #ifdef PNG_gAMA_SUPPORTED
473 #ifdef PNG_FLOATING_POINT_SUPPORTED
474 png_uint_32 PNGAPI
475 png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
477 png_debug1(1, "in %s retrieval function", "gAMA");
479 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
480 && file_gamma != NULL)
482 *file_gamma = (double)info_ptr->gamma;
483 return (PNG_INFO_gAMA);
485 return (0);
487 #endif
488 #ifdef PNG_FIXED_POINT_SUPPORTED
489 png_uint_32 PNGAPI
490 png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
491 png_fixed_point *int_file_gamma)
493 png_debug1(1, "in %s retrieval function", "gAMA");
495 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
496 && int_file_gamma != NULL)
498 *int_file_gamma = info_ptr->int_gamma;
499 return (PNG_INFO_gAMA);
501 return (0);
503 #endif
504 #endif
506 #ifdef PNG_sRGB_SUPPORTED
507 png_uint_32 PNGAPI
508 png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
510 png_debug1(1, "in %s retrieval function", "sRGB");
512 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
513 && file_srgb_intent != NULL)
515 *file_srgb_intent = (int)info_ptr->srgb_intent;
516 return (PNG_INFO_sRGB);
518 return (0);
520 #endif
522 #ifdef PNG_iCCP_SUPPORTED
523 png_uint_32 PNGAPI
524 png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
525 png_charpp name, int *compression_type,
526 png_charpp profile, png_uint_32 *proflen)
528 png_debug1(1, "in %s retrieval function", "iCCP");
530 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
531 && name != NULL && profile != NULL && proflen != NULL)
533 *name = info_ptr->iccp_name;
534 *profile = info_ptr->iccp_profile;
535 /* Compression_type is a dummy so the API won't have to change
536 * if we introduce multiple compression types later.
538 *proflen = (int)info_ptr->iccp_proflen;
539 *compression_type = (int)info_ptr->iccp_compression;
540 return (PNG_INFO_iCCP);
542 return (0);
544 #endif
546 #ifdef PNG_sPLT_SUPPORTED
547 png_uint_32 PNGAPI
548 png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
549 png_sPLT_tpp spalettes)
551 if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
553 *spalettes = info_ptr->splt_palettes;
554 return ((png_uint_32)info_ptr->splt_palettes_num);
556 return (0);
558 #endif
560 #ifdef PNG_hIST_SUPPORTED
561 png_uint_32 PNGAPI
562 png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
564 png_debug1(1, "in %s retrieval function", "hIST");
566 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
567 && hist != NULL)
569 *hist = info_ptr->hist;
570 return (PNG_INFO_hIST);
572 return (0);
574 #endif
576 png_uint_32 PNGAPI
577 png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
578 png_uint_32 *width, png_uint_32 *height, int *bit_depth,
579 int *color_type, int *interlace_type, int *compression_type,
580 int *filter_type)
583 png_debug1(1, "in %s retrieval function", "IHDR");
585 if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
586 height == NULL || bit_depth == NULL || color_type == NULL)
587 return (0);
589 *width = info_ptr->width;
590 *height = info_ptr->height;
591 *bit_depth = info_ptr->bit_depth;
592 *color_type = info_ptr->color_type;
594 if (compression_type != NULL)
595 *compression_type = info_ptr->compression_type;
597 if (filter_type != NULL)
598 *filter_type = info_ptr->filter_type;
600 if (interlace_type != NULL)
601 *interlace_type = info_ptr->interlace_type;
603 /* This is redundant if we can be sure that the info_ptr values were all
604 * assigned in png_set_IHDR(). We do the check anyhow in case an
605 * application has ignored our advice not to mess with the members
606 * of info_ptr directly.
608 png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height,
609 info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
610 info_ptr->compression_type, info_ptr->filter_type);
612 return (1);
615 #ifdef PNG_oFFs_SUPPORTED
616 png_uint_32 PNGAPI
617 png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
618 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
620 png_debug1(1, "in %s retrieval function", "oFFs");
622 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
623 && offset_x != NULL && offset_y != NULL && unit_type != NULL)
625 *offset_x = info_ptr->x_offset;
626 *offset_y = info_ptr->y_offset;
627 *unit_type = (int)info_ptr->offset_unit_type;
628 return (PNG_INFO_oFFs);
630 return (0);
632 #endif
634 #ifdef PNG_pCAL_SUPPORTED
635 png_uint_32 PNGAPI
636 png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
637 png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
638 png_charp *units, png_charpp *params)
640 png_debug1(1, "in %s retrieval function", "pCAL");
642 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
643 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
644 nparams != NULL && units != NULL && params != NULL)
646 *purpose = info_ptr->pcal_purpose;
647 *X0 = info_ptr->pcal_X0;
648 *X1 = info_ptr->pcal_X1;
649 *type = (int)info_ptr->pcal_type;
650 *nparams = (int)info_ptr->pcal_nparams;
651 *units = info_ptr->pcal_units;
652 *params = info_ptr->pcal_params;
653 return (PNG_INFO_pCAL);
655 return (0);
657 #endif
659 #ifdef PNG_sCAL_SUPPORTED
660 #ifdef PNG_FLOATING_POINT_SUPPORTED
661 png_uint_32 PNGAPI
662 png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
663 int *unit, double *width, double *height)
665 if (png_ptr != NULL && info_ptr != NULL &&
666 (info_ptr->valid & PNG_INFO_sCAL))
668 *unit = info_ptr->scal_unit;
669 *width = info_ptr->scal_pixel_width;
670 *height = info_ptr->scal_pixel_height;
671 return (PNG_INFO_sCAL);
673 return(0);
675 #else
676 #ifdef PNG_FIXED_POINT_SUPPORTED
677 png_uint_32 PNGAPI
678 png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
679 int *unit, png_charpp width, png_charpp height)
681 if (png_ptr != NULL && info_ptr != NULL &&
682 (info_ptr->valid & PNG_INFO_sCAL))
684 *unit = info_ptr->scal_unit;
685 *width = info_ptr->scal_s_width;
686 *height = info_ptr->scal_s_height;
687 return (PNG_INFO_sCAL);
689 return(0);
691 #endif
692 #endif
693 #endif
695 #ifdef PNG_pHYs_SUPPORTED
696 png_uint_32 PNGAPI
697 png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
698 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
700 png_uint_32 retval = 0;
702 png_debug1(1, "in %s retrieval function", "pHYs");
704 if (png_ptr != NULL && info_ptr != NULL &&
705 (info_ptr->valid & PNG_INFO_pHYs))
707 if (res_x != NULL)
709 *res_x = info_ptr->x_pixels_per_unit;
710 retval |= PNG_INFO_pHYs;
713 if (res_y != NULL)
715 *res_y = info_ptr->y_pixels_per_unit;
716 retval |= PNG_INFO_pHYs;
719 if (unit_type != NULL)
721 *unit_type = (int)info_ptr->phys_unit_type;
722 retval |= PNG_INFO_pHYs;
725 return (retval);
727 #endif
729 png_uint_32 PNGAPI
730 png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
731 int *num_palette)
733 png_debug1(1, "in %s retrieval function", "PLTE");
735 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
736 && palette != NULL)
738 *palette = info_ptr->palette;
739 *num_palette = info_ptr->num_palette;
740 png_debug1(3, "num_palette = %d", *num_palette);
741 return (PNG_INFO_PLTE);
743 return (0);
746 #ifdef PNG_sBIT_SUPPORTED
747 png_uint_32 PNGAPI
748 png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
750 png_debug1(1, "in %s retrieval function", "sBIT");
752 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
753 && sig_bit != NULL)
755 *sig_bit = &(info_ptr->sig_bit);
756 return (PNG_INFO_sBIT);
758 return (0);
760 #endif
762 #ifdef PNG_TEXT_SUPPORTED
763 png_uint_32 PNGAPI
764 png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
765 int *num_text)
767 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
769 png_debug1(1, "in %s retrieval function",
770 (png_ptr->chunk_name[0] == '\0' ? "text"
771 : (png_const_charp)png_ptr->chunk_name));
773 if (text_ptr != NULL)
774 *text_ptr = info_ptr->text;
776 if (num_text != NULL)
777 *num_text = info_ptr->num_text;
779 return ((png_uint_32)info_ptr->num_text);
781 if (num_text != NULL)
782 *num_text = 0;
783 return(0);
785 #endif
787 #ifdef PNG_tIME_SUPPORTED
788 png_uint_32 PNGAPI
789 png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
791 png_debug1(1, "in %s retrieval function", "tIME");
793 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
794 && mod_time != NULL)
796 *mod_time = &(info_ptr->mod_time);
797 return (PNG_INFO_tIME);
799 return (0);
801 #endif
803 #ifdef PNG_tRNS_SUPPORTED
804 png_uint_32 PNGAPI
805 png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
806 png_bytep *trans, int *num_trans, png_color_16p *trans_values)
808 png_uint_32 retval = 0;
809 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
811 png_debug1(1, "in %s retrieval function", "tRNS");
813 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
815 if (trans != NULL)
817 *trans = info_ptr->trans;
818 retval |= PNG_INFO_tRNS;
821 if (trans_values != NULL)
822 *trans_values = &(info_ptr->trans_values);
824 else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
826 if (trans_values != NULL)
828 *trans_values = &(info_ptr->trans_values);
829 retval |= PNG_INFO_tRNS;
832 if (trans != NULL)
833 *trans = NULL;
835 if (num_trans != NULL)
837 *num_trans = info_ptr->num_trans;
838 retval |= PNG_INFO_tRNS;
841 return (retval);
843 #endif
845 #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
846 png_uint_32 PNGAPI
847 png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
848 png_unknown_chunkpp unknowns)
850 if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
852 *unknowns = info_ptr->unknown_chunks;
853 return ((png_uint_32)info_ptr->unknown_chunks_num);
855 return (0);
857 #endif
859 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
860 png_byte PNGAPI
861 png_get_rgb_to_gray_status (png_structp png_ptr)
863 return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0);
865 #endif
867 #ifdef PNG_USER_CHUNKS_SUPPORTED
868 png_voidp PNGAPI
869 png_get_user_chunk_ptr(png_structp png_ptr)
871 return (png_ptr? png_ptr->user_chunk_ptr : NULL);
873 #endif
875 png_uint_32 PNGAPI
876 png_get_compression_buffer_size(png_structp png_ptr)
878 return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L);
881 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
882 #ifndef PNG_1_0_X
883 /* This function was added to libpng 1.2.0 and should exist by default */
884 png_uint_32 PNGAPI
885 png_get_asm_flags (png_structp png_ptr)
887 /* Obsolete, to be removed from libpng-1.4.0 */
888 return (png_ptr? 0L: 0L);
891 /* This function was added to libpng 1.2.0 and should exist by default */
892 png_uint_32 PNGAPI
893 png_get_asm_flagmask (int flag_select)
895 /* Obsolete, to be removed from libpng-1.4.0 */
896 flag_select=flag_select;
897 return 0L;
900 /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
901 /* This function was added to libpng 1.2.0 */
902 png_uint_32 PNGAPI
903 png_get_mmx_flagmask (int flag_select, int *compilerID)
905 /* Obsolete, to be removed from libpng-1.4.0 */
906 flag_select=flag_select;
907 *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */
908 return 0L;
911 /* This function was added to libpng 1.2.0 */
912 png_byte PNGAPI
913 png_get_mmx_bitdepth_threshold (png_structp png_ptr)
915 /* Obsolete, to be removed from libpng-1.4.0 */
916 return (png_ptr? 0: 0);
919 /* This function was added to libpng 1.2.0 */
920 png_uint_32 PNGAPI
921 png_get_mmx_rowbytes_threshold (png_structp png_ptr)
923 /* Obsolete, to be removed from libpng-1.4.0 */
924 return (png_ptr? 0L: 0L);
926 #endif /* ?PNG_1_0_X */
927 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
929 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
930 /* These functions were added to libpng 1.2.6 but not enabled
931 * by default. They will be enabled in libpng-1.4.0 */
932 png_uint_32 PNGAPI
933 png_get_user_width_max (png_structp png_ptr)
935 return (png_ptr? png_ptr->user_width_max : 0);
937 png_uint_32 PNGAPI
938 png_get_user_height_max (png_structp png_ptr)
940 return (png_ptr? png_ptr->user_height_max : 0);
942 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
944 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */