michael@0: michael@0: /* pngget.c - retrieval of values from info struct michael@0: * michael@0: * Last changed in libpng 1.6.1 [March 28, 2013] michael@0: * Copyright (c) 1998-2013 Glenn Randers-Pehrson michael@0: * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) michael@0: * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) michael@0: * michael@0: * This code is released under the libpng license. michael@0: * For conditions of distribution and use, see the disclaimer michael@0: * and license in png.h michael@0: * michael@0: */ michael@0: michael@0: #include "pngpriv.h" michael@0: michael@0: #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr, michael@0: png_uint_32 flag) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return(info_ptr->valid & flag); michael@0: michael@0: return(0); michael@0: } michael@0: michael@0: png_size_t PNGAPI michael@0: png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return(info_ptr->rowbytes); michael@0: michael@0: return(0); michael@0: } michael@0: michael@0: #ifdef PNG_INFO_IMAGE_SUPPORTED michael@0: png_bytepp PNGAPI michael@0: png_get_rows(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return(info_ptr->row_pointers); michael@0: michael@0: return(0); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef PNG_EASY_ACCESS_SUPPORTED michael@0: /* Easy access to info, added in libpng-0.99 */ michael@0: png_uint_32 PNGAPI michael@0: png_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return info_ptr->width; michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return info_ptr->height; michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: png_byte PNGAPI michael@0: png_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return info_ptr->bit_depth; michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: png_byte PNGAPI michael@0: png_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return info_ptr->color_type; michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: png_byte PNGAPI michael@0: png_get_filter_type(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return info_ptr->filter_type; michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: png_byte PNGAPI michael@0: png_get_interlace_type(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return info_ptr->interlace_type; michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: png_byte PNGAPI michael@0: png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return info_ptr->compression_type; michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp michael@0: info_ptr) michael@0: { michael@0: #ifdef PNG_pHYs_SUPPORTED michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", michael@0: "png_get_x_pixels_per_meter"); michael@0: michael@0: if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) michael@0: return (info_ptr->x_pixels_per_unit); michael@0: } michael@0: #endif michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp michael@0: info_ptr) michael@0: { michael@0: #ifdef PNG_pHYs_SUPPORTED michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", michael@0: "png_get_y_pixels_per_meter"); michael@0: michael@0: if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) michael@0: return (info_ptr->y_pixels_per_unit); michael@0: } michael@0: #endif michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: #ifdef PNG_pHYs_SUPPORTED michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter"); michael@0: michael@0: if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER && michael@0: info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit) michael@0: return (info_ptr->x_pixels_per_unit); michael@0: } michael@0: #endif michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: #ifdef PNG_FLOATING_POINT_SUPPORTED michael@0: float PNGAPI michael@0: png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp michael@0: info_ptr) michael@0: { michael@0: #ifdef PNG_READ_pHYs_SUPPORTED michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); michael@0: michael@0: if (info_ptr->x_pixels_per_unit != 0) michael@0: return ((float)((float)info_ptr->y_pixels_per_unit michael@0: /(float)info_ptr->x_pixels_per_unit)); michael@0: } michael@0: #else michael@0: PNG_UNUSED(png_ptr) michael@0: PNG_UNUSED(info_ptr) michael@0: #endif michael@0: michael@0: return ((float)0.0); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef PNG_FIXED_POINT_SUPPORTED michael@0: png_fixed_point PNGAPI michael@0: png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr, michael@0: png_const_inforp info_ptr) michael@0: { michael@0: #ifdef PNG_READ_pHYs_SUPPORTED michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs) michael@0: && info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 michael@0: && info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX michael@0: && info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX) michael@0: { michael@0: png_fixed_point res; michael@0: michael@0: png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio_fixed"); michael@0: michael@0: /* The following casts work because a PNG 4 byte integer only has a valid michael@0: * range of 0..2^31-1; otherwise the cast might overflow. michael@0: */ michael@0: if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1, michael@0: (png_int_32)info_ptr->x_pixels_per_unit)) michael@0: return res; michael@0: } michael@0: #else michael@0: PNG_UNUSED(png_ptr) michael@0: PNG_UNUSED(info_ptr) michael@0: #endif michael@0: michael@0: return 0; michael@0: } michael@0: #endif michael@0: michael@0: png_int_32 PNGAPI michael@0: png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: #ifdef PNG_oFFs_SUPPORTED michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); michael@0: michael@0: if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) michael@0: return (info_ptr->x_offset); michael@0: } michael@0: #endif michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: png_int_32 PNGAPI michael@0: png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: #ifdef PNG_oFFs_SUPPORTED michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); michael@0: michael@0: if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) michael@0: return (info_ptr->y_offset); michael@0: } michael@0: #endif michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: png_int_32 PNGAPI michael@0: png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: #ifdef PNG_oFFs_SUPPORTED michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels"); michael@0: michael@0: if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) michael@0: return (info_ptr->x_offset); michael@0: } michael@0: #endif michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: png_int_32 PNGAPI michael@0: png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: #ifdef PNG_oFFs_SUPPORTED michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels"); michael@0: michael@0: if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) michael@0: return (info_ptr->y_offset); michael@0: } michael@0: #endif michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: #ifdef PNG_INCH_CONVERSIONS_SUPPORTED michael@0: static png_uint_32 michael@0: ppi_from_ppm(png_uint_32 ppm) michael@0: { michael@0: #if 0 michael@0: /* The conversion is *(2.54/100), in binary (32 digits): michael@0: * .00000110100000001001110101001001 michael@0: */ michael@0: png_uint_32 t1001, t1101; michael@0: ppm >>= 1; /* .1 */ michael@0: t1001 = ppm + (ppm >> 3); /* .1001 */ michael@0: t1101 = t1001 + (ppm >> 1); /* .1101 */ michael@0: ppm >>= 20; /* .000000000000000000001 */ michael@0: t1101 += t1101 >> 15; /* .1101000000000001101 */ michael@0: t1001 >>= 11; /* .000000000001001 */ michael@0: t1001 += t1001 >> 12; /* .000000000001001000000001001 */ michael@0: ppm += t1001; /* .000000000001001000001001001 */ michael@0: ppm += t1101; /* .110100000001001110101001001 */ michael@0: return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */ michael@0: #else michael@0: /* The argument is a PNG unsigned integer, so it is not permitted michael@0: * to be bigger than 2^31. michael@0: */ michael@0: png_fixed_point result; michael@0: if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127, michael@0: 5000)) michael@0: return result; michael@0: michael@0: /* Overflow. */ michael@0: return 0; michael@0: #endif michael@0: } michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr)); michael@0: } michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_x_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr)); michael@0: } michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_y_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr)); michael@0: } michael@0: michael@0: #ifdef PNG_FIXED_POINT_SUPPORTED michael@0: static png_fixed_point michael@0: png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns) michael@0: { michael@0: /* Convert from metres * 1,000,000 to inches * 100,000, meters to michael@0: * inches is simply *(100/2.54), so we want *(10/2.54) == 500/127. michael@0: * Notice that this can overflow - a warning is output and 0 is michael@0: * returned. michael@0: */ michael@0: return png_muldiv_warn(png_ptr, microns, 500, 127); michael@0: } michael@0: michael@0: png_fixed_point PNGAPI michael@0: png_get_x_offset_inches_fixed(png_const_structrp png_ptr, michael@0: png_const_inforp info_ptr) michael@0: { michael@0: return png_fixed_inches_from_microns(png_ptr, michael@0: png_get_x_offset_microns(png_ptr, info_ptr)); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef PNG_FIXED_POINT_SUPPORTED michael@0: png_fixed_point PNGAPI michael@0: png_get_y_offset_inches_fixed(png_const_structrp png_ptr, michael@0: png_const_inforp info_ptr) michael@0: { michael@0: return png_fixed_inches_from_microns(png_ptr, michael@0: png_get_y_offset_microns(png_ptr, info_ptr)); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef PNG_FLOATING_POINT_SUPPORTED michael@0: float PNGAPI michael@0: png_get_x_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: /* To avoid the overflow do the conversion directly in floating michael@0: * point. michael@0: */ michael@0: return (float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef PNG_FLOATING_POINT_SUPPORTED michael@0: float PNGAPI michael@0: png_get_y_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: /* To avoid the overflow do the conversion directly in floating michael@0: * point. michael@0: */ michael@0: return (float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef PNG_pHYs_SUPPORTED michael@0: png_uint_32 PNGAPI michael@0: png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr, michael@0: png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) michael@0: { michael@0: png_uint_32 retval = 0; michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "pHYs"); michael@0: michael@0: if (res_x != NULL) michael@0: { michael@0: *res_x = info_ptr->x_pixels_per_unit; michael@0: retval |= PNG_INFO_pHYs; michael@0: } michael@0: michael@0: if (res_y != NULL) michael@0: { michael@0: *res_y = info_ptr->y_pixels_per_unit; michael@0: retval |= PNG_INFO_pHYs; michael@0: } michael@0: michael@0: if (unit_type != NULL) michael@0: { michael@0: *unit_type = (int)info_ptr->phys_unit_type; michael@0: retval |= PNG_INFO_pHYs; michael@0: michael@0: if (*unit_type == 1) michael@0: { michael@0: if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); michael@0: if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); michael@0: } michael@0: } michael@0: } michael@0: michael@0: return (retval); michael@0: } michael@0: #endif /* PNG_pHYs_SUPPORTED */ michael@0: #endif /* PNG_INCH_CONVERSIONS_SUPPORTED */ michael@0: michael@0: /* png_get_channels really belongs in here, too, but it's been around longer */ michael@0: michael@0: #endif /* PNG_EASY_ACCESS_SUPPORTED */ michael@0: michael@0: michael@0: png_byte PNGAPI michael@0: png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return(info_ptr->channels); michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: #ifdef PNG_READ_SUPPORTED michael@0: png_const_bytep PNGAPI michael@0: png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return(info_ptr->signature); michael@0: michael@0: return (NULL); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef PNG_bKGD_SUPPORTED michael@0: png_uint_32 PNGAPI michael@0: png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr, michael@0: png_color_16p *background) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) michael@0: && background != NULL) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "bKGD"); michael@0: michael@0: *background = &(info_ptr->background); michael@0: return (PNG_INFO_bKGD); michael@0: } michael@0: michael@0: return (0); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef PNG_cHRM_SUPPORTED michael@0: /* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the michael@0: * same time to correct the rgb grayscale coefficient defaults obtained from the michael@0: * cHRM chunk in 1.5.4 michael@0: */ michael@0: # ifdef PNG_FLOATING_POINT_SUPPORTED michael@0: png_uint_32 PNGAPI michael@0: png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr, michael@0: double *white_x, double *white_y, double *red_x, double *red_y, michael@0: double *green_x, double *green_y, double *blue_x, double *blue_y) michael@0: { michael@0: /* Quiet API change: this code used to only return the end points if a cHRM michael@0: * chunk was present, but the end points can also come from iCCP or sRGB michael@0: * chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and michael@0: * the png_set_ APIs merely check that set end points are mutually michael@0: * consistent. michael@0: */ michael@0: if (png_ptr != NULL && info_ptr != NULL && michael@0: (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "cHRM"); michael@0: michael@0: if (white_x != NULL) michael@0: *white_x = png_float(png_ptr, michael@0: info_ptr->colorspace.end_points_xy.whitex, "cHRM white X"); michael@0: if (white_y != NULL) michael@0: *white_y = png_float(png_ptr, michael@0: info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y"); michael@0: if (red_x != NULL) michael@0: *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx, michael@0: "cHRM red X"); michael@0: if (red_y != NULL) michael@0: *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy, michael@0: "cHRM red Y"); michael@0: if (green_x != NULL) michael@0: *green_x = png_float(png_ptr, michael@0: info_ptr->colorspace.end_points_xy.greenx, "cHRM green X"); michael@0: if (green_y != NULL) michael@0: *green_y = png_float(png_ptr, michael@0: info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y"); michael@0: if (blue_x != NULL) michael@0: *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex, michael@0: "cHRM blue X"); michael@0: if (blue_y != NULL) michael@0: *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey, michael@0: "cHRM blue Y"); michael@0: return (PNG_INFO_cHRM); michael@0: } michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr, michael@0: double *red_X, double *red_Y, double *red_Z, double *green_X, michael@0: double *green_Y, double *green_Z, double *blue_X, double *blue_Y, michael@0: double *blue_Z) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL && michael@0: (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)"); michael@0: michael@0: if (red_X != NULL) michael@0: *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X, michael@0: "cHRM red X"); michael@0: if (red_Y != NULL) michael@0: *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y, michael@0: "cHRM red Y"); michael@0: if (red_Z != NULL) michael@0: *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z, michael@0: "cHRM red Z"); michael@0: if (green_X != NULL) michael@0: *green_X = png_float(png_ptr, michael@0: info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X"); michael@0: if (green_Y != NULL) michael@0: *green_Y = png_float(png_ptr, michael@0: info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y"); michael@0: if (green_Z != NULL) michael@0: *green_Z = png_float(png_ptr, michael@0: info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z"); michael@0: if (blue_X != NULL) michael@0: *blue_X = png_float(png_ptr, michael@0: info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X"); michael@0: if (blue_Y != NULL) michael@0: *blue_Y = png_float(png_ptr, michael@0: info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y"); michael@0: if (blue_Z != NULL) michael@0: *blue_Z = png_float(png_ptr, michael@0: info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z"); michael@0: return (PNG_INFO_cHRM); michael@0: } michael@0: michael@0: return (0); michael@0: } michael@0: # endif michael@0: michael@0: # ifdef PNG_FIXED_POINT_SUPPORTED michael@0: png_uint_32 PNGAPI michael@0: png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, michael@0: png_fixed_point *int_red_X, png_fixed_point *int_red_Y, michael@0: png_fixed_point *int_red_Z, png_fixed_point *int_green_X, michael@0: png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, michael@0: png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, michael@0: png_fixed_point *int_blue_Z) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL && michael@0: (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "cHRM_XYZ"); michael@0: michael@0: if (int_red_X != NULL) michael@0: *int_red_X = info_ptr->colorspace.end_points_XYZ.red_X; michael@0: if (int_red_Y != NULL) michael@0: *int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y; michael@0: if (int_red_Z != NULL) michael@0: *int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z; michael@0: if (int_green_X != NULL) michael@0: *int_green_X = info_ptr->colorspace.end_points_XYZ.green_X; michael@0: if (int_green_Y != NULL) michael@0: *int_green_Y = info_ptr->colorspace.end_points_XYZ.green_Y; michael@0: if (int_green_Z != NULL) michael@0: *int_green_Z = info_ptr->colorspace.end_points_XYZ.green_Z; michael@0: if (int_blue_X != NULL) michael@0: *int_blue_X = info_ptr->colorspace.end_points_XYZ.blue_X; michael@0: if (int_blue_Y != NULL) michael@0: *int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y; michael@0: if (int_blue_Z != NULL) michael@0: *int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z; michael@0: return (PNG_INFO_cHRM); michael@0: } michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, michael@0: png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, michael@0: png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, michael@0: png_fixed_point *blue_x, png_fixed_point *blue_y) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "cHRM"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL && michael@0: (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) michael@0: { michael@0: if (white_x != NULL) michael@0: *white_x = info_ptr->colorspace.end_points_xy.whitex; michael@0: if (white_y != NULL) michael@0: *white_y = info_ptr->colorspace.end_points_xy.whitey; michael@0: if (red_x != NULL) michael@0: *red_x = info_ptr->colorspace.end_points_xy.redx; michael@0: if (red_y != NULL) michael@0: *red_y = info_ptr->colorspace.end_points_xy.redy; michael@0: if (green_x != NULL) michael@0: *green_x = info_ptr->colorspace.end_points_xy.greenx; michael@0: if (green_y != NULL) michael@0: *green_y = info_ptr->colorspace.end_points_xy.greeny; michael@0: if (blue_x != NULL) michael@0: *blue_x = info_ptr->colorspace.end_points_xy.bluex; michael@0: if (blue_y != NULL) michael@0: *blue_y = info_ptr->colorspace.end_points_xy.bluey; michael@0: return (PNG_INFO_cHRM); michael@0: } michael@0: michael@0: return (0); michael@0: } michael@0: # endif michael@0: #endif michael@0: michael@0: #ifdef PNG_gAMA_SUPPORTED michael@0: # ifdef PNG_FIXED_POINT_SUPPORTED michael@0: png_uint_32 PNGAPI michael@0: png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, michael@0: png_fixed_point *file_gamma) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "gAMA"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL && michael@0: (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) && michael@0: file_gamma != NULL) michael@0: { michael@0: *file_gamma = info_ptr->colorspace.gamma; michael@0: return (PNG_INFO_gAMA); michael@0: } michael@0: michael@0: return (0); michael@0: } michael@0: # endif michael@0: michael@0: # ifdef PNG_FLOATING_POINT_SUPPORTED michael@0: png_uint_32 PNGAPI michael@0: png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr, michael@0: double *file_gamma) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "gAMA(float)"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL && michael@0: (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) && michael@0: file_gamma != NULL) michael@0: { michael@0: *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma, michael@0: "png_get_gAMA"); michael@0: return (PNG_INFO_gAMA); michael@0: } michael@0: michael@0: return (0); michael@0: } michael@0: # endif michael@0: #endif michael@0: michael@0: #ifdef PNG_sRGB_SUPPORTED michael@0: png_uint_32 PNGAPI michael@0: png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr, michael@0: int *file_srgb_intent) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "sRGB"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) michael@0: && file_srgb_intent != NULL) michael@0: { michael@0: *file_srgb_intent = info_ptr->colorspace.rendering_intent; michael@0: return (PNG_INFO_sRGB); michael@0: } michael@0: michael@0: return (0); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef PNG_iCCP_SUPPORTED michael@0: png_uint_32 PNGAPI michael@0: png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, michael@0: png_charpp name, int *compression_type, michael@0: png_bytepp profile, png_uint_32 *proflen) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "iCCP"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) michael@0: && name != NULL && compression_type != NULL && profile != NULL && michael@0: proflen != NULL) michael@0: { michael@0: *name = info_ptr->iccp_name; michael@0: *profile = info_ptr->iccp_profile; michael@0: *proflen = png_get_uint_32(info_ptr->iccp_profile); michael@0: /* This is somewhat irrelevant since the profile data returned has michael@0: * actually been uncompressed. michael@0: */ michael@0: *compression_type = PNG_COMPRESSION_TYPE_BASE; michael@0: return (PNG_INFO_iCCP); michael@0: } michael@0: michael@0: return (0); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef PNG_sPLT_SUPPORTED michael@0: int PNGAPI michael@0: png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr, michael@0: png_sPLT_tpp spalettes) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) michael@0: { michael@0: *spalettes = info_ptr->splt_palettes; michael@0: return info_ptr->splt_palettes_num; michael@0: } michael@0: michael@0: return (0); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef PNG_hIST_SUPPORTED michael@0: png_uint_32 PNGAPI michael@0: png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr, michael@0: png_uint_16p *hist) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "hIST"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) michael@0: && hist != NULL) michael@0: { michael@0: *hist = info_ptr->hist; michael@0: return (PNG_INFO_hIST); michael@0: } michael@0: michael@0: return (0); michael@0: } michael@0: #endif michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr, michael@0: png_uint_32 *width, png_uint_32 *height, int *bit_depth, michael@0: int *color_type, int *interlace_type, int *compression_type, michael@0: int *filter_type) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "IHDR"); michael@0: michael@0: if (png_ptr == NULL || info_ptr == NULL || width == NULL || michael@0: height == NULL || bit_depth == NULL || color_type == NULL) michael@0: return (0); michael@0: michael@0: *width = info_ptr->width; michael@0: *height = info_ptr->height; michael@0: *bit_depth = info_ptr->bit_depth; michael@0: *color_type = info_ptr->color_type; michael@0: michael@0: if (compression_type != NULL) michael@0: *compression_type = info_ptr->compression_type; michael@0: michael@0: if (filter_type != NULL) michael@0: *filter_type = info_ptr->filter_type; michael@0: michael@0: if (interlace_type != NULL) michael@0: *interlace_type = info_ptr->interlace_type; michael@0: michael@0: /* This is redundant if we can be sure that the info_ptr values were all michael@0: * assigned in png_set_IHDR(). We do the check anyhow in case an michael@0: * application has ignored our advice not to mess with the members michael@0: * of info_ptr directly. michael@0: */ michael@0: png_check_IHDR(png_ptr, info_ptr->width, info_ptr->height, michael@0: info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, michael@0: info_ptr->compression_type, info_ptr->filter_type); michael@0: michael@0: return (1); michael@0: } michael@0: michael@0: #ifdef PNG_oFFs_SUPPORTED michael@0: png_uint_32 PNGAPI michael@0: png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr, michael@0: png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "oFFs"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) michael@0: && offset_x != NULL && offset_y != NULL && unit_type != NULL) michael@0: { michael@0: *offset_x = info_ptr->x_offset; michael@0: *offset_y = info_ptr->y_offset; michael@0: *unit_type = (int)info_ptr->offset_unit_type; michael@0: return (PNG_INFO_oFFs); michael@0: } michael@0: michael@0: return (0); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef PNG_pCAL_SUPPORTED michael@0: png_uint_32 PNGAPI michael@0: png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, michael@0: png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, michael@0: png_charp *units, png_charpp *params) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "pCAL"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) michael@0: && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && michael@0: nparams != NULL && units != NULL && params != NULL) michael@0: { michael@0: *purpose = info_ptr->pcal_purpose; michael@0: *X0 = info_ptr->pcal_X0; michael@0: *X1 = info_ptr->pcal_X1; michael@0: *type = (int)info_ptr->pcal_type; michael@0: *nparams = (int)info_ptr->pcal_nparams; michael@0: *units = info_ptr->pcal_units; michael@0: *params = info_ptr->pcal_params; michael@0: return (PNG_INFO_pCAL); michael@0: } michael@0: michael@0: return (0); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef PNG_sCAL_SUPPORTED michael@0: # ifdef PNG_FIXED_POINT_SUPPORTED michael@0: # if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ michael@0: defined(PNG_FLOATING_POINT_SUPPORTED) michael@0: png_uint_32 PNGAPI michael@0: png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, michael@0: int *unit, png_fixed_point *width, png_fixed_point *height) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL && michael@0: (info_ptr->valid & PNG_INFO_sCAL)) michael@0: { michael@0: *unit = info_ptr->scal_unit; michael@0: /*TODO: make this work without FP support; the API is currently eliminated michael@0: * if neither floating point APIs nor internal floating point arithmetic michael@0: * are enabled. michael@0: */ michael@0: *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width"); michael@0: *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height), michael@0: "sCAL height"); michael@0: return (PNG_INFO_sCAL); michael@0: } michael@0: michael@0: return(0); michael@0: } michael@0: # endif /* FLOATING_ARITHMETIC */ michael@0: # endif /* FIXED_POINT */ michael@0: # ifdef PNG_FLOATING_POINT_SUPPORTED michael@0: png_uint_32 PNGAPI michael@0: png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr, michael@0: int *unit, double *width, double *height) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL && michael@0: (info_ptr->valid & PNG_INFO_sCAL)) michael@0: { michael@0: *unit = info_ptr->scal_unit; michael@0: *width = atof(info_ptr->scal_s_width); michael@0: *height = atof(info_ptr->scal_s_height); michael@0: return (PNG_INFO_sCAL); michael@0: } michael@0: michael@0: return(0); michael@0: } michael@0: # endif /* FLOATING POINT */ michael@0: png_uint_32 PNGAPI michael@0: png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr, michael@0: int *unit, png_charpp width, png_charpp height) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL && michael@0: (info_ptr->valid & PNG_INFO_sCAL)) michael@0: { michael@0: *unit = info_ptr->scal_unit; michael@0: *width = info_ptr->scal_s_width; michael@0: *height = info_ptr->scal_s_height; michael@0: return (PNG_INFO_sCAL); michael@0: } michael@0: michael@0: return(0); michael@0: } michael@0: #endif /* sCAL */ michael@0: michael@0: #ifdef PNG_pHYs_SUPPORTED michael@0: png_uint_32 PNGAPI michael@0: png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr, michael@0: png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) michael@0: { michael@0: png_uint_32 retval = 0; michael@0: michael@0: png_debug1(1, "in %s retrieval function", "pHYs"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL && michael@0: (info_ptr->valid & PNG_INFO_pHYs)) michael@0: { michael@0: if (res_x != NULL) michael@0: { michael@0: *res_x = info_ptr->x_pixels_per_unit; michael@0: retval |= PNG_INFO_pHYs; michael@0: } michael@0: michael@0: if (res_y != NULL) michael@0: { michael@0: *res_y = info_ptr->y_pixels_per_unit; michael@0: retval |= PNG_INFO_pHYs; michael@0: } michael@0: michael@0: if (unit_type != NULL) michael@0: { michael@0: *unit_type = (int)info_ptr->phys_unit_type; michael@0: retval |= PNG_INFO_pHYs; michael@0: } michael@0: } michael@0: michael@0: return (retval); michael@0: } michael@0: #endif /* pHYs */ michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr, michael@0: png_colorp *palette, int *num_palette) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "PLTE"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) michael@0: && palette != NULL) michael@0: { michael@0: *palette = info_ptr->palette; michael@0: *num_palette = info_ptr->num_palette; michael@0: png_debug1(3, "num_palette = %d", *num_palette); michael@0: return (PNG_INFO_PLTE); michael@0: } michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: #ifdef PNG_sBIT_SUPPORTED michael@0: png_uint_32 PNGAPI michael@0: png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr, michael@0: png_color_8p *sig_bit) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "sBIT"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) michael@0: && sig_bit != NULL) michael@0: { michael@0: *sig_bit = &(info_ptr->sig_bit); michael@0: return (PNG_INFO_sBIT); michael@0: } michael@0: michael@0: return (0); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef PNG_TEXT_SUPPORTED michael@0: int PNGAPI michael@0: png_get_text(png_const_structrp png_ptr, png_inforp info_ptr, michael@0: png_textp *text_ptr, int *num_text) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) michael@0: { michael@0: png_debug1(1, "in 0x%lx retrieval function", michael@0: (unsigned long)png_ptr->chunk_name); michael@0: michael@0: if (text_ptr != NULL) michael@0: *text_ptr = info_ptr->text; michael@0: michael@0: if (num_text != NULL) michael@0: *num_text = info_ptr->num_text; michael@0: michael@0: return info_ptr->num_text; michael@0: } michael@0: michael@0: if (num_text != NULL) michael@0: *num_text = 0; michael@0: michael@0: return(0); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef PNG_tIME_SUPPORTED michael@0: png_uint_32 PNGAPI michael@0: png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr, michael@0: png_timep *mod_time) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "tIME"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) michael@0: && mod_time != NULL) michael@0: { michael@0: *mod_time = &(info_ptr->mod_time); michael@0: return (PNG_INFO_tIME); michael@0: } michael@0: michael@0: return (0); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef PNG_tRNS_SUPPORTED michael@0: png_uint_32 PNGAPI michael@0: png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr, michael@0: png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color) michael@0: { michael@0: png_uint_32 retval = 0; michael@0: if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "tRNS"); michael@0: michael@0: if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) michael@0: { michael@0: if (trans_alpha != NULL) michael@0: { michael@0: *trans_alpha = info_ptr->trans_alpha; michael@0: retval |= PNG_INFO_tRNS; michael@0: } michael@0: michael@0: if (trans_color != NULL) michael@0: *trans_color = &(info_ptr->trans_color); michael@0: } michael@0: michael@0: else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ michael@0: { michael@0: if (trans_color != NULL) michael@0: { michael@0: *trans_color = &(info_ptr->trans_color); michael@0: retval |= PNG_INFO_tRNS; michael@0: } michael@0: michael@0: if (trans_alpha != NULL) michael@0: *trans_alpha = NULL; michael@0: } michael@0: michael@0: if (num_trans != NULL) michael@0: { michael@0: *num_trans = info_ptr->num_trans; michael@0: retval |= PNG_INFO_tRNS; michael@0: } michael@0: } michael@0: michael@0: return (retval); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED michael@0: int PNGAPI michael@0: png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr, michael@0: png_unknown_chunkpp unknowns) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL) michael@0: { michael@0: *unknowns = info_ptr->unknown_chunks; michael@0: return info_ptr->unknown_chunks_num; michael@0: } michael@0: michael@0: return (0); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED michael@0: png_byte PNGAPI michael@0: png_get_rgb_to_gray_status (png_const_structrp png_ptr) michael@0: { michael@0: return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef PNG_USER_CHUNKS_SUPPORTED michael@0: png_voidp PNGAPI michael@0: png_get_user_chunk_ptr(png_const_structrp png_ptr) michael@0: { michael@0: return (png_ptr ? png_ptr->user_chunk_ptr : NULL); michael@0: } michael@0: #endif michael@0: michael@0: png_size_t PNGAPI michael@0: png_get_compression_buffer_size(png_const_structrp png_ptr) michael@0: { michael@0: if (png_ptr == NULL) michael@0: return 0; michael@0: michael@0: # ifdef PNG_WRITE_SUPPORTED michael@0: if (png_ptr->mode & PNG_IS_READ_STRUCT) michael@0: # endif michael@0: { michael@0: # ifdef PNG_SEQUENTIAL_READ_SUPPORTED michael@0: return png_ptr->IDAT_read_size; michael@0: # else michael@0: return PNG_IDAT_READ_SIZE; michael@0: # endif michael@0: } michael@0: michael@0: # ifdef PNG_WRITE_SUPPORTED michael@0: else michael@0: return png_ptr->zbuffer_size; michael@0: # endif michael@0: } michael@0: michael@0: #ifdef PNG_SET_USER_LIMITS_SUPPORTED michael@0: /* These functions were added to libpng 1.2.6 and were enabled michael@0: * by default in libpng-1.4.0 */ michael@0: png_uint_32 PNGAPI michael@0: png_get_user_width_max (png_const_structrp png_ptr) michael@0: { michael@0: return (png_ptr ? png_ptr->user_width_max : 0); michael@0: } michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_user_height_max (png_const_structrp png_ptr) michael@0: { michael@0: return (png_ptr ? png_ptr->user_height_max : 0); michael@0: } michael@0: michael@0: /* This function was added to libpng 1.4.0 */ michael@0: png_uint_32 PNGAPI michael@0: png_get_chunk_cache_max (png_const_structrp png_ptr) michael@0: { michael@0: return (png_ptr ? png_ptr->user_chunk_cache_max : 0); michael@0: } michael@0: michael@0: /* This function was added to libpng 1.4.1 */ michael@0: png_alloc_size_t PNGAPI michael@0: png_get_chunk_malloc_max (png_const_structrp png_ptr) michael@0: { michael@0: return (png_ptr ? png_ptr->user_chunk_malloc_max : 0); michael@0: } michael@0: #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ michael@0: michael@0: /* These functions were added to libpng 1.4.0 */ michael@0: #ifdef PNG_IO_STATE_SUPPORTED michael@0: png_uint_32 PNGAPI michael@0: png_get_io_state (png_const_structrp png_ptr) michael@0: { michael@0: return png_ptr->io_state; michael@0: } michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_io_chunk_type (png_const_structrp png_ptr) michael@0: { michael@0: return png_ptr->chunk_name; michael@0: } michael@0: #endif /* ?PNG_IO_STATE_SUPPORTED */ michael@0: michael@0: #ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED michael@0: # ifdef PNG_GET_PALETTE_MAX_SUPPORTED michael@0: int PNGAPI michael@0: png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr) michael@0: { michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return png_ptr->num_palette_max; michael@0: michael@0: return (-1); michael@0: } michael@0: # endif michael@0: #endif michael@0: michael@0: #ifdef PNG_APNG_SUPPORTED michael@0: png_uint_32 PNGAPI michael@0: png_get_acTL(png_structp png_ptr, png_infop info_ptr, michael@0: png_uint_32 *num_frames, png_uint_32 *num_plays) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "acTL"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL && michael@0: (info_ptr->valid & PNG_INFO_acTL) && michael@0: num_frames != NULL && num_plays != NULL) michael@0: { michael@0: *num_frames = info_ptr->num_frames; michael@0: *num_plays = info_ptr->num_plays; michael@0: return (1); michael@0: } michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_num_frames(png_structp png_ptr, png_infop info_ptr) michael@0: { michael@0: png_debug(1, "in png_get_num_frames()"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return (info_ptr->num_frames); michael@0: return (0); michael@0: } michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_num_plays(png_structp png_ptr, png_infop info_ptr) michael@0: { michael@0: png_debug(1, "in png_get_num_plays()"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return (info_ptr->num_plays); michael@0: return (0); michael@0: } michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr, michael@0: png_uint_32 *width, png_uint_32 *height, michael@0: png_uint_32 *x_offset, png_uint_32 *y_offset, michael@0: png_uint_16 *delay_num, png_uint_16 *delay_den, michael@0: png_byte *dispose_op, png_byte *blend_op) michael@0: { michael@0: png_debug1(1, "in %s retrieval function", "fcTL"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL && michael@0: (info_ptr->valid & PNG_INFO_fcTL) && michael@0: width != NULL && height != NULL && michael@0: x_offset != NULL && y_offset != NULL && michael@0: delay_num != NULL && delay_den != NULL && michael@0: dispose_op != NULL && blend_op != NULL) michael@0: { michael@0: *width = info_ptr->next_frame_width; michael@0: *height = info_ptr->next_frame_height; michael@0: *x_offset = info_ptr->next_frame_x_offset; michael@0: *y_offset = info_ptr->next_frame_y_offset; michael@0: *delay_num = info_ptr->next_frame_delay_num; michael@0: *delay_den = info_ptr->next_frame_delay_den; michael@0: *dispose_op = info_ptr->next_frame_dispose_op; michael@0: *blend_op = info_ptr->next_frame_blend_op; michael@0: return (1); michael@0: } michael@0: michael@0: return (0); michael@0: } michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_next_frame_width(png_structp png_ptr, png_infop info_ptr) michael@0: { michael@0: png_debug(1, "in png_get_next_frame_width()"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return (info_ptr->next_frame_width); michael@0: return (0); michael@0: } michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_next_frame_height(png_structp png_ptr, png_infop info_ptr) michael@0: { michael@0: png_debug(1, "in png_get_next_frame_height()"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return (info_ptr->next_frame_height); michael@0: return (0); michael@0: } michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_next_frame_x_offset(png_structp png_ptr, png_infop info_ptr) michael@0: { michael@0: png_debug(1, "in png_get_next_frame_x_offset()"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return (info_ptr->next_frame_x_offset); michael@0: return (0); michael@0: } michael@0: michael@0: png_uint_32 PNGAPI michael@0: png_get_next_frame_y_offset(png_structp png_ptr, png_infop info_ptr) michael@0: { michael@0: png_debug(1, "in png_get_next_frame_y_offset()"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return (info_ptr->next_frame_y_offset); michael@0: return (0); michael@0: } michael@0: michael@0: png_uint_16 PNGAPI michael@0: png_get_next_frame_delay_num(png_structp png_ptr, png_infop info_ptr) michael@0: { michael@0: png_debug(1, "in png_get_next_frame_delay_num()"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return (info_ptr->next_frame_delay_num); michael@0: return (0); michael@0: } michael@0: michael@0: png_uint_16 PNGAPI michael@0: png_get_next_frame_delay_den(png_structp png_ptr, png_infop info_ptr) michael@0: { michael@0: png_debug(1, "in png_get_next_frame_delay_den()"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return (info_ptr->next_frame_delay_den); michael@0: return (0); michael@0: } michael@0: michael@0: png_byte PNGAPI michael@0: png_get_next_frame_dispose_op(png_structp png_ptr, png_infop info_ptr) michael@0: { michael@0: png_debug(1, "in png_get_next_frame_dispose_op()"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return (info_ptr->next_frame_dispose_op); michael@0: return (0); michael@0: } michael@0: michael@0: png_byte PNGAPI michael@0: png_get_next_frame_blend_op(png_structp png_ptr, png_infop info_ptr) michael@0: { michael@0: png_debug(1, "in png_get_next_frame_blend_op()"); michael@0: michael@0: if (png_ptr != NULL && info_ptr != NULL) michael@0: return (info_ptr->next_frame_blend_op); michael@0: return (0); michael@0: } michael@0: michael@0: png_byte PNGAPI michael@0: png_get_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr) michael@0: { michael@0: png_debug(1, "in png_first_frame_is_hidden()"); michael@0: michael@0: if (png_ptr != NULL) michael@0: return (png_byte)(png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN); michael@0: michael@0: PNG_UNUSED(info_ptr) michael@0: michael@0: return 0; michael@0: } michael@0: #endif /* PNG_APNG_SUPPORTED */ michael@0: #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */