16#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
19png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr,
22 if (png_ptr != NULL && info_ptr != NULL)
24#ifdef PNG_READ_tRNS_SUPPORTED
29 if (flag == PNG_INFO_tRNS && png_ptr->num_trans == 0)
33 return info_ptr->valid & flag;
40png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr)
42 if (png_ptr != NULL && info_ptr != NULL)
43 return info_ptr->rowbytes;
48#ifdef PNG_INFO_IMAGE_SUPPORTED
50png_get_rows(png_const_structrp png_ptr, png_const_inforp info_ptr)
52 if (png_ptr != NULL && info_ptr != NULL)
53 return info_ptr->row_pointers;
59#ifdef PNG_EASY_ACCESS_SUPPORTED
62png_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr)
64 if (png_ptr != NULL && info_ptr != NULL)
65 return info_ptr->width;
71png_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr)
73 if (png_ptr != NULL && info_ptr != NULL)
74 return info_ptr->height;
80png_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr)
82 if (png_ptr != NULL && info_ptr != NULL)
83 return info_ptr->bit_depth;
89png_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
91 if (png_ptr != NULL && info_ptr != NULL)
92 return info_ptr->color_type;
98png_get_filter_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
100 if (png_ptr != NULL && info_ptr != NULL)
101 return info_ptr->filter_type;
107png_get_interlace_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
109 if (png_ptr != NULL && info_ptr != NULL)
110 return info_ptr->interlace_type;
116png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
118 if (png_ptr != NULL && info_ptr != NULL)
119 return info_ptr->compression_type;
125png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
128#ifdef PNG_pHYs_SUPPORTED
129 png_debug(1,
"in png_get_x_pixels_per_meter");
131 if (png_ptr != NULL && info_ptr != NULL &&
132 (info_ptr->valid & PNG_INFO_pHYs) != 0)
134 if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
135 return info_ptr->x_pixels_per_unit;
146png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
149#ifdef PNG_pHYs_SUPPORTED
150 png_debug(1,
"in png_get_y_pixels_per_meter");
152 if (png_ptr != NULL && info_ptr != NULL &&
153 (info_ptr->valid & PNG_INFO_pHYs) != 0)
155 if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
156 return info_ptr->y_pixels_per_unit;
167png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
169#ifdef PNG_pHYs_SUPPORTED
170 png_debug(1,
"in png_get_pixels_per_meter");
172 if (png_ptr != NULL && info_ptr != NULL &&
173 (info_ptr->valid & PNG_INFO_pHYs) != 0)
175 if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER &&
176 info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit)
177 return info_ptr->x_pixels_per_unit;
187#ifdef PNG_FLOATING_POINT_SUPPORTED
189png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp
192#ifdef PNG_READ_pHYs_SUPPORTED
193 png_debug(1,
"in png_get_pixel_aspect_ratio");
195 if (png_ptr != NULL && info_ptr != NULL &&
196 (info_ptr->valid & PNG_INFO_pHYs) != 0)
198 if (info_ptr->x_pixels_per_unit != 0)
199 return (
float)info_ptr->y_pixels_per_unit
200 / (float)info_ptr->x_pixels_per_unit;
211#ifdef PNG_FIXED_POINT_SUPPORTED
212png_fixed_point PNGAPI
213png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
214 png_const_inforp info_ptr)
216#ifdef PNG_READ_pHYs_SUPPORTED
217 png_debug(1,
"in png_get_pixel_aspect_ratio_fixed");
219 if (png_ptr != NULL && info_ptr != NULL &&
220 (info_ptr->valid & PNG_INFO_pHYs) != 0 &&
221 info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 &&
222 info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX &&
223 info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX)
230 if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1,
231 (png_int_32)info_ptr->x_pixels_per_unit) != 0)
244png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
246#ifdef PNG_oFFs_SUPPORTED
247 png_debug(1,
"in png_get_x_offset_microns");
249 if (png_ptr != NULL && info_ptr != NULL &&
250 (info_ptr->valid & PNG_INFO_oFFs) != 0)
252 if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
253 return info_ptr->x_offset;
264png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
266#ifdef PNG_oFFs_SUPPORTED
267 png_debug(1,
"in png_get_y_offset_microns");
269 if (png_ptr != NULL && info_ptr != NULL &&
270 (info_ptr->valid & PNG_INFO_oFFs) != 0)
272 if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
273 return info_ptr->y_offset;
284png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
286#ifdef PNG_oFFs_SUPPORTED
287 png_debug(1,
"in png_get_x_offset_pixels");
289 if (png_ptr != NULL && info_ptr != NULL &&
290 (info_ptr->valid & PNG_INFO_oFFs) != 0)
292 if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
293 return info_ptr->x_offset;
304png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
306#ifdef PNG_oFFs_SUPPORTED
307 png_debug(1,
"in png_get_y_offset_pixels");
309 if (png_ptr != NULL && info_ptr != NULL &&
310 (info_ptr->valid & PNG_INFO_oFFs) != 0)
312 if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
313 return info_ptr->y_offset;
323#ifdef PNG_INCH_CONVERSIONS_SUPPORTED
325ppi_from_ppm(png_uint_32 ppm)
331 png_uint_32 t1001, t1101;
333 t1001 = ppm + (ppm >> 3);
334 t1101 = t1001 + (ppm >> 1);
336 t1101 += t1101 >> 15;
338 t1001 += t1001 >> 12;
341 return (ppm + 16) >> 5;
346 png_fixed_point result;
347 if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127,
349 return (png_uint_32)result;
357png_get_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
359 return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr));
363png_get_x_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
365 return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr));
369png_get_y_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
371 return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr));
374#ifdef PNG_FIXED_POINT_SUPPORTED
375static png_fixed_point
376png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns)
383 png_fixed_point result;
385 if (png_muldiv(&result, microns, 500, 127) != 0)
388 png_warning(png_ptr,
"fixed point overflow ignored");
392png_fixed_point PNGAPI
393png_get_x_offset_inches_fixed(png_const_structrp png_ptr,
394 png_const_inforp info_ptr)
396 return png_fixed_inches_from_microns(png_ptr,
397 png_get_x_offset_microns(png_ptr, info_ptr));
401#ifdef PNG_FIXED_POINT_SUPPORTED
402png_fixed_point PNGAPI
403png_get_y_offset_inches_fixed(png_const_structrp png_ptr,
404 png_const_inforp info_ptr)
406 return png_fixed_inches_from_microns(png_ptr,
407 png_get_y_offset_microns(png_ptr, info_ptr));
411#ifdef PNG_FLOATING_POINT_SUPPORTED
413png_get_x_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)
418 return (
float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937);
422#ifdef PNG_FLOATING_POINT_SUPPORTED
424png_get_y_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)
429 return (
float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937);
433#ifdef PNG_pHYs_SUPPORTED
435png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
436 png_uint_32 *res_x, png_uint_32 *res_y,
int *unit_type)
438 png_uint_32 retval = 0;
440 png_debug1(1,
"in %s retrieval function",
"pHYs");
442 if (png_ptr != NULL && info_ptr != NULL &&
443 (info_ptr->valid & PNG_INFO_pHYs) != 0)
447 *res_x = info_ptr->x_pixels_per_unit;
448 retval |= PNG_INFO_pHYs;
453 *res_y = info_ptr->y_pixels_per_unit;
454 retval |= PNG_INFO_pHYs;
457 if (unit_type != NULL)
459 *unit_type = (int)info_ptr->phys_unit_type;
460 retval |= PNG_INFO_pHYs;
464 if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
465 if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
481png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr)
483 if (png_ptr != NULL && info_ptr != NULL)
484 return info_ptr->channels;
489#ifdef PNG_READ_SUPPORTED
490png_const_bytep PNGAPI
491png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr)
493 if (png_ptr != NULL && info_ptr != NULL)
494 return info_ptr->signature;
500#ifdef PNG_bKGD_SUPPORTED
502png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
503 png_color_16p *background)
505 png_debug1(1,
"in %s retrieval function",
"bKGD");
507 if (png_ptr != NULL && info_ptr != NULL &&
508 (info_ptr->valid & PNG_INFO_bKGD) != 0 &&
511 *background = &(info_ptr->background);
512 return PNG_INFO_bKGD;
519#ifdef PNG_cHRM_SUPPORTED
524# ifdef PNG_FLOATING_POINT_SUPPORTED
526png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
527 double *whitex,
double *whitey,
double *redx,
double *redy,
528 double *greenx,
double *greeny,
double *bluex,
double *bluey)
530 png_debug1(1,
"in %s retrieval function",
"cHRM");
533 if (png_ptr != NULL && info_ptr != NULL &&
534 (info_ptr->valid & PNG_INFO_cHRM) != 0)
537 *whitex = png_float(png_ptr, info_ptr->cHRM.whitex,
"cHRM wx");
539 *whitey = png_float(png_ptr, info_ptr->cHRM.whitey,
"cHRM wy");
541 *redx = png_float(png_ptr, info_ptr->cHRM.redx,
"cHRM rx");
543 *redy = png_float(png_ptr, info_ptr->cHRM.redy,
"cHRM ry");
545 *greenx = png_float(png_ptr, info_ptr->cHRM.greenx,
"cHRM gx");
547 *greeny = png_float(png_ptr, info_ptr->cHRM.greeny,
"cHRM gy");
549 *bluex = png_float(png_ptr, info_ptr->cHRM.bluex,
"cHRM bx");
551 *bluey = png_float(png_ptr, info_ptr->cHRM.bluey,
"cHRM by");
552 return PNG_INFO_cHRM;
559png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
560 double *red_X,
double *red_Y,
double *red_Z,
double *green_X,
561 double *green_Y,
double *green_Z,
double *blue_X,
double *blue_Y,
565 png_debug1(1,
"in %s retrieval function",
"cHRM_XYZ(float)");
567 if (png_ptr != NULL && info_ptr != NULL &&
568 (info_ptr->valid & PNG_INFO_cHRM) != 0 &&
569 png_XYZ_from_xy(&XYZ, &info_ptr->cHRM) == 0)
572 *red_X = png_float(png_ptr, XYZ.red_X,
"cHRM red X");
574 *red_Y = png_float(png_ptr, XYZ.red_Y,
"cHRM red Y");
576 *red_Z = png_float(png_ptr, XYZ.red_Z,
"cHRM red Z");
578 *green_X = png_float(png_ptr, XYZ.green_X,
"cHRM green X");
580 *green_Y = png_float(png_ptr, XYZ.green_Y,
"cHRM green Y");
582 *green_Z = png_float(png_ptr, XYZ.green_Z,
"cHRM green Z");
584 *blue_X = png_float(png_ptr, XYZ.blue_X,
"cHRM blue X");
586 *blue_Y = png_float(png_ptr, XYZ.blue_Y,
"cHRM blue Y");
588 *blue_Z = png_float(png_ptr, XYZ.blue_Z,
"cHRM blue Z");
589 return PNG_INFO_cHRM;
596# ifdef PNG_FIXED_POINT_SUPPORTED
598png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
599 png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
600 png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
601 png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
602 png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
603 png_fixed_point *int_blue_Z)
606 png_debug1(1,
"in %s retrieval function",
"cHRM_XYZ");
608 if (png_ptr != NULL && info_ptr != NULL &&
609 (info_ptr->valid & PNG_INFO_cHRM) != 0U &&
610 png_XYZ_from_xy(&XYZ, &info_ptr->cHRM) == 0)
612 if (int_red_X != NULL) *int_red_X = XYZ.red_X;
613 if (int_red_Y != NULL) *int_red_Y = XYZ.red_Y;
614 if (int_red_Z != NULL) *int_red_Z = XYZ.red_Z;
615 if (int_green_X != NULL) *int_green_X = XYZ.green_X;
616 if (int_green_Y != NULL) *int_green_Y = XYZ.green_Y;
617 if (int_green_Z != NULL) *int_green_Z = XYZ.green_Z;
618 if (int_blue_X != NULL) *int_blue_X = XYZ.blue_X;
619 if (int_blue_Y != NULL) *int_blue_Y = XYZ.blue_Y;
620 if (int_blue_Z != NULL) *int_blue_Z = XYZ.blue_Z;
621 return PNG_INFO_cHRM;
628png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
629 png_fixed_point *whitex, png_fixed_point *whitey, png_fixed_point *redx,
630 png_fixed_point *redy, png_fixed_point *greenx, png_fixed_point *greeny,
631 png_fixed_point *bluex, png_fixed_point *bluey)
633 png_debug1(1,
"in %s retrieval function",
"cHRM");
636 if (png_ptr != NULL && info_ptr != NULL &&
637 (info_ptr->valid & PNG_INFO_cHRM) != 0)
639 if (whitex != NULL) *whitex = info_ptr->cHRM.whitex;
640 if (whitey != NULL) *whitey = info_ptr->cHRM.whitey;
641 if (redx != NULL) *redx = info_ptr->cHRM.redx;
642 if (redy != NULL) *redy = info_ptr->cHRM.redy;
643 if (greenx != NULL) *greenx = info_ptr->cHRM.greenx;
644 if (greeny != NULL) *greeny = info_ptr->cHRM.greeny;
645 if (bluex != NULL) *bluex = info_ptr->cHRM.bluex;
646 if (bluey != NULL) *bluey = info_ptr->cHRM.bluey;
647 return PNG_INFO_cHRM;
655#ifdef PNG_gAMA_SUPPORTED
656# ifdef PNG_FIXED_POINT_SUPPORTED
658png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
659 png_fixed_point *file_gamma)
661 png_debug1(1,
"in %s retrieval function",
"gAMA");
664 if (png_ptr != NULL && info_ptr != NULL &&
665 (info_ptr->valid & PNG_INFO_gAMA) != 0)
667 if (file_gamma != NULL) *file_gamma = info_ptr->gamma;
668 return PNG_INFO_gAMA;
675# ifdef PNG_FLOATING_POINT_SUPPORTED
677png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
680 png_debug1(1,
"in %s retrieval function",
"gAMA(float)");
683 if (png_ptr != NULL && info_ptr != NULL &&
684 (info_ptr->valid & PNG_INFO_gAMA) != 0)
686 if (file_gamma != NULL)
687 *file_gamma = png_float(png_ptr, info_ptr->gamma,
"gAMA");
689 return PNG_INFO_gAMA;
697#ifdef PNG_sRGB_SUPPORTED
699png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
700 int *file_srgb_intent)
702 png_debug1(1,
"in %s retrieval function",
"sRGB");
704 if (png_ptr != NULL && info_ptr != NULL &&
705 (info_ptr->valid & PNG_INFO_sRGB) != 0)
707 if (file_srgb_intent != NULL)
708 *file_srgb_intent = info_ptr->rendering_intent;
709 return PNG_INFO_sRGB;
716#ifdef PNG_iCCP_SUPPORTED
718png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
719 png_charpp name,
int *compression_type,
720 png_bytepp profile, png_uint_32 *proflen)
722 png_debug1(1,
"in %s retrieval function",
"iCCP");
724 if (png_ptr != NULL && info_ptr != NULL &&
725 (info_ptr->valid & PNG_INFO_iCCP) != 0 &&
726 name != NULL && profile != NULL && proflen != NULL)
728 *name = info_ptr->iccp_name;
729 *profile = info_ptr->iccp_profile;
730 *proflen = png_get_uint_32(info_ptr->iccp_profile);
734 if (compression_type != NULL)
735 *compression_type = PNG_COMPRESSION_TYPE_BASE;
736 return PNG_INFO_iCCP;
744#ifdef PNG_sPLT_SUPPORTED
746png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,
747 png_sPLT_tpp spalettes)
749 png_debug1(1,
"in %s retrieval function",
"sPLT");
751 if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
753 *spalettes = info_ptr->splt_palettes;
754 return info_ptr->splt_palettes_num;
761#ifdef PNG_cICP_SUPPORTED
763png_get_cICP(png_const_structrp png_ptr,
764 png_const_inforp info_ptr, png_bytep colour_primaries,
765 png_bytep transfer_function, png_bytep matrix_coefficients,
766 png_bytep video_full_range_flag)
768 png_debug1(1,
"in %s retrieval function",
"cICP");
770 if (png_ptr != NULL && info_ptr != NULL &&
771 (info_ptr->valid & PNG_INFO_cICP) != 0 &&
772 colour_primaries != NULL && transfer_function != NULL &&
773 matrix_coefficients != NULL && video_full_range_flag != NULL)
775 *colour_primaries = info_ptr->cicp_colour_primaries;
776 *transfer_function = info_ptr->cicp_transfer_function;
777 *matrix_coefficients = info_ptr->cicp_matrix_coefficients;
778 *video_full_range_flag = info_ptr->cicp_video_full_range_flag;
779 return (PNG_INFO_cICP);
786#ifdef PNG_cLLI_SUPPORTED
787# ifdef PNG_FIXED_POINT_SUPPORTED
789png_get_cLLI_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
791 png_uint_32p maxFALL)
793 png_debug1(1,
"in %s retrieval function",
"cLLI");
795 if (png_ptr != NULL && info_ptr != NULL &&
796 (info_ptr->valid & PNG_INFO_cLLI) != 0)
798 if (maxCLL != NULL) *maxCLL = info_ptr->maxCLL;
799 if (maxFALL != NULL) *maxFALL = info_ptr->maxFALL;
800 return PNG_INFO_cLLI;
807# ifdef PNG_FLOATING_POINT_SUPPORTED
809png_get_cLLI(png_const_structrp png_ptr, png_const_inforp info_ptr,
810 double *maxCLL,
double *maxFALL)
812 png_debug1(1,
"in %s retrieval function",
"cLLI(float)");
814 if (png_ptr != NULL && info_ptr != NULL &&
815 (info_ptr->valid & PNG_INFO_cLLI) != 0)
817 if (maxCLL != NULL) *maxCLL = info_ptr->maxCLL * .0001;
818 if (maxFALL != NULL) *maxFALL = info_ptr->maxFALL * .0001;
819 return PNG_INFO_cLLI;
827#ifdef PNG_mDCV_SUPPORTED
828# ifdef PNG_FIXED_POINT_SUPPORTED
830png_get_mDCV_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
831 png_fixed_point *white_x, png_fixed_point *white_y,
832 png_fixed_point *red_x, png_fixed_point *red_y,
833 png_fixed_point *green_x, png_fixed_point *green_y,
834 png_fixed_point *blue_x, png_fixed_point *blue_y,
835 png_uint_32p mastering_maxDL, png_uint_32p mastering_minDL)
837 png_debug1(1,
"in %s retrieval function",
"mDCV");
839 if (png_ptr != NULL && info_ptr != NULL &&
840 (info_ptr->valid & PNG_INFO_mDCV) != 0)
842 if (white_x != NULL) *white_x = info_ptr->mastering_white_x * 2;
843 if (white_y != NULL) *white_y = info_ptr->mastering_white_y * 2;
844 if (red_x != NULL) *red_x = info_ptr->mastering_red_x * 2;
845 if (red_y != NULL) *red_y = info_ptr->mastering_red_y * 2;
846 if (green_x != NULL) *green_x = info_ptr->mastering_green_x * 2;
847 if (green_y != NULL) *green_y = info_ptr->mastering_green_y * 2;
848 if (blue_x != NULL) *blue_x = info_ptr->mastering_blue_x * 2;
849 if (blue_y != NULL) *blue_y = info_ptr->mastering_blue_y * 2;
850 if (mastering_maxDL != NULL) *mastering_maxDL = info_ptr->mastering_maxDL;
851 if (mastering_minDL != NULL) *mastering_minDL = info_ptr->mastering_minDL;
852 return PNG_INFO_mDCV;
859# ifdef PNG_FLOATING_POINT_SUPPORTED
861png_get_mDCV(png_const_structrp png_ptr, png_const_inforp info_ptr,
862 double *white_x,
double *white_y,
double *red_x,
double *red_y,
863 double *green_x,
double *green_y,
double *blue_x,
double *blue_y,
864 double *mastering_maxDL,
double *mastering_minDL)
866 png_debug1(1,
"in %s retrieval function",
"mDCV(float)");
868 if (png_ptr != NULL && info_ptr != NULL &&
869 (info_ptr->valid & PNG_INFO_mDCV) != 0)
871 if (white_x != NULL) *white_x = info_ptr->mastering_white_x * .00002;
872 if (white_y != NULL) *white_y = info_ptr->mastering_white_y * .00002;
873 if (red_x != NULL) *red_x = info_ptr->mastering_red_x * .00002;
874 if (red_y != NULL) *red_y = info_ptr->mastering_red_y * .00002;
875 if (green_x != NULL) *green_x = info_ptr->mastering_green_x * .00002;
876 if (green_y != NULL) *green_y = info_ptr->mastering_green_y * .00002;
877 if (blue_x != NULL) *blue_x = info_ptr->mastering_blue_x * .00002;
878 if (blue_y != NULL) *blue_y = info_ptr->mastering_blue_y * .00002;
879 if (mastering_maxDL != NULL)
880 *mastering_maxDL = info_ptr->mastering_maxDL * .0001;
881 if (mastering_minDL != NULL)
882 *mastering_minDL = info_ptr->mastering_minDL * .0001;
883 return PNG_INFO_mDCV;
891#ifdef PNG_eXIf_SUPPORTED
893png_get_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
896 png_warning(png_ptr,
"png_get_eXIf does not work; use png_get_eXIf_1");
903png_get_eXIf_1(png_const_structrp png_ptr, png_const_inforp info_ptr,
904 png_uint_32 *num_exif, png_bytep *exif)
906 png_debug1(1,
"in %s retrieval function",
"eXIf");
908 if (png_ptr != NULL && info_ptr != NULL &&
909 (info_ptr->valid & PNG_INFO_eXIf) != 0 && exif != NULL)
911 *num_exif = info_ptr->num_exif;
912 *exif = info_ptr->exif;
913 return PNG_INFO_eXIf;
920#ifdef PNG_hIST_SUPPORTED
922png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
925 png_debug1(1,
"in %s retrieval function",
"hIST");
927 if (png_ptr != NULL && info_ptr != NULL &&
928 (info_ptr->valid & PNG_INFO_hIST) != 0 && hist != NULL)
930 *hist = info_ptr->hist;
931 return PNG_INFO_hIST;
939png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
940 png_uint_32 *width, png_uint_32 *height,
int *bit_depth,
941 int *color_type,
int *interlace_type,
int *compression_type,
944 png_debug1(1,
"in %s retrieval function",
"IHDR");
946 if (png_ptr == NULL || info_ptr == NULL)
950 *width = info_ptr->width;
953 *height = info_ptr->height;
955 if (bit_depth != NULL)
956 *bit_depth = info_ptr->bit_depth;
958 if (color_type != NULL)
959 *color_type = info_ptr->color_type;
961 if (compression_type != NULL)
962 *compression_type = info_ptr->compression_type;
964 if (filter_type != NULL)
965 *filter_type = info_ptr->filter_type;
967 if (interlace_type != NULL)
968 *interlace_type = info_ptr->interlace_type;
975 png_check_IHDR(png_ptr, info_ptr->width, info_ptr->height,
976 info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
977 info_ptr->compression_type, info_ptr->filter_type);
982#ifdef PNG_oFFs_SUPPORTED
984png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr,
985 png_int_32 *offset_x, png_int_32 *offset_y,
int *unit_type)
987 png_debug1(1,
"in %s retrieval function",
"oFFs");
989 if (png_ptr != NULL && info_ptr != NULL &&
990 (info_ptr->valid & PNG_INFO_oFFs) != 0 &&
991 offset_x != NULL && offset_y != NULL && unit_type != NULL)
993 *offset_x = info_ptr->x_offset;
994 *offset_y = info_ptr->y_offset;
995 *unit_type = (int)info_ptr->offset_unit_type;
996 return PNG_INFO_oFFs;
1003#ifdef PNG_pCAL_SUPPORTED
1005png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
1006 png_charp *purpose, png_int_32 *X0, png_int_32 *X1,
int *type,
int *nparams,
1007 png_charp *units, png_charpp *params)
1009 png_debug1(1,
"in %s retrieval function",
"pCAL");
1011 if (png_ptr != NULL && info_ptr != NULL &&
1012 (info_ptr->valid & PNG_INFO_pCAL) != 0 &&
1013 purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
1014 nparams != NULL && units != NULL && params != NULL)
1016 *purpose = info_ptr->pcal_purpose;
1017 *X0 = info_ptr->pcal_X0;
1018 *X1 = info_ptr->pcal_X1;
1019 *type = (int)info_ptr->pcal_type;
1020 *nparams = (int)info_ptr->pcal_nparams;
1021 *units = info_ptr->pcal_units;
1022 *params = info_ptr->pcal_params;
1023 return PNG_INFO_pCAL;
1030#ifdef PNG_sCAL_SUPPORTED
1031# ifdef PNG_FIXED_POINT_SUPPORTED
1032# if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
1033 defined(PNG_FLOATING_POINT_SUPPORTED)
1035png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
1036 int *unit, png_fixed_point *width, png_fixed_point *height)
1038 png_debug1(1,
"in %s retrieval function",
"sCAL");
1040 if (png_ptr != NULL && info_ptr != NULL &&
1041 (info_ptr->valid & PNG_INFO_sCAL) != 0)
1043 *unit = info_ptr->scal_unit;
1048 *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width),
"sCAL width");
1049 *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
1051 return PNG_INFO_sCAL;
1058# ifdef PNG_FLOATING_POINT_SUPPORTED
1060png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
1061 int *unit,
double *width,
double *height)
1063 png_debug1(1,
"in %s retrieval function",
"sCAL(float)");
1065 if (png_ptr != NULL && info_ptr != NULL &&
1066 (info_ptr->valid & PNG_INFO_sCAL) != 0)
1068 *unit = info_ptr->scal_unit;
1069 *width = atof(info_ptr->scal_s_width);
1070 *height = atof(info_ptr->scal_s_height);
1071 return PNG_INFO_sCAL;
1078png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr,
1079 int *unit, png_charpp width, png_charpp height)
1081 png_debug1(1,
"in %s retrieval function",
"sCAL(str)");
1083 if (png_ptr != NULL && info_ptr != NULL &&
1084 (info_ptr->valid & PNG_INFO_sCAL) != 0)
1086 *unit = info_ptr->scal_unit;
1087 *width = info_ptr->scal_s_width;
1088 *height = info_ptr->scal_s_height;
1089 return PNG_INFO_sCAL;
1096#ifdef PNG_pHYs_SUPPORTED
1098png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr,
1099 png_uint_32 *res_x, png_uint_32 *res_y,
int *unit_type)
1101 png_uint_32 retval = 0;
1103 png_debug1(1,
"in %s retrieval function",
"pHYs");
1105 if (png_ptr != NULL && info_ptr != NULL &&
1106 (info_ptr->valid & PNG_INFO_pHYs) != 0)
1110 *res_x = info_ptr->x_pixels_per_unit;
1111 retval |= PNG_INFO_pHYs;
1116 *res_y = info_ptr->y_pixels_per_unit;
1117 retval |= PNG_INFO_pHYs;
1120 if (unit_type != NULL)
1122 *unit_type = (int)info_ptr->phys_unit_type;
1123 retval |= PNG_INFO_pHYs;
1132png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr,
1133 png_colorp *palette,
int *num_palette)
1135 png_debug1(1,
"in %s retrieval function",
"PLTE");
1137 if (png_ptr != NULL && info_ptr != NULL &&
1138 (info_ptr->valid & PNG_INFO_PLTE) != 0 && palette != NULL)
1140 *palette = info_ptr->palette;
1141 *num_palette = info_ptr->num_palette;
1142 png_debug1(3,
"num_palette = %d", *num_palette);
1143 return PNG_INFO_PLTE;
1149#ifdef PNG_sBIT_SUPPORTED
1151png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,
1152 png_color_8p *sig_bit)
1154 png_debug1(1,
"in %s retrieval function",
"sBIT");
1156 if (png_ptr != NULL && info_ptr != NULL &&
1157 (info_ptr->valid & PNG_INFO_sBIT) != 0 && sig_bit != NULL)
1159 *sig_bit = &(info_ptr->sig_bit);
1160 return PNG_INFO_sBIT;
1167#ifdef PNG_TEXT_SUPPORTED
1169png_get_text(png_const_structrp png_ptr, png_inforp info_ptr,
1170 png_textp *text_ptr,
int *num_text)
1172 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
1174 png_debug1(1,
"in text retrieval function, chunk typeid = 0x%lx",
1175 (
unsigned long)png_ptr->chunk_name);
1177 if (text_ptr != NULL)
1178 *text_ptr = info_ptr->text;
1180 if (num_text != NULL)
1181 *num_text = info_ptr->num_text;
1183 return info_ptr->num_text;
1186 if (num_text != NULL)
1193#ifdef PNG_tIME_SUPPORTED
1195png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
1196 png_timep *mod_time)
1198 png_debug1(1,
"in %s retrieval function",
"tIME");
1200 if (png_ptr != NULL && info_ptr != NULL &&
1201 (info_ptr->valid & PNG_INFO_tIME) != 0 && mod_time != NULL)
1203 *mod_time = &(info_ptr->mod_time);
1204 return PNG_INFO_tIME;
1211#ifdef PNG_tRNS_SUPPORTED
1213png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
1214 png_bytep *trans_alpha,
int *num_trans, png_color_16p *trans_color)
1216 png_uint_32 retval = 0;
1218 png_debug1(1,
"in %s retrieval function",
"tRNS");
1220 if (png_ptr != NULL && info_ptr != NULL &&
1221 (info_ptr->valid & PNG_INFO_tRNS) != 0)
1223 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
1225 if (trans_alpha != NULL)
1227 *trans_alpha = info_ptr->trans_alpha;
1228 retval |= PNG_INFO_tRNS;
1231 if (trans_color != NULL)
1232 *trans_color = &(info_ptr->trans_color);
1237 if (trans_color != NULL)
1239 *trans_color = &(info_ptr->trans_color);
1240 retval |= PNG_INFO_tRNS;
1243 if (trans_alpha != NULL)
1244 *trans_alpha = NULL;
1247 if (num_trans != NULL)
1249 *num_trans = info_ptr->num_trans;
1250 retval |= PNG_INFO_tRNS;
1258#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
1260png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr,
1261 png_unknown_chunkpp unknowns)
1263 if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
1265 *unknowns = info_ptr->unknown_chunks;
1266 return info_ptr->unknown_chunks_num;
1273#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
1275png_get_rgb_to_gray_status(png_const_structrp png_ptr)
1277 return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
1281#ifdef PNG_USER_CHUNKS_SUPPORTED
1283png_get_user_chunk_ptr(png_const_structrp png_ptr)
1285 return (png_ptr ? png_ptr->user_chunk_ptr : NULL);
1290png_get_compression_buffer_size(png_const_structrp png_ptr)
1292 if (png_ptr == NULL)
1295#ifdef PNG_WRITE_SUPPORTED
1296 if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
1299#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
1300 return png_ptr->IDAT_read_size;
1302 return PNG_IDAT_READ_SIZE;
1306#ifdef PNG_WRITE_SUPPORTED
1308 return png_ptr->zbuffer_size;
1312#ifdef PNG_SET_USER_LIMITS_SUPPORTED
1316png_get_user_width_max(png_const_structrp png_ptr)
1318 return (png_ptr ? png_ptr->user_width_max : 0);
1322png_get_user_height_max(png_const_structrp png_ptr)
1324 return (png_ptr ? png_ptr->user_height_max : 0);
1329png_get_chunk_cache_max(png_const_structrp png_ptr)
1331 return (png_ptr ? png_ptr->user_chunk_cache_max : 0);
1335png_alloc_size_t PNGAPI
1336png_get_chunk_malloc_max(png_const_structrp png_ptr)
1338 return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
1343#ifdef PNG_IO_STATE_SUPPORTED
1345png_get_io_state(png_const_structrp png_ptr)
1347 return png_ptr->io_state;
1351png_get_io_chunk_type(png_const_structrp png_ptr)
1353 return png_ptr->chunk_name;
1357#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
1358# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
1360png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr)
1362 if (png_ptr != NULL && info_ptr != NULL)
1363 return png_ptr->num_palette_max;