2 /* pngget.c - retrieval of values from info struct
4 * Last changed in libpng 1.2.30 [August 15, 2008]
5 * For conditions of distribution and use, see copyright notice in png.h
6 * Copyright (c) 1998-2008 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
);
25 png_get_rowbytes(png_structp png_ptr
, png_infop info_ptr
)
27 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
28 return(info_ptr
->rowbytes
);
33 #if defined(PNG_INFO_IMAGE_SUPPORTED)
35 png_get_rows(png_structp png_ptr
, png_infop info_ptr
)
37 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
38 return(info_ptr
->row_pointers
);
44 #ifdef PNG_EASY_ACCESS_SUPPORTED
45 /* easy access to info, added in libpng-0.99 */
47 png_get_image_width(png_structp png_ptr
, png_infop info_ptr
)
49 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
51 return info_ptr
->width
;
57 png_get_image_height(png_structp png_ptr
, png_infop info_ptr
)
59 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
61 return info_ptr
->height
;
67 png_get_bit_depth(png_structp png_ptr
, png_infop info_ptr
)
69 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
)
81 return info_ptr
->color_type
;
87 png_get_filter_type(png_structp png_ptr
, png_infop info_ptr
)
89 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
91 return info_ptr
->filter_type
;
97 png_get_interlace_type(png_structp png_ptr
, png_infop info_ptr
)
99 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
101 return info_ptr
->interlace_type
;
107 png_get_compression_type(png_structp png_ptr
, png_infop info_ptr
)
109 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
111 return info_ptr
->compression_type
;
117 png_get_x_pixels_per_meter(png_structp png_ptr
, png_infop info_ptr
)
119 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
120 #if defined(PNG_pHYs_SUPPORTED)
121 if (info_ptr
->valid
& PNG_INFO_pHYs
)
123 png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter");
124 if (info_ptr
->phys_unit_type
!= PNG_RESOLUTION_METER
)
126 else return (info_ptr
->x_pixels_per_unit
);
135 png_get_y_pixels_per_meter(png_structp png_ptr
, png_infop info_ptr
)
137 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
138 #if defined(PNG_pHYs_SUPPORTED)
139 if (info_ptr
->valid
& PNG_INFO_pHYs
)
141 png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter");
142 if (info_ptr
->phys_unit_type
!= PNG_RESOLUTION_METER
)
144 else return (info_ptr
->y_pixels_per_unit
);
153 png_get_pixels_per_meter(png_structp png_ptr
, png_infop info_ptr
)
155 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
156 #if defined(PNG_pHYs_SUPPORTED)
157 if (info_ptr
->valid
& PNG_INFO_pHYs
)
159 png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
160 if (info_ptr
->phys_unit_type
!= PNG_RESOLUTION_METER
||
161 info_ptr
->x_pixels_per_unit
!= info_ptr
->y_pixels_per_unit
)
163 else return (info_ptr
->x_pixels_per_unit
);
171 #ifdef PNG_FLOATING_POINT_SUPPORTED
173 png_get_pixel_aspect_ratio(png_structp png_ptr
, png_infop info_ptr
)
175 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
176 #if defined(PNG_pHYs_SUPPORTED)
177 if (info_ptr
->valid
& PNG_INFO_pHYs
)
179 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
180 if (info_ptr
->x_pixels_per_unit
== 0)
183 return ((float)((float)info_ptr
->y_pixels_per_unit
184 /(float)info_ptr
->x_pixels_per_unit
));
194 png_get_x_offset_microns(png_structp png_ptr
, png_infop info_ptr
)
196 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
197 #if defined(PNG_oFFs_SUPPORTED)
198 if (info_ptr
->valid
& PNG_INFO_oFFs
)
200 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
201 if (info_ptr
->offset_unit_type
!= PNG_OFFSET_MICROMETER
)
203 else return (info_ptr
->x_offset
);
212 png_get_y_offset_microns(png_structp png_ptr
, png_infop info_ptr
)
214 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
215 #if defined(PNG_oFFs_SUPPORTED)
216 if (info_ptr
->valid
& PNG_INFO_oFFs
)
218 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
219 if (info_ptr
->offset_unit_type
!= PNG_OFFSET_MICROMETER
)
221 else return (info_ptr
->y_offset
);
230 png_get_x_offset_pixels(png_structp png_ptr
, png_infop info_ptr
)
232 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
233 #if defined(PNG_oFFs_SUPPORTED)
234 if (info_ptr
->valid
& PNG_INFO_oFFs
)
236 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
237 if (info_ptr
->offset_unit_type
!= PNG_OFFSET_PIXEL
)
239 else return (info_ptr
->x_offset
);
248 png_get_y_offset_pixels(png_structp png_ptr
, png_infop info_ptr
)
250 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
251 #if defined(PNG_oFFs_SUPPORTED)
252 if (info_ptr
->valid
& PNG_INFO_oFFs
)
254 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
255 if (info_ptr
->offset_unit_type
!= PNG_OFFSET_PIXEL
)
257 else return (info_ptr
->y_offset
);
265 #if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
267 png_get_pixels_per_inch(png_structp png_ptr
, png_infop info_ptr
)
269 return ((png_uint_32
)((float)png_get_pixels_per_meter(png_ptr
, info_ptr
)
274 png_get_x_pixels_per_inch(png_structp png_ptr
, png_infop info_ptr
)
276 return ((png_uint_32
)((float)png_get_x_pixels_per_meter(png_ptr
, info_ptr
)
281 png_get_y_pixels_per_inch(png_structp png_ptr
, png_infop info_ptr
)
283 return ((png_uint_32
)((float)png_get_y_pixels_per_meter(png_ptr
, info_ptr
)
288 png_get_x_offset_inches(png_structp png_ptr
, png_infop info_ptr
)
290 return ((float)png_get_x_offset_microns(png_ptr
, info_ptr
)
295 png_get_y_offset_inches(png_structp png_ptr
, png_infop info_ptr
)
297 return ((float)png_get_y_offset_microns(png_ptr
, info_ptr
)
301 #if defined(PNG_pHYs_SUPPORTED)
303 png_get_pHYs_dpi(png_structp png_ptr
, png_infop info_ptr
,
304 png_uint_32
*res_x
, png_uint_32
*res_y
, int *unit_type
)
306 png_uint_32 retval
= 0;
308 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_pHYs
))
310 png_debug1(1, "in %s retrieval function", "pHYs");
313 *res_x
= info_ptr
->x_pixels_per_unit
;
314 retval
|= PNG_INFO_pHYs
;
318 *res_y
= info_ptr
->y_pixels_per_unit
;
319 retval
|= PNG_INFO_pHYs
;
321 if (unit_type
!= NULL
)
323 *unit_type
= (int)info_ptr
->phys_unit_type
;
324 retval
|= PNG_INFO_pHYs
;
327 if (res_x
!= NULL
) *res_x
= (png_uint_32
)(*res_x
* .0254 + .50);
328 if (res_y
!= NULL
) *res_y
= (png_uint_32
)(*res_y
* .0254 + .50);
334 #endif /* PNG_pHYs_SUPPORTED */
335 #endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
337 /* png_get_channels really belongs in here, too, but it's been around longer */
339 #endif /* PNG_EASY_ACCESS_SUPPORTED */
342 png_get_channels(png_structp png_ptr
, png_infop info_ptr
)
344 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
345 return(info_ptr
->channels
);
351 png_get_signature(png_structp png_ptr
, png_infop info_ptr
)
353 if (png_ptr
!= NULL
&& info_ptr
!= NULL
)
354 return(info_ptr
->signature
);
359 #if defined(PNG_bKGD_SUPPORTED)
361 png_get_bKGD(png_structp png_ptr
, png_infop info_ptr
,
362 png_color_16p
*background
)
364 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_bKGD
)
365 && background
!= NULL
)
367 png_debug1(1, "in %s retrieval function", "bKGD");
368 *background
= &(info_ptr
->background
);
369 return (PNG_INFO_bKGD
);
375 #if defined(PNG_cHRM_SUPPORTED)
376 #ifdef PNG_FLOATING_POINT_SUPPORTED
378 png_get_cHRM(png_structp png_ptr
, png_infop info_ptr
,
379 double *white_x
, double *white_y
, double *red_x
, double *red_y
,
380 double *green_x
, double *green_y
, double *blue_x
, double *blue_y
)
382 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_cHRM
))
384 png_debug1(1, "in %s retrieval function", "cHRM");
386 *white_x
= (double)info_ptr
->x_white
;
388 *white_y
= (double)info_ptr
->y_white
;
390 *red_x
= (double)info_ptr
->x_red
;
392 *red_y
= (double)info_ptr
->y_red
;
394 *green_x
= (double)info_ptr
->x_green
;
396 *green_y
= (double)info_ptr
->y_green
;
398 *blue_x
= (double)info_ptr
->x_blue
;
400 *blue_y
= (double)info_ptr
->y_blue
;
401 return (PNG_INFO_cHRM
);
406 #ifdef PNG_FIXED_POINT_SUPPORTED
408 png_get_cHRM_fixed(png_structp png_ptr
, png_infop info_ptr
,
409 png_fixed_point
*white_x
, png_fixed_point
*white_y
, png_fixed_point
*red_x
,
410 png_fixed_point
*red_y
, png_fixed_point
*green_x
, png_fixed_point
*green_y
,
411 png_fixed_point
*blue_x
, png_fixed_point
*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 *white_x
= info_ptr
->int_x_white
;
419 *white_y
= info_ptr
->int_y_white
;
421 *red_x
= info_ptr
->int_x_red
;
423 *red_y
= info_ptr
->int_y_red
;
425 *green_x
= info_ptr
->int_x_green
;
427 *green_y
= info_ptr
->int_y_green
;
429 *blue_x
= info_ptr
->int_x_blue
;
431 *blue_y
= info_ptr
->int_y_blue
;
432 return (PNG_INFO_cHRM
);
439 #if defined(PNG_gAMA_SUPPORTED)
440 #ifdef PNG_FLOATING_POINT_SUPPORTED
442 png_get_gAMA(png_structp png_ptr
, png_infop info_ptr
, double *file_gamma
)
444 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_gAMA
)
445 && file_gamma
!= NULL
)
447 png_debug1(1, "in %s retrieval function", "gAMA");
448 *file_gamma
= (double)info_ptr
->gamma
;
449 return (PNG_INFO_gAMA
);
454 #ifdef PNG_FIXED_POINT_SUPPORTED
456 png_get_gAMA_fixed(png_structp png_ptr
, png_infop info_ptr
,
457 png_fixed_point
*int_file_gamma
)
459 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_gAMA
)
460 && int_file_gamma
!= NULL
)
462 png_debug1(1, "in %s retrieval function", "gAMA");
463 *int_file_gamma
= info_ptr
->int_gamma
;
464 return (PNG_INFO_gAMA
);
471 #if defined(PNG_sRGB_SUPPORTED)
473 png_get_sRGB(png_structp png_ptr
, png_infop info_ptr
, int *file_srgb_intent
)
475 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_sRGB
)
476 && file_srgb_intent
!= NULL
)
478 png_debug1(1, "in %s retrieval function", "sRGB");
479 *file_srgb_intent
= (int)info_ptr
->srgb_intent
;
480 return (PNG_INFO_sRGB
);
486 #if defined(PNG_iCCP_SUPPORTED)
488 png_get_iCCP(png_structp png_ptr
, png_infop info_ptr
,
489 png_charpp name
, int *compression_type
,
490 png_charpp profile
, png_uint_32
*proflen
)
492 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_iCCP
)
493 && name
!= NULL
&& profile
!= NULL
&& proflen
!= NULL
)
495 png_debug1(1, "in %s retrieval function", "iCCP");
496 *name
= info_ptr
->iccp_name
;
497 *profile
= info_ptr
->iccp_profile
;
498 /* compression_type is a dummy so the API won't have to change
499 if we introduce multiple compression types later. */
500 *proflen
= (int)info_ptr
->iccp_proflen
;
501 *compression_type
= (int)info_ptr
->iccp_compression
;
502 return (PNG_INFO_iCCP
);
508 #if defined(PNG_sPLT_SUPPORTED)
510 png_get_sPLT(png_structp png_ptr
, png_infop info_ptr
,
511 png_sPLT_tpp spalettes
)
513 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& spalettes
!= NULL
)
515 *spalettes
= info_ptr
->splt_palettes
;
516 return ((png_uint_32
)info_ptr
->splt_palettes_num
);
522 #if defined(PNG_hIST_SUPPORTED)
524 png_get_hIST(png_structp png_ptr
, png_infop info_ptr
, png_uint_16p
*hist
)
526 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_hIST
)
529 png_debug1(1, "in %s retrieval function", "hIST");
530 *hist
= info_ptr
->hist
;
531 return (PNG_INFO_hIST
);
538 png_get_IHDR(png_structp png_ptr
, png_infop info_ptr
,
539 png_uint_32
*width
, png_uint_32
*height
, int *bit_depth
,
540 int *color_type
, int *interlace_type
, int *compression_type
,
544 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& width
!= NULL
&& height
!= NULL
&&
545 bit_depth
!= NULL
&& color_type
!= NULL
)
547 png_debug1(1, "in %s retrieval function", "IHDR");
548 *width
= info_ptr
->width
;
549 *height
= info_ptr
->height
;
550 *bit_depth
= info_ptr
->bit_depth
;
551 if (info_ptr
->bit_depth
< 1 || info_ptr
->bit_depth
> 16)
552 png_error(png_ptr
, "Invalid bit depth");
553 *color_type
= info_ptr
->color_type
;
554 if (info_ptr
->color_type
> 6)
555 png_error(png_ptr
, "Invalid color type");
556 if (compression_type
!= NULL
)
557 *compression_type
= info_ptr
->compression_type
;
558 if (filter_type
!= NULL
)
559 *filter_type
= info_ptr
->filter_type
;
560 if (interlace_type
!= NULL
)
561 *interlace_type
= info_ptr
->interlace_type
;
563 /* check for potential overflow of rowbytes */
564 if (*width
== 0 || *width
> PNG_UINT_31_MAX
)
565 png_error(png_ptr
, "Invalid image width");
566 if (*height
== 0 || *height
> PNG_UINT_31_MAX
)
567 png_error(png_ptr
, "Invalid image height");
568 if (info_ptr
->width
> (PNG_UINT_32_MAX
569 >> 3) /* 8-byte RGBA pixels */
570 - 64 /* bigrowbuf hack */
571 - 1 /* filter byte */
572 - 7*8 /* rounding of width to multiple of 8 pixels */
573 - 8) /* extra max_pixel_depth pad */
576 "Width too large for libpng to process image data.");
583 #if defined(PNG_oFFs_SUPPORTED)
585 png_get_oFFs(png_structp png_ptr
, png_infop info_ptr
,
586 png_int_32
*offset_x
, png_int_32
*offset_y
, int *unit_type
)
588 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_oFFs
)
589 && offset_x
!= NULL
&& offset_y
!= NULL
&& unit_type
!= NULL
)
591 png_debug1(1, "in %s retrieval function", "oFFs");
592 *offset_x
= info_ptr
->x_offset
;
593 *offset_y
= info_ptr
->y_offset
;
594 *unit_type
= (int)info_ptr
->offset_unit_type
;
595 return (PNG_INFO_oFFs
);
601 #if defined(PNG_pCAL_SUPPORTED)
603 png_get_pCAL(png_structp png_ptr
, png_infop info_ptr
,
604 png_charp
*purpose
, png_int_32
*X0
, png_int_32
*X1
, int *type
, int *nparams
,
605 png_charp
*units
, png_charpp
*params
)
607 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_pCAL
)
608 && purpose
!= NULL
&& X0
!= NULL
&& X1
!= NULL
&& type
!= NULL
&&
609 nparams
!= NULL
&& units
!= NULL
&& params
!= NULL
)
611 png_debug1(1, "in %s retrieval function", "pCAL");
612 *purpose
= info_ptr
->pcal_purpose
;
613 *X0
= info_ptr
->pcal_X0
;
614 *X1
= info_ptr
->pcal_X1
;
615 *type
= (int)info_ptr
->pcal_type
;
616 *nparams
= (int)info_ptr
->pcal_nparams
;
617 *units
= info_ptr
->pcal_units
;
618 *params
= info_ptr
->pcal_params
;
619 return (PNG_INFO_pCAL
);
625 #if defined(PNG_sCAL_SUPPORTED)
626 #ifdef PNG_FLOATING_POINT_SUPPORTED
628 png_get_sCAL(png_structp png_ptr
, png_infop info_ptr
,
629 int *unit
, double *width
, double *height
)
631 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&&
632 (info_ptr
->valid
& PNG_INFO_sCAL
))
634 *unit
= info_ptr
->scal_unit
;
635 *width
= info_ptr
->scal_pixel_width
;
636 *height
= info_ptr
->scal_pixel_height
;
637 return (PNG_INFO_sCAL
);
642 #ifdef PNG_FIXED_POINT_SUPPORTED
644 png_get_sCAL_s(png_structp png_ptr
, png_infop info_ptr
,
645 int *unit
, png_charpp width
, png_charpp height
)
647 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&&
648 (info_ptr
->valid
& PNG_INFO_sCAL
))
650 *unit
= info_ptr
->scal_unit
;
651 *width
= info_ptr
->scal_s_width
;
652 *height
= info_ptr
->scal_s_height
;
653 return (PNG_INFO_sCAL
);
661 #if defined(PNG_pHYs_SUPPORTED)
663 png_get_pHYs(png_structp png_ptr
, png_infop info_ptr
,
664 png_uint_32
*res_x
, png_uint_32
*res_y
, int *unit_type
)
666 png_uint_32 retval
= 0;
668 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&&
669 (info_ptr
->valid
& PNG_INFO_pHYs
))
671 png_debug1(1, "in %s retrieval function", "pHYs");
674 *res_x
= info_ptr
->x_pixels_per_unit
;
675 retval
|= PNG_INFO_pHYs
;
679 *res_y
= info_ptr
->y_pixels_per_unit
;
680 retval
|= PNG_INFO_pHYs
;
682 if (unit_type
!= NULL
)
684 *unit_type
= (int)info_ptr
->phys_unit_type
;
685 retval
|= PNG_INFO_pHYs
;
693 png_get_PLTE(png_structp png_ptr
, png_infop info_ptr
, png_colorp
*palette
,
696 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_PLTE
)
699 png_debug1(1, "in %s retrieval function", "PLTE");
700 *palette
= info_ptr
->palette
;
701 *num_palette
= info_ptr
->num_palette
;
702 png_debug1(3, "num_palette = %d", *num_palette
);
703 return (PNG_INFO_PLTE
);
708 #if defined(PNG_sBIT_SUPPORTED)
710 png_get_sBIT(png_structp png_ptr
, png_infop info_ptr
, png_color_8p
*sig_bit
)
712 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_sBIT
)
715 png_debug1(1, "in %s retrieval function", "sBIT");
716 *sig_bit
= &(info_ptr
->sig_bit
);
717 return (PNG_INFO_sBIT
);
723 #if defined(PNG_TEXT_SUPPORTED)
725 png_get_text(png_structp png_ptr
, png_infop info_ptr
, png_textp
*text_ptr
,
728 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& info_ptr
->num_text
> 0)
730 png_debug1(1, "in %s retrieval function",
731 (png_ptr
->chunk_name
[0] == '\0' ? "text"
732 : (png_const_charp
)png_ptr
->chunk_name
));
733 if (text_ptr
!= NULL
)
734 *text_ptr
= info_ptr
->text
;
735 if (num_text
!= NULL
)
736 *num_text
= info_ptr
->num_text
;
737 return ((png_uint_32
)info_ptr
->num_text
);
739 if (num_text
!= NULL
)
745 #if defined(PNG_tIME_SUPPORTED)
747 png_get_tIME(png_structp png_ptr
, png_infop info_ptr
, png_timep
*mod_time
)
749 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_tIME
)
752 png_debug1(1, "in %s retrieval function", "tIME");
753 *mod_time
= &(info_ptr
->mod_time
);
754 return (PNG_INFO_tIME
);
760 #if defined(PNG_tRNS_SUPPORTED)
762 png_get_tRNS(png_structp png_ptr
, png_infop info_ptr
,
763 png_bytep
*trans
, int *num_trans
, png_color_16p
*trans_values
)
765 png_uint_32 retval
= 0;
766 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& (info_ptr
->valid
& PNG_INFO_tRNS
))
768 png_debug1(1, "in %s retrieval function", "tRNS");
769 if (info_ptr
->color_type
== PNG_COLOR_TYPE_PALETTE
)
773 *trans
= info_ptr
->trans
;
774 retval
|= PNG_INFO_tRNS
;
776 if (trans_values
!= NULL
)
777 *trans_values
= &(info_ptr
->trans_values
);
779 else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
781 if (trans_values
!= NULL
)
783 *trans_values
= &(info_ptr
->trans_values
);
784 retval
|= PNG_INFO_tRNS
;
789 if (num_trans
!= NULL
)
791 *num_trans
= info_ptr
->num_trans
;
792 retval
|= PNG_INFO_tRNS
;
799 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
801 png_get_unknown_chunks(png_structp png_ptr
, png_infop info_ptr
,
802 png_unknown_chunkpp unknowns
)
804 if (png_ptr
!= NULL
&& info_ptr
!= NULL
&& unknowns
!= NULL
)
806 *unknowns
= info_ptr
->unknown_chunks
;
807 return ((png_uint_32
)info_ptr
->unknown_chunks_num
);
813 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
815 png_get_rgb_to_gray_status (png_structp png_ptr
)
817 return (png_byte
)(png_ptr
? png_ptr
->rgb_to_gray_status
: 0);
821 #if defined(PNG_USER_CHUNKS_SUPPORTED)
823 png_get_user_chunk_ptr(png_structp png_ptr
)
825 return (png_ptr
? png_ptr
->user_chunk_ptr
: NULL
);
829 #ifdef PNG_WRITE_SUPPORTED
831 png_get_compression_buffer_size(png_structp png_ptr
)
833 return (png_uint_32
)(png_ptr
? png_ptr
->zbuf_size
: 0L);
837 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
839 /* this function was added to libpng 1.2.0 and should exist by default */
841 png_get_asm_flags (png_structp png_ptr
)
843 /* obsolete, to be removed from libpng-1.4.0 */
844 return (png_ptr
? 0L: 0L);
847 /* this function was added to libpng 1.2.0 and should exist by default */
849 png_get_asm_flagmask (int flag_select
)
851 /* obsolete, to be removed from libpng-1.4.0 */
852 flag_select
=flag_select
;
856 /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
857 /* this function was added to libpng 1.2.0 */
859 png_get_mmx_flagmask (int flag_select
, int *compilerID
)
861 /* obsolete, to be removed from libpng-1.4.0 */
862 flag_select
=flag_select
;
863 *compilerID
= -1; /* unknown (i.e., no asm/MMX code compiled) */
867 /* this function was added to libpng 1.2.0 */
869 png_get_mmx_bitdepth_threshold (png_structp png_ptr
)
871 /* obsolete, to be removed from libpng-1.4.0 */
872 return (png_ptr
? 0: 0);
875 /* this function was added to libpng 1.2.0 */
877 png_get_mmx_rowbytes_threshold (png_structp png_ptr
)
879 /* obsolete, to be removed from libpng-1.4.0 */
880 return (png_ptr
? 0L: 0L);
882 #endif /* ?PNG_1_0_X */
883 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
885 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
886 /* these functions were added to libpng 1.2.6 */
888 png_get_user_width_max (png_structp png_ptr
)
890 return (png_ptr
? png_ptr
->user_width_max
: 0);
893 png_get_user_height_max (png_structp png_ptr
)
895 return (png_ptr
? png_ptr
->user_height_max
: 0);
897 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
900 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */