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.)
13 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
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
);
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
);
35 #if defined(PNG_INFO_IMAGE_SUPPORTED)
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
);
47 #ifdef PNG_EASY_ACCESS_SUPPORTED
48 /* Easy access to info, added in libpng-0.99 */
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
;
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
;
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
;
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
;
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
;
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
;
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
;
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
)
125 return (info_ptr
->x_pixels_per_unit
);
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
)
146 return (info_ptr
->y_pixels_per_unit
);
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
)
168 return (info_ptr
->x_pixels_per_unit
);
176 #ifdef PNG_FLOATING_POINT_SUPPORTED
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)
189 return ((float)((float)info_ptr
->y_pixels_per_unit
190 /(float)info_ptr
->x_pixels_per_unit
));
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
)
213 return (info_ptr
->x_offset
);
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
)
235 return (info_ptr
->y_offset
);
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
)
257 return (info_ptr
->x_offset
);
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
)
279 return (info_ptr
->y_offset
);
287 #if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
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
)
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
)
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
)
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
)
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
)
323 #if defined(PNG_pHYs_SUPPORTED)
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");
335 *res_x
= info_ptr
->x_pixels_per_unit
;
336 retval
|= PNG_INFO_pHYs
;
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
;
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);
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 */
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
);
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
);
381 #if defined(PNG_bKGD_SUPPORTED)
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
);
397 #if defined(PNG_cHRM_SUPPORTED)
398 #ifdef PNG_FLOATING_POINT_SUPPORTED
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");
408 *white_x
= (double)info_ptr
->x_white
;
410 *white_y
= (double)info_ptr
->y_white
;
412 *red_x
= (double)info_ptr
->x_red
;
414 *red_y
= (double)info_ptr
->y_red
;
416 *green_x
= (double)info_ptr
->x_green
;
418 *green_y
= (double)info_ptr
->y_green
;
420 *blue_x
= (double)info_ptr
->x_blue
;
422 *blue_y
= (double)info_ptr
->y_blue
;
423 return (PNG_INFO_cHRM
);
428 #ifdef PNG_FIXED_POINT_SUPPORTED
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");
439 *white_x
= info_ptr
->int_x_white
;
441 *white_y
= info_ptr
->int_y_white
;
443 *red_x
= info_ptr
->int_x_red
;
445 *red_y
= info_ptr
->int_y_red
;
447 *green_x
= info_ptr
->int_x_green
;
449 *green_y
= info_ptr
->int_y_green
;
451 *blue_x
= info_ptr
->int_x_blue
;
453 *blue_y
= info_ptr
->int_y_blue
;
454 return (PNG_INFO_cHRM
);
461 #if defined(PNG_gAMA_SUPPORTED)
462 #ifdef PNG_FLOATING_POINT_SUPPORTED
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
);
476 #ifdef PNG_FIXED_POINT_SUPPORTED
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
);
493 #if defined(PNG_sRGB_SUPPORTED)
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
);
508 #if defined(PNG_iCCP_SUPPORTED)
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
);
531 #if defined(PNG_sPLT_SUPPORTED)
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
);
545 #if defined(PNG_hIST_SUPPORTED)
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
)
552 png_debug1(1, "in %s retrieval function", "hIST");
553 *hist
= info_ptr
->hist
;
554 return (PNG_INFO_hIST
);
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
,
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 */
606 "Width too large for libpng to process image data.");
614 #if defined(PNG_oFFs_SUPPORTED)
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
);
632 #if defined(PNG_pCAL_SUPPORTED)
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
);
656 #if defined(PNG_sCAL_SUPPORTED)
657 #ifdef PNG_FLOATING_POINT_SUPPORTED
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
);
673 #ifdef PNG_FIXED_POINT_SUPPORTED
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
);
692 #if defined(PNG_pHYs_SUPPORTED)
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");
706 *res_x
= info_ptr
->x_pixels_per_unit
;
707 retval
|= PNG_INFO_pHYs
;
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
;
727 png_get_PLTE(png_structp png_ptr
, png_infop info_ptr
, png_colorp
*palette
,
730 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_PLTE
)
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
);
742 #if defined(PNG_sBIT_SUPPORTED)
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
)
749 png_debug1(1, "in %s retrieval function", "sBIT");
750 *sig_bit
= &(info_ptr
->sig_bit
);
751 return (PNG_INFO_sBIT
);
757 #if defined(PNG_TEXT_SUPPORTED)
759 png_get_text(png_structp png_ptr
, png_infop info_ptr
, png_textp
*text_ptr
,
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
)
782 #if defined(PNG_tIME_SUPPORTED)
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
)
789 png_debug1(1, "in %s retrieval function", "tIME");
790 *mod_time
= &(info_ptr
->mod_time
);
791 return (PNG_INFO_tIME
);
797 #if defined(PNG_tRNS_SUPPORTED)
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
)
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
;
828 if (num_trans
!= NULL
)
830 *num_trans
= info_ptr
->num_trans
;
831 retval
|= PNG_INFO_tRNS
;
838 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
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
);
852 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
854 png_get_rgb_to_gray_status (png_structp png_ptr
)
856 return (png_byte
)(png_ptr
? png_ptr
->rgb_to_gray_status
: 0);
860 #if defined(PNG_USER_CHUNKS_SUPPORTED)
862 png_get_user_chunk_ptr(png_structp png_ptr
)
864 return (png_ptr
? png_ptr
->user_chunk_ptr
: NULL
);
868 #ifdef PNG_WRITE_SUPPORTED
870 png_get_compression_buffer_size(png_structp png_ptr
)
872 return (png_uint_32
)(png_ptr
? png_ptr
->zbuf_size
: 0L);
876 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
878 /* This function was added to libpng 1.2.0 and should exist by default */
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 */
888 png_get_asm_flagmask (int flag_select
)
890 /* Obsolete, to be removed from libpng-1.4.0 */
891 flag_select
=flag_select
;
895 /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
896 /* This function was added to libpng 1.2.0 */
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) */
906 /* This function was added to libpng 1.2.0 */
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 */
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 */
927 png_get_user_width_max (png_structp png_ptr
)
929 return (png_ptr
? png_ptr
->user_width_max
: 0);
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 */