2 /* pngget.c - retrieval of values from info struct
4 * Last changed in libpng 1.2.15 January 5, 2007
5 * For conditions of distribution and use, see copyright notice in png.h
6 * Copyright (c) 1998-2007 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.)
14 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
17 png_get_valid(png_structp png_ptr
, png_infop info_ptr
, png_uint_32 flag
)
19 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
20 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
);
34 #if defined(PNG_INFO_IMAGE_SUPPORTED)
36 png_get_rows(png_structp png_ptr
, png_infop info_ptr
)
38 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
39 return(info_ptr
->row_pointers
);
45 #ifdef PNG_EASY_ACCESS_SUPPORTED
46 /* easy access to info, added in libpng-0.99 */
48 png_get_image_width(png_structp png_ptr
, png_infop info_ptr
)
50 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
52 return info_ptr
->width
;
58 png_get_image_height(png_structp png_ptr
, png_infop info_ptr
)
60 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
)
72 return info_ptr
->bit_depth
;
78 png_get_color_type(png_structp png_ptr
, png_infop info_ptr
)
80 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
82 return info_ptr
->color_type
;
88 png_get_filter_type(png_structp png_ptr
, png_infop info_ptr
)
90 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
92 return info_ptr
->filter_type
;
98 png_get_interlace_type(png_structp png_ptr
, png_infop info_ptr
)
100 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
102 return info_ptr
->interlace_type
;
108 png_get_compression_type(png_structp png_ptr
, png_infop info_ptr
)
110 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
112 return info_ptr
->compression_type
;
118 png_get_x_pixels_per_meter(png_structp png_ptr
, png_infop info_ptr
)
120 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
121 #if defined(PNG_pHYs_SUPPORTED)
122 if (info_ptr
->valid
& PNG_INFO_pHYs
)
124 png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter");
125 if(info_ptr
->phys_unit_type
!= PNG_RESOLUTION_METER
)
127 else return (info_ptr
->x_pixels_per_unit
);
136 png_get_y_pixels_per_meter(png_structp png_ptr
, png_infop info_ptr
)
138 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
139 #if defined(PNG_pHYs_SUPPORTED)
140 if (info_ptr
->valid
& PNG_INFO_pHYs
)
142 png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter");
143 if(info_ptr
->phys_unit_type
!= PNG_RESOLUTION_METER
)
145 else return (info_ptr
->y_pixels_per_unit
);
154 png_get_pixels_per_meter(png_structp png_ptr
, png_infop info_ptr
)
156 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
157 #if defined(PNG_pHYs_SUPPORTED)
158 if (info_ptr
->valid
& PNG_INFO_pHYs
)
160 png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter");
161 if(info_ptr
->phys_unit_type
!= PNG_RESOLUTION_METER
||
162 info_ptr
->x_pixels_per_unit
!= info_ptr
->y_pixels_per_unit
)
164 else return (info_ptr
->x_pixels_per_unit
);
172 #ifdef PNG_FLOATING_POINT_SUPPORTED
174 png_get_pixel_aspect_ratio(png_structp png_ptr
, png_infop info_ptr
)
176 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
177 #if defined(PNG_pHYs_SUPPORTED)
178 if (info_ptr
->valid
& PNG_INFO_pHYs
)
180 png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio");
181 if (info_ptr
->x_pixels_per_unit
== 0)
184 return ((float)((float)info_ptr
->y_pixels_per_unit
185 /(float)info_ptr
->x_pixels_per_unit
));
195 png_get_x_offset_microns(png_structp png_ptr
, png_infop info_ptr
)
197 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
198 #if defined(PNG_oFFs_SUPPORTED)
199 if (info_ptr
->valid
& PNG_INFO_oFFs
)
201 png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
202 if(info_ptr
->offset_unit_type
!= PNG_OFFSET_MICROMETER
)
204 else return (info_ptr
->x_offset
);
213 png_get_y_offset_microns(png_structp png_ptr
, png_infop info_ptr
)
215 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
216 #if defined(PNG_oFFs_SUPPORTED)
217 if (info_ptr
->valid
& PNG_INFO_oFFs
)
219 png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
220 if(info_ptr
->offset_unit_type
!= PNG_OFFSET_MICROMETER
)
222 else return (info_ptr
->y_offset
);
231 png_get_x_offset_pixels(png_structp png_ptr
, png_infop info_ptr
)
233 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
234 #if defined(PNG_oFFs_SUPPORTED)
235 if (info_ptr
->valid
& PNG_INFO_oFFs
)
237 png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
238 if(info_ptr
->offset_unit_type
!= PNG_OFFSET_PIXEL
)
240 else return (info_ptr
->x_offset
);
249 png_get_y_offset_pixels(png_structp png_ptr
, png_infop info_ptr
)
251 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
252 #if defined(PNG_oFFs_SUPPORTED)
253 if (info_ptr
->valid
& PNG_INFO_oFFs
)
255 png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
256 if(info_ptr
->offset_unit_type
!= PNG_OFFSET_PIXEL
)
258 else return (info_ptr
->y_offset
);
266 #if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
268 png_get_pixels_per_inch(png_structp png_ptr
, png_infop info_ptr
)
270 return ((png_uint_32
)((float)png_get_pixels_per_meter(png_ptr
, info_ptr
)
275 png_get_x_pixels_per_inch(png_structp png_ptr
, png_infop info_ptr
)
277 return ((png_uint_32
)((float)png_get_x_pixels_per_meter(png_ptr
, info_ptr
)
282 png_get_y_pixels_per_inch(png_structp png_ptr
, png_infop info_ptr
)
284 return ((png_uint_32
)((float)png_get_y_pixels_per_meter(png_ptr
, info_ptr
)
289 png_get_x_offset_inches(png_structp png_ptr
, png_infop info_ptr
)
291 return ((float)png_get_x_offset_microns(png_ptr
, info_ptr
)
296 png_get_y_offset_inches(png_structp png_ptr
, png_infop info_ptr
)
298 return ((float)png_get_y_offset_microns(png_ptr
, info_ptr
)
302 #if defined(PNG_pHYs_SUPPORTED)
304 png_get_pHYs_dpi(png_structp png_ptr
, png_infop info_ptr
,
305 png_uint_32
*res_x
, png_uint_32
*res_y
, int *unit_type
)
307 png_uint_32 retval
= 0;
309 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_pHYs
))
311 png_debug1(1, "in %s retrieval function\n", "pHYs");
314 *res_x
= info_ptr
->x_pixels_per_unit
;
315 retval
|= PNG_INFO_pHYs
;
319 *res_y
= info_ptr
->y_pixels_per_unit
;
320 retval
|= PNG_INFO_pHYs
;
322 if (unit_type
!= NULL
)
324 *unit_type
= (int)info_ptr
->phys_unit_type
;
325 retval
|= PNG_INFO_pHYs
;
328 if (res_x
!= NULL
) *res_x
= (png_uint_32
)(*res_x
* .0254 + .50);
329 if (res_y
!= NULL
) *res_y
= (png_uint_32
)(*res_y
* .0254 + .50);
335 #endif /* PNG_pHYs_SUPPORTED */
336 #endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
338 /* png_get_channels really belongs in here, too, but it's been around longer */
340 #endif /* PNG_EASY_ACCESS_SUPPORTED */
343 png_get_channels(png_structp png_ptr
, png_infop info_ptr
)
345 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
346 return(info_ptr
->channels
);
352 png_get_signature(png_structp png_ptr
, png_infop info_ptr
)
354 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
355 return(info_ptr
->signature
);
360 #if defined(PNG_bKGD_SUPPORTED)
362 png_get_bKGD(png_structp png_ptr
, png_infop info_ptr
,
363 png_color_16p
*background
)
365 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_bKGD
)
366 && background
!= NULL
)
368 png_debug1(1, "in %s retrieval function\n", "bKGD");
369 *background
= &(info_ptr
->background
);
370 return (PNG_INFO_bKGD
);
376 #if defined(PNG_cHRM_SUPPORTED)
377 #ifdef PNG_FLOATING_POINT_SUPPORTED
379 png_get_cHRM(png_structp png_ptr
, png_infop info_ptr
,
380 double *white_x
, double *white_y
, double *red_x
, double *red_y
,
381 double *green_x
, double *green_y
, double *blue_x
, double *blue_y
)
383 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_cHRM
))
385 png_debug1(1, "in %s retrieval function\n", "cHRM");
387 *white_x
= (double)info_ptr
->x_white
;
389 *white_y
= (double)info_ptr
->y_white
;
391 *red_x
= (double)info_ptr
->x_red
;
393 *red_y
= (double)info_ptr
->y_red
;
395 *green_x
= (double)info_ptr
->x_green
;
397 *green_y
= (double)info_ptr
->y_green
;
399 *blue_x
= (double)info_ptr
->x_blue
;
401 *blue_y
= (double)info_ptr
->y_blue
;
402 return (PNG_INFO_cHRM
);
407 #ifdef PNG_FIXED_POINT_SUPPORTED
409 png_get_cHRM_fixed(png_structp png_ptr
, png_infop info_ptr
,
410 png_fixed_point
*white_x
, png_fixed_point
*white_y
, png_fixed_point
*red_x
,
411 png_fixed_point
*red_y
, png_fixed_point
*green_x
, png_fixed_point
*green_y
,
412 png_fixed_point
*blue_x
, png_fixed_point
*blue_y
)
414 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_cHRM
))
416 png_debug1(1, "in %s retrieval function\n", "cHRM");
418 *white_x
= info_ptr
->int_x_white
;
420 *white_y
= info_ptr
->int_y_white
;
422 *red_x
= info_ptr
->int_x_red
;
424 *red_y
= info_ptr
->int_y_red
;
426 *green_x
= info_ptr
->int_x_green
;
428 *green_y
= info_ptr
->int_y_green
;
430 *blue_x
= info_ptr
->int_x_blue
;
432 *blue_y
= info_ptr
->int_y_blue
;
433 return (PNG_INFO_cHRM
);
440 #if defined(PNG_gAMA_SUPPORTED)
441 #ifdef PNG_FLOATING_POINT_SUPPORTED
443 png_get_gAMA(png_structp png_ptr
, png_infop info_ptr
, double *file_gamma
)
445 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_gAMA
)
446 && file_gamma
!= NULL
)
448 png_debug1(1, "in %s retrieval function\n", "gAMA");
449 *file_gamma
= (double)info_ptr
->gamma
;
450 return (PNG_INFO_gAMA
);
455 #ifdef PNG_FIXED_POINT_SUPPORTED
457 png_get_gAMA_fixed(png_structp png_ptr
, png_infop info_ptr
,
458 png_fixed_point
*int_file_gamma
)
460 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_gAMA
)
461 && int_file_gamma
!= NULL
)
463 png_debug1(1, "in %s retrieval function\n", "gAMA");
464 *int_file_gamma
= info_ptr
->int_gamma
;
465 return (PNG_INFO_gAMA
);
472 #if defined(PNG_sRGB_SUPPORTED)
474 png_get_sRGB(png_structp png_ptr
, png_infop info_ptr
, int *file_srgb_intent
)
476 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_sRGB
)
477 && file_srgb_intent
!= NULL
)
479 png_debug1(1, "in %s retrieval function\n", "sRGB");
480 *file_srgb_intent
= (int)info_ptr
->srgb_intent
;
481 return (PNG_INFO_sRGB
);
487 #if defined(PNG_iCCP_SUPPORTED)
489 png_get_iCCP(png_structp png_ptr
, png_infop info_ptr
,
490 png_charpp name
, int *compression_type
,
491 png_charpp profile
, png_uint_32
*proflen
)
493 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_iCCP
)
494 && name
!= NULL
&& profile
!= NULL
&& proflen
!= NULL
)
496 png_debug1(1, "in %s retrieval function\n", "iCCP");
497 *name
= info_ptr
->iccp_name
;
498 *profile
= info_ptr
->iccp_profile
;
499 /* compression_type is a dummy so the API won't have to change
500 if we introduce multiple compression types later. */
501 *proflen
= (int)info_ptr
->iccp_proflen
;
502 *compression_type
= (int)info_ptr
->iccp_compression
;
503 return (PNG_INFO_iCCP
);
509 #if defined(PNG_sPLT_SUPPORTED)
511 png_get_sPLT(png_structp png_ptr
, png_infop info_ptr
,
512 png_sPLT_tpp spalettes
)
514 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& spalettes
!= NULL
)
516 *spalettes
= info_ptr
->splt_palettes
;
517 return ((png_uint_32
)info_ptr
->splt_palettes_num
);
523 #if defined(PNG_hIST_SUPPORTED)
525 png_get_hIST(png_structp png_ptr
, png_infop info_ptr
, png_uint_16p
*hist
)
527 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_hIST
)
530 png_debug1(1, "in %s retrieval function\n", "hIST");
531 *hist
= info_ptr
->hist
;
532 return (PNG_INFO_hIST
);
539 png_get_IHDR(png_structp png_ptr
, png_infop info_ptr
,
540 png_uint_32
*width
, png_uint_32
*height
, int *bit_depth
,
541 int *color_type
, int *interlace_type
, int *compression_type
,
545 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& width
!= NULL
&& height
!= NULL
&&
546 bit_depth
!= NULL
&& color_type
!= NULL
)
548 png_debug1(1, "in %s retrieval function\n", "IHDR");
549 *width
= info_ptr
->width
;
550 *height
= info_ptr
->height
;
551 *bit_depth
= info_ptr
->bit_depth
;
552 if (info_ptr
->bit_depth
< 1 || info_ptr
->bit_depth
> 16)
553 png_error(png_ptr
, "Invalid bit depth");
554 *color_type
= info_ptr
->color_type
;
555 if (info_ptr
->color_type
> 6)
556 png_error(png_ptr
, "Invalid color type");
557 if (compression_type
!= NULL
)
558 *compression_type
= info_ptr
->compression_type
;
559 if (filter_type
!= NULL
)
560 *filter_type
= info_ptr
->filter_type
;
561 if (interlace_type
!= NULL
)
562 *interlace_type
= info_ptr
->interlace_type
;
564 /* check for potential overflow of rowbytes */
565 if (*width
== 0 || *width
> PNG_UINT_31_MAX
)
566 png_error(png_ptr
, "Invalid image width");
567 if (*height
== 0 || *height
> PNG_UINT_31_MAX
)
568 png_error(png_ptr
, "Invalid image height");
569 if (info_ptr
->width
> (PNG_UINT_32_MAX
570 >> 3) /* 8-byte RGBA pixels */
571 - 64 /* bigrowbuf hack */
572 - 1 /* filter byte */
573 - 7*8 /* rounding of width to multiple of 8 pixels */
574 - 8) /* extra max_pixel_depth pad */
577 "Width too large for libpng to process image data.");
584 #if defined(PNG_oFFs_SUPPORTED)
586 png_get_oFFs(png_structp png_ptr
, png_infop info_ptr
,
587 png_int_32
*offset_x
, png_int_32
*offset_y
, int *unit_type
)
589 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_oFFs
)
590 && offset_x
!= NULL
&& offset_y
!= NULL
&& unit_type
!= NULL
)
592 png_debug1(1, "in %s retrieval function\n", "oFFs");
593 *offset_x
= info_ptr
->x_offset
;
594 *offset_y
= info_ptr
->y_offset
;
595 *unit_type
= (int)info_ptr
->offset_unit_type
;
596 return (PNG_INFO_oFFs
);
602 #if defined(PNG_pCAL_SUPPORTED)
604 png_get_pCAL(png_structp png_ptr
, png_infop info_ptr
,
605 png_charp
*purpose
, png_int_32
*X0
, png_int_32
*X1
, int *type
, int *nparams
,
606 png_charp
*units
, png_charpp
*params
)
608 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_pCAL
)
609 && purpose
!= NULL
&& X0
!= NULL
&& X1
!= NULL
&& type
!= NULL
&&
610 nparams
!= NULL
&& units
!= NULL
&& params
!= NULL
)
612 png_debug1(1, "in %s retrieval function\n", "pCAL");
613 *purpose
= info_ptr
->pcal_purpose
;
614 *X0
= info_ptr
->pcal_X0
;
615 *X1
= info_ptr
->pcal_X1
;
616 *type
= (int)info_ptr
->pcal_type
;
617 *nparams
= (int)info_ptr
->pcal_nparams
;
618 *units
= info_ptr
->pcal_units
;
619 *params
= info_ptr
->pcal_params
;
620 return (PNG_INFO_pCAL
);
626 #if defined(PNG_sCAL_SUPPORTED)
627 #ifdef PNG_FLOATING_POINT_SUPPORTED
629 png_get_sCAL(png_structp png_ptr
, png_infop info_ptr
,
630 int *unit
, double *width
, double *height
)
632 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&&
633 (info_ptr
->valid
& PNG_INFO_sCAL
))
635 *unit
= info_ptr
->scal_unit
;
636 *width
= info_ptr
->scal_pixel_width
;
637 *height
= info_ptr
->scal_pixel_height
;
638 return (PNG_INFO_sCAL
);
643 #ifdef PNG_FIXED_POINT_SUPPORTED
645 png_get_sCAL_s(png_structp png_ptr
, png_infop info_ptr
,
646 int *unit
, png_charpp width
, png_charpp height
)
648 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&&
649 (info_ptr
->valid
& PNG_INFO_sCAL
))
651 *unit
= info_ptr
->scal_unit
;
652 *width
= info_ptr
->scal_s_width
;
653 *height
= info_ptr
->scal_s_height
;
654 return (PNG_INFO_sCAL
);
662 #if defined(PNG_pHYs_SUPPORTED)
664 png_get_pHYs(png_structp png_ptr
, png_infop info_ptr
,
665 png_uint_32
*res_x
, png_uint_32
*res_y
, int *unit_type
)
667 png_uint_32 retval
= 0;
669 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&&
670 (info_ptr
->valid
& PNG_INFO_pHYs
))
672 png_debug1(1, "in %s retrieval function\n", "pHYs");
675 *res_x
= info_ptr
->x_pixels_per_unit
;
676 retval
|= PNG_INFO_pHYs
;
680 *res_y
= info_ptr
->y_pixels_per_unit
;
681 retval
|= PNG_INFO_pHYs
;
683 if (unit_type
!= NULL
)
685 *unit_type
= (int)info_ptr
->phys_unit_type
;
686 retval
|= PNG_INFO_pHYs
;
694 png_get_PLTE(png_structp png_ptr
, png_infop info_ptr
, png_colorp
*palette
,
697 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_PLTE
)
700 png_debug1(1, "in %s retrieval function\n", "PLTE");
701 *palette
= info_ptr
->palette
;
702 *num_palette
= info_ptr
->num_palette
;
703 png_debug1(3, "num_palette = %d\n", *num_palette
);
704 return (PNG_INFO_PLTE
);
709 #if defined(PNG_sBIT_SUPPORTED)
711 png_get_sBIT(png_structp png_ptr
, png_infop info_ptr
, png_color_8p
*sig_bit
)
713 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_sBIT
)
716 png_debug1(1, "in %s retrieval function\n", "sBIT");
717 *sig_bit
= &(info_ptr
->sig_bit
);
718 return (PNG_INFO_sBIT
);
724 #if defined(PNG_TEXT_SUPPORTED)
726 png_get_text(png_structp png_ptr
, png_infop info_ptr
, png_textp
*text_ptr
,
729 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& info_ptr
->num_text
> 0)
731 png_debug1(1, "in %s retrieval function\n",
732 (png_ptr
->chunk_name
[0] == '\0' ? "text"
733 : (png_const_charp
)png_ptr
->chunk_name
));
734 if (text_ptr
!= NULL
)
735 *text_ptr
= info_ptr
->text
;
736 if (num_text
!= NULL
)
737 *num_text
= info_ptr
->num_text
;
738 return ((png_uint_32
)info_ptr
->num_text
);
740 if (num_text
!= NULL
)
746 #if defined(PNG_tIME_SUPPORTED)
748 png_get_tIME(png_structp png_ptr
, png_infop info_ptr
, png_timep
*mod_time
)
750 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_tIME
)
753 png_debug1(1, "in %s retrieval function\n", "tIME");
754 *mod_time
= &(info_ptr
->mod_time
);
755 return (PNG_INFO_tIME
);
761 #if defined(PNG_tRNS_SUPPORTED)
763 png_get_tRNS(png_structp png_ptr
, png_infop info_ptr
,
764 png_bytep
*trans
, int *num_trans
, png_color_16p
*trans_values
)
766 png_uint_32 retval
= 0;
767 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_tRNS
))
769 png_debug1(1, "in %s retrieval function\n", "tRNS");
770 if (info_ptr
->color_type
== PNG_COLOR_TYPE_PALETTE
)
774 *trans
= info_ptr
->trans
;
775 retval
|= PNG_INFO_tRNS
;
777 if (trans_values
!= NULL
)
778 *trans_values
= &(info_ptr
->trans_values
);
780 else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
782 if (trans_values
!= NULL
)
784 *trans_values
= &(info_ptr
->trans_values
);
785 retval
|= PNG_INFO_tRNS
;
790 if(num_trans
!= NULL
)
792 *num_trans
= info_ptr
->num_trans
;
793 retval
|= PNG_INFO_tRNS
;
800 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
802 png_get_unknown_chunks(png_structp png_ptr
, png_infop info_ptr
,
803 png_unknown_chunkpp unknowns
)
805 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& unknowns
!= NULL
)
807 *unknowns
= info_ptr
->unknown_chunks
;
808 return ((png_uint_32
)info_ptr
->unknown_chunks_num
);
814 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
816 png_get_rgb_to_gray_status (png_structp png_ptr
)
818 return (png_byte
)(png_ptr
? png_ptr
->rgb_to_gray_status
: 0);
822 #if defined(PNG_USER_CHUNKS_SUPPORTED)
824 png_get_user_chunk_ptr(png_structp png_ptr
)
826 return (png_ptr
? png_ptr
->user_chunk_ptr
: NULL
);
830 #ifdef PNG_WRITE_SUPPORTED
832 png_get_compression_buffer_size(png_structp png_ptr
)
834 return (png_uint_32
)(png_ptr
? png_ptr
->zbuf_size
: 0L);
838 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
840 /* this function was added to libpng 1.2.0 and should exist by default */
842 png_get_asm_flags (png_structp png_ptr
)
844 /* obsolete, to be removed from libpng-1.4.0 */
845 return (png_ptr
? 0L: 0L);
848 /* this function was added to libpng 1.2.0 and should exist by default */
850 png_get_asm_flagmask (int flag_select
)
852 /* obsolete, to be removed from libpng-1.4.0 */
853 flag_select
=flag_select
;
857 /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
858 /* this function was added to libpng 1.2.0 */
860 png_get_mmx_flagmask (int flag_select
, int *compilerID
)
862 /* obsolete, to be removed from libpng-1.4.0 */
863 flag_select
=flag_select
;
864 *compilerID
= -1; /* unknown (i.e., no asm/MMX code compiled) */
868 /* this function was added to libpng 1.2.0 */
870 png_get_mmx_bitdepth_threshold (png_structp png_ptr
)
872 /* obsolete, to be removed from libpng-1.4.0 */
873 return (png_ptr
? 0: 0);
876 /* this function was added to libpng 1.2.0 */
878 png_get_mmx_rowbytes_threshold (png_structp png_ptr
)
880 /* obsolete, to be removed from libpng-1.4.0 */
881 return (png_ptr
? 0L: 0L);
883 #endif /* ?PNG_1_0_X */
884 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
886 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
887 /* these functions were added to libpng 1.2.6 */
889 png_get_user_width_max (png_structp png_ptr
)
891 return (png_ptr
? png_ptr
->user_width_max
: 0);
894 png_get_user_height_max (png_structp png_ptr
)
896 return (png_ptr
? png_ptr
->user_height_max
: 0);
898 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
901 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */