summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/libpng/pngget.c
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@theqtcompany.com>2015-04-08 12:30:36 +0200
committeraavit <eirik.aavitsland@theqtcompany.com>2015-04-09 12:14:28 +0000
commit68c137cc725ceadec68c455e0e3e365ecb00f2c1 (patch)
tree242485964753e2e7890015694a916c71755cdfb3 /src/3rdparty/libpng/pngget.c
parentf0cee4568ec3bd58cbc33108a6e606c3294e0fb3 (diff)
Update bundled libpng to version 1.6.17
Merged in the upstream version, which obsoleted many of the local patches. The remaining diff to clean 1.6.17 is archived in the qtpatches.diff file. Change-Id: I5065435dc5a922d3f4a46eb37a23a4877dde2ee6 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Diffstat (limited to 'src/3rdparty/libpng/pngget.c')
-rw-r--r--src/3rdparty/libpng/pngget.c563
1 files changed, 329 insertions, 234 deletions
diff --git a/src/3rdparty/libpng/pngget.c b/src/3rdparty/libpng/pngget.c
index 43400cda7e..743a6a9bbc 100644
--- a/src/3rdparty/libpng/pngget.c
+++ b/src/3rdparty/libpng/pngget.c
@@ -1,8 +1,8 @@
/* pngget.c - retrieval of values from info struct
*
- * Last changed in libpng 1.5.7 [December 15, 2011]
- * Copyright (c) 1998-2011 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.17 [March 26, 2015]
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@@ -17,7 +17,7 @@
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
png_uint_32 PNGAPI
-png_get_valid(png_const_structp png_ptr, png_const_infop info_ptr,
+png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr,
png_uint_32 flag)
{
if (png_ptr != NULL && info_ptr != NULL)
@@ -27,7 +27,7 @@ png_get_valid(png_const_structp png_ptr, png_const_infop info_ptr,
}
png_size_t PNGAPI
-png_get_rowbytes(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->rowbytes);
@@ -37,7 +37,7 @@ png_get_rowbytes(png_const_structp png_ptr, png_const_infop info_ptr)
#ifdef PNG_INFO_IMAGE_SUPPORTED
png_bytepp PNGAPI
-png_get_rows(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_rows(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->row_pointers);
@@ -49,7 +49,7 @@ png_get_rows(png_const_structp png_ptr, png_const_infop info_ptr)
#ifdef PNG_EASY_ACCESS_SUPPORTED
/* Easy access to info, added in libpng-0.99 */
png_uint_32 PNGAPI
-png_get_image_width(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->width;
@@ -58,7 +58,7 @@ png_get_image_width(png_const_structp png_ptr, png_const_infop info_ptr)
}
png_uint_32 PNGAPI
-png_get_image_height(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->height;
@@ -67,7 +67,7 @@ png_get_image_height(png_const_structp png_ptr, png_const_infop info_ptr)
}
png_byte PNGAPI
-png_get_bit_depth(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->bit_depth;
@@ -76,7 +76,7 @@ png_get_bit_depth(png_const_structp png_ptr, png_const_infop info_ptr)
}
png_byte PNGAPI
-png_get_color_type(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->color_type;
@@ -85,7 +85,7 @@ png_get_color_type(png_const_structp png_ptr, png_const_infop info_ptr)
}
png_byte PNGAPI
-png_get_filter_type(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_filter_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->filter_type;
@@ -94,7 +94,7 @@ png_get_filter_type(png_const_structp png_ptr, png_const_infop info_ptr)
}
png_byte PNGAPI
-png_get_interlace_type(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_interlace_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->interlace_type;
@@ -103,7 +103,7 @@ png_get_interlace_type(png_const_structp png_ptr, png_const_infop info_ptr)
}
png_byte PNGAPI
-png_get_compression_type(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->compression_type;
@@ -112,10 +112,12 @@ png_get_compression_type(png_const_structp png_ptr, png_const_infop info_ptr)
}
png_uint_32 PNGAPI
-png_get_x_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
+ info_ptr)
{
#ifdef PNG_pHYs_SUPPORTED
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_pHYs) != 0)
{
png_debug1(1, "in %s retrieval function",
"png_get_x_pixels_per_meter");
@@ -123,16 +125,21 @@ png_get_x_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
return (info_ptr->x_pixels_per_unit);
}
+#else
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(info_ptr)
#endif
return (0);
}
png_uint_32 PNGAPI
-png_get_y_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
+ info_ptr)
{
#ifdef PNG_pHYs_SUPPORTED
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_pHYs) != 0)
{
png_debug1(1, "in %s retrieval function",
"png_get_y_pixels_per_meter");
@@ -140,16 +147,20 @@ png_get_y_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
return (info_ptr->y_pixels_per_unit);
}
+#else
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(info_ptr)
#endif
return (0);
}
png_uint_32 PNGAPI
-png_get_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_pHYs_SUPPORTED
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_pHYs) != 0)
{
png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
@@ -157,6 +168,9 @@ png_get_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit)
return (info_ptr->x_pixels_per_unit);
}
+#else
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(info_ptr)
#endif
return (0);
@@ -164,10 +178,12 @@ png_get_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
#ifdef PNG_FLOATING_POINT_SUPPORTED
float PNGAPI
-png_get_pixel_aspect_ratio(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp
+ info_ptr)
{
#ifdef PNG_READ_pHYs_SUPPORTED
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_pHYs) != 0)
{
png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
@@ -175,6 +191,9 @@ png_get_pixel_aspect_ratio(png_const_structp png_ptr, png_const_infop info_ptr)
return ((float)((float)info_ptr->y_pixels_per_unit
/(float)info_ptr->x_pixels_per_unit));
}
+#else
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(info_ptr)
#endif
return ((float)0.0);
@@ -183,14 +202,15 @@ png_get_pixel_aspect_ratio(png_const_structp png_ptr, png_const_infop info_ptr)
#ifdef PNG_FIXED_POINT_SUPPORTED
png_fixed_point PNGAPI
-png_get_pixel_aspect_ratio_fixed(png_const_structp png_ptr,
- png_const_infop info_ptr)
+png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
+ png_const_inforp info_ptr)
{
#ifdef PNG_READ_pHYs_SUPPORTED
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)
- && info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0
- && info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX
- && info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_pHYs) != 0 &&
+ info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 &&
+ info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX &&
+ info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX)
{
png_fixed_point res;
@@ -200,9 +220,12 @@ png_get_pixel_aspect_ratio_fixed(png_const_structp png_ptr,
* range of 0..2^31-1; otherwise the cast might overflow.
*/
if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1,
- (png_int_32)info_ptr->x_pixels_per_unit))
+ (png_int_32)info_ptr->x_pixels_per_unit) != 0)
return res;
}
+#else
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(info_ptr)
#endif
return 0;
@@ -210,64 +233,80 @@ png_get_pixel_aspect_ratio_fixed(png_const_structp png_ptr,
#endif
png_int_32 PNGAPI
-png_get_x_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_oFFs) != 0)
{
png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
return (info_ptr->x_offset);
}
+#else
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(info_ptr)
#endif
return (0);
}
png_int_32 PNGAPI
-png_get_y_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_oFFs) != 0)
{
png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
return (info_ptr->y_offset);
}
+#else
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(info_ptr)
#endif
return (0);
}
png_int_32 PNGAPI
-png_get_x_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_oFFs) != 0)
{
png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels");
if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
return (info_ptr->x_offset);
}
+#else
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(info_ptr)
#endif
return (0);
}
png_int_32 PNGAPI
-png_get_y_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_oFFs) != 0)
{
png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels");
if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
return (info_ptr->y_offset);
}
+#else
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(info_ptr)
#endif
return (0);
@@ -298,7 +337,7 @@ ppi_from_ppm(png_uint_32 ppm)
*/
png_fixed_point result;
if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127,
- 5000))
+ 5000) != 0)
return result;
/* Overflow. */
@@ -307,26 +346,26 @@ ppi_from_ppm(png_uint_32 ppm)
}
png_uint_32 PNGAPI
-png_get_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr));
}
png_uint_32 PNGAPI
-png_get_x_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_x_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr));
}
png_uint_32 PNGAPI
-png_get_y_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_y_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr));
}
#ifdef PNG_FIXED_POINT_SUPPORTED
static png_fixed_point
-png_fixed_inches_from_microns(png_structp png_ptr, png_int_32 microns)
+png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns)
{
/* Convert from metres * 1,000,000 to inches * 100,000, meters to
* inches is simply *(100/2.54), so we want *(10/2.54) == 500/127.
@@ -337,8 +376,8 @@ png_fixed_inches_from_microns(png_structp png_ptr, png_int_32 microns)
}
png_fixed_point PNGAPI
-png_get_x_offset_inches_fixed(png_structp png_ptr,
- png_const_infop info_ptr)
+png_get_x_offset_inches_fixed(png_const_structrp png_ptr,
+ png_const_inforp info_ptr)
{
return png_fixed_inches_from_microns(png_ptr,
png_get_x_offset_microns(png_ptr, info_ptr));
@@ -347,8 +386,8 @@ png_get_x_offset_inches_fixed(png_structp png_ptr,
#ifdef PNG_FIXED_POINT_SUPPORTED
png_fixed_point PNGAPI
-png_get_y_offset_inches_fixed(png_structp png_ptr,
- png_const_infop info_ptr)
+png_get_y_offset_inches_fixed(png_const_structrp png_ptr,
+ png_const_inforp info_ptr)
{
return png_fixed_inches_from_microns(png_ptr,
png_get_y_offset_microns(png_ptr, info_ptr));
@@ -357,7 +396,7 @@ png_get_y_offset_inches_fixed(png_structp png_ptr,
#ifdef PNG_FLOATING_POINT_SUPPORTED
float PNGAPI
-png_get_x_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_x_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
/* To avoid the overflow do the conversion directly in floating
* point.
@@ -368,7 +407,7 @@ png_get_x_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
#ifdef PNG_FLOATING_POINT_SUPPORTED
float PNGAPI
-png_get_y_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_y_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
/* To avoid the overflow do the conversion directly in floating
* point.
@@ -379,12 +418,13 @@ png_get_y_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
#ifdef PNG_pHYs_SUPPORTED
png_uint_32 PNGAPI
-png_get_pHYs_dpi(png_const_structp png_ptr, png_const_infop info_ptr,
+png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
{
png_uint_32 retval = 0;
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_pHYs) != 0)
{
png_debug1(1, "in %s retrieval function", "pHYs");
@@ -415,15 +455,16 @@ png_get_pHYs_dpi(png_const_structp png_ptr, png_const_infop info_ptr,
return (retval);
}
-#endif /* PNG_pHYs_SUPPORTED */
-#endif /* PNG_INCH_CONVERSIONS_SUPPORTED */
+#endif /* pHYs */
+#endif /* INCH_CONVERSIONS */
/* png_get_channels really belongs in here, too, but it's been around longer */
-#endif /* PNG_EASY_ACCESS_SUPPORTED */
+#endif /* EASY_ACCESS */
+
png_byte PNGAPI
-png_get_channels(png_const_structp png_ptr, png_const_infop info_ptr)
+png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->channels);
@@ -431,22 +472,25 @@ png_get_channels(png_const_structp png_ptr, png_const_infop info_ptr)
return (0);
}
+#ifdef PNG_READ_SUPPORTED
png_const_bytep PNGAPI
-png_get_signature(png_const_structp png_ptr, png_infop info_ptr)
+png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->signature);
return (NULL);
}
+#endif
#ifdef PNG_bKGD_SUPPORTED
png_uint_32 PNGAPI
-png_get_bKGD(png_const_structp png_ptr, png_infop info_ptr,
+png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
png_color_16p *background)
{
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
- && background != NULL)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_bKGD) != 0 &&
+ background != NULL)
{
png_debug1(1, "in %s retrieval function", "bKGD");
@@ -463,87 +507,47 @@ png_get_bKGD(png_const_structp png_ptr, png_infop info_ptr,
* same time to correct the rgb grayscale coefficient defaults obtained from the
* cHRM chunk in 1.5.4
*/
-png_uint_32 PNGFAPI
-png_get_cHRM_XYZ_fixed(png_structp png_ptr, png_const_infop info_ptr,
- png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
- png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
- png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
- png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
- png_fixed_point *int_blue_Z)
-{
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
- {
- png_xy xy;
- png_XYZ XYZ;
-
- png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
-
- xy.whitex = info_ptr->x_white;
- xy.whitey = info_ptr->y_white;
- xy.redx = info_ptr->x_red;
- xy.redy = info_ptr->y_red;
- xy.greenx = info_ptr->x_green;
- xy.greeny = info_ptr->y_green;
- xy.bluex = info_ptr->x_blue;
- xy.bluey = info_ptr->y_blue;
-
- /* The *_checked function handles error reporting, so just return 0 if
- * there is a failure here.
- */
- if (png_XYZ_from_xy_checked(png_ptr, &XYZ, xy))
- {
- if (int_red_X != NULL)
- *int_red_X = XYZ.redX;
- if (int_red_Y != NULL)
- *int_red_Y = XYZ.redY;
- if (int_red_Z != NULL)
- *int_red_Z = XYZ.redZ;
- if (int_green_X != NULL)
- *int_green_X = XYZ.greenX;
- if (int_green_Y != NULL)
- *int_green_Y = XYZ.greenY;
- if (int_green_Z != NULL)
- *int_green_Z = XYZ.greenZ;
- if (int_blue_X != NULL)
- *int_blue_X = XYZ.blueX;
- if (int_blue_Y != NULL)
- *int_blue_Y = XYZ.blueY;
- if (int_blue_Z != NULL)
- *int_blue_Z = XYZ.blueZ;
-
- return (PNG_INFO_cHRM);
- }
- }
-
- return (0);
-}
-
# ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI
-png_get_cHRM(png_const_structp png_ptr, png_const_infop info_ptr,
+png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
double *white_x, double *white_y, double *red_x, double *red_y,
double *green_x, double *green_y, double *blue_x, double *blue_y)
{
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
+ /* Quiet API change: this code used to only return the end points if a cHRM
+ * chunk was present, but the end points can also come from iCCP or sRGB
+ * chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and
+ * the png_set_ APIs merely check that set end points are mutually
+ * consistent.
+ */
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{
png_debug1(1, "in %s retrieval function", "cHRM");
if (white_x != NULL)
- *white_x = png_float(png_ptr, info_ptr->x_white, "cHRM white X");
+ *white_x = png_float(png_ptr,
+ info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
if (white_y != NULL)
- *white_y = png_float(png_ptr, info_ptr->y_white, "cHRM white Y");
+ *white_y = png_float(png_ptr,
+ info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y");
if (red_x != NULL)
- *red_x = png_float(png_ptr, info_ptr->x_red, "cHRM red X");
+ *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx,
+ "cHRM red X");
if (red_y != NULL)
- *red_y = png_float(png_ptr, info_ptr->y_red, "cHRM red Y");
+ *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy,
+ "cHRM red Y");
if (green_x != NULL)
- *green_x = png_float(png_ptr, info_ptr->x_green, "cHRM green X");
+ *green_x = png_float(png_ptr,
+ info_ptr->colorspace.end_points_xy.greenx, "cHRM green X");
if (green_y != NULL)
- *green_y = png_float(png_ptr, info_ptr->y_green, "cHRM green Y");
+ *green_y = png_float(png_ptr,
+ info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y");
if (blue_x != NULL)
- *blue_x = png_float(png_ptr, info_ptr->x_blue, "cHRM blue X");
+ *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex,
+ "cHRM blue X");
if (blue_y != NULL)
- *blue_y = png_float(png_ptr, info_ptr->y_blue, "cHRM blue Y");
+ *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,
+ "cHRM blue Y");
return (PNG_INFO_cHRM);
}
@@ -551,35 +555,43 @@ png_get_cHRM(png_const_structp png_ptr, png_const_infop info_ptr,
}
png_uint_32 PNGAPI
-png_get_cHRM_XYZ(png_structp png_ptr, png_const_infop info_ptr,
+png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
double *red_X, double *red_Y, double *red_Z, double *green_X,
double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
double *blue_Z)
{
- png_XYZ XYZ;
-
- if (png_get_cHRM_XYZ_fixed(png_ptr, info_ptr,
- &XYZ.redX, &XYZ.redY, &XYZ.redZ, &XYZ.greenX, &XYZ.greenY, &XYZ.greenZ,
- &XYZ.blueX, &XYZ.blueY, &XYZ.blueZ) & PNG_INFO_cHRM)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{
+ png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
+
if (red_X != NULL)
- *red_X = png_float(png_ptr, XYZ.redX, "cHRM red X");
+ *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X,
+ "cHRM red X");
if (red_Y != NULL)
- *red_Y = png_float(png_ptr, XYZ.redY, "cHRM red Y");
+ *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y,
+ "cHRM red Y");
if (red_Z != NULL)
- *red_Z = png_float(png_ptr, XYZ.redZ, "cHRM red Z");
+ *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z,
+ "cHRM red Z");
if (green_X != NULL)
- *green_X = png_float(png_ptr, XYZ.greenX, "cHRM green X");
+ *green_X = png_float(png_ptr,
+ info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X");
if (green_Y != NULL)
- *green_Y = png_float(png_ptr, XYZ.greenY, "cHRM green Y");
+ *green_Y = png_float(png_ptr,
+ info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y");
if (green_Z != NULL)
- *green_Z = png_float(png_ptr, XYZ.greenZ, "cHRM green Z");
+ *green_Z = png_float(png_ptr,
+ info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z");
if (blue_X != NULL)
- *blue_X = png_float(png_ptr, XYZ.blueX, "cHRM blue X");
+ *blue_X = png_float(png_ptr,
+ info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X");
if (blue_Y != NULL)
- *blue_Y = png_float(png_ptr, XYZ.blueY, "cHRM blue Y");
+ *blue_Y = png_float(png_ptr,
+ info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y");
if (blue_Z != NULL)
- *blue_Z = png_float(png_ptr, XYZ.blueZ, "cHRM blue Z");
+ *blue_Z = png_float(png_ptr,
+ info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
return (PNG_INFO_cHRM);
}
@@ -589,31 +601,69 @@ png_get_cHRM_XYZ(png_structp png_ptr, png_const_infop info_ptr,
# ifdef PNG_FIXED_POINT_SUPPORTED
png_uint_32 PNGAPI
-png_get_cHRM_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
+png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
+ png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
+ png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
+ png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
+ png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
+ png_fixed_point *int_blue_Z)
+{
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
+ {
+ png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
+
+ if (int_red_X != NULL)
+ *int_red_X = info_ptr->colorspace.end_points_XYZ.red_X;
+ if (int_red_Y != NULL)
+ *int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y;
+ if (int_red_Z != NULL)
+ *int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z;
+ if (int_green_X != NULL)
+ *int_green_X = info_ptr->colorspace.end_points_XYZ.green_X;
+ if (int_green_Y != NULL)
+ *int_green_Y = info_ptr->colorspace.end_points_XYZ.green_Y;
+ if (int_green_Z != NULL)
+ *int_green_Z = info_ptr->colorspace.end_points_XYZ.green_Z;
+ if (int_blue_X != NULL)
+ *int_blue_X = info_ptr->colorspace.end_points_XYZ.blue_X;
+ if (int_blue_Y != NULL)
+ *int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y;
+ if (int_blue_Z != NULL)
+ *int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z;
+ return (PNG_INFO_cHRM);
+ }
+
+ return (0);
+}
+
+png_uint_32 PNGAPI
+png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
png_fixed_point *blue_x, png_fixed_point *blue_y)
{
png_debug1(1, "in %s retrieval function", "cHRM");
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{
if (white_x != NULL)
- *white_x = info_ptr->x_white;
+ *white_x = info_ptr->colorspace.end_points_xy.whitex;
if (white_y != NULL)
- *white_y = info_ptr->y_white;
+ *white_y = info_ptr->colorspace.end_points_xy.whitey;
if (red_x != NULL)
- *red_x = info_ptr->x_red;
+ *red_x = info_ptr->colorspace.end_points_xy.redx;
if (red_y != NULL)
- *red_y = info_ptr->y_red;
+ *red_y = info_ptr->colorspace.end_points_xy.redy;
if (green_x != NULL)
- *green_x = info_ptr->x_green;
+ *green_x = info_ptr->colorspace.end_points_xy.greenx;
if (green_y != NULL)
- *green_y = info_ptr->y_green;
+ *green_y = info_ptr->colorspace.end_points_xy.greeny;
if (blue_x != NULL)
- *blue_x = info_ptr->x_blue;
+ *blue_x = info_ptr->colorspace.end_points_xy.bluex;
if (blue_y != NULL)
- *blue_y = info_ptr->y_blue;
+ *blue_y = info_ptr->colorspace.end_points_xy.bluey;
return (PNG_INFO_cHRM);
}
@@ -623,49 +673,57 @@ png_get_cHRM_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
#endif
#ifdef PNG_gAMA_SUPPORTED
-png_uint_32 PNGFAPI
-png_get_gAMA_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
+# ifdef PNG_FIXED_POINT_SUPPORTED
+png_uint_32 PNGAPI
+png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
png_fixed_point *file_gamma)
{
png_debug1(1, "in %s retrieval function", "gAMA");
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
- && file_gamma != NULL)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
+ file_gamma != NULL)
{
- *file_gamma = info_ptr->gamma;
+ *file_gamma = info_ptr->colorspace.gamma;
return (PNG_INFO_gAMA);
}
return (0);
}
+# endif
+
# ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI
-png_get_gAMA(png_const_structp png_ptr, png_const_infop info_ptr,
+png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
double *file_gamma)
{
- png_fixed_point igamma;
- png_uint_32 ok = png_get_gAMA_fixed(png_ptr, info_ptr, &igamma);
+ png_debug1(1, "in %s retrieval function", "gAMA(float)");
- if (ok)
- *file_gamma = png_float(png_ptr, igamma, "png_get_gAMA");
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
+ file_gamma != NULL)
+ {
+ *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
+ "png_get_gAMA");
+ return (PNG_INFO_gAMA);
+ }
- return ok;
+ return (0);
}
-
# endif
#endif
#ifdef PNG_sRGB_SUPPORTED
png_uint_32 PNGAPI
-png_get_sRGB(png_const_structp png_ptr, png_const_infop info_ptr,
+png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
int *file_srgb_intent)
{
png_debug1(1, "in %s retrieval function", "sRGB");
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
- && file_srgb_intent != NULL)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_sRGB) != 0 && file_srgb_intent != NULL)
{
- *file_srgb_intent = (int)info_ptr->srgb_intent;
+ *file_srgb_intent = info_ptr->colorspace.rendering_intent;
return (PNG_INFO_sRGB);
}
@@ -675,23 +733,24 @@ png_get_sRGB(png_const_structp png_ptr, png_const_infop info_ptr,
#ifdef PNG_iCCP_SUPPORTED
png_uint_32 PNGAPI
-png_get_iCCP(png_const_structp png_ptr, png_const_infop info_ptr,
+png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
png_charpp name, int *compression_type,
png_bytepp profile, png_uint_32 *proflen)
{
png_debug1(1, "in %s retrieval function", "iCCP");
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
- && name != NULL && compression_type != NULL && profile != NULL &&
- proflen != NULL)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_iCCP) != 0 &&
+ name != NULL && compression_type != NULL && profile != NULL &&
+ proflen != NULL)
{
*name = info_ptr->iccp_name;
*profile = info_ptr->iccp_profile;
- /* Compression_type is a dummy so the API won't have to change
- * if we introduce multiple compression types later.
+ *proflen = png_get_uint_32(info_ptr->iccp_profile);
+ /* This is somewhat irrelevant since the profile data returned has
+ * actually been uncompressed.
*/
- *proflen = info_ptr->iccp_proflen;
- *compression_type = info_ptr->iccp_compression;
+ *compression_type = PNG_COMPRESSION_TYPE_BASE;
return (PNG_INFO_iCCP);
}
@@ -700,14 +759,14 @@ png_get_iCCP(png_const_structp png_ptr, png_const_infop info_ptr,
#endif
#ifdef PNG_sPLT_SUPPORTED
-png_uint_32 PNGAPI
-png_get_sPLT(png_const_structp png_ptr, png_const_infop info_ptr,
+int PNGAPI
+png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,
png_sPLT_tpp spalettes)
{
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
{
*spalettes = info_ptr->splt_palettes;
- return ((png_uint_32)info_ptr->splt_palettes_num);
+ return info_ptr->splt_palettes_num;
}
return (0);
@@ -716,13 +775,13 @@ png_get_sPLT(png_const_structp png_ptr, png_const_infop info_ptr,
#ifdef PNG_hIST_SUPPORTED
png_uint_32 PNGAPI
-png_get_hIST(png_const_structp png_ptr, png_const_infop info_ptr,
+png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
png_uint_16p *hist)
{
png_debug1(1, "in %s retrieval function", "hIST");
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
- && hist != NULL)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_hIST) != 0 && hist != NULL)
{
*hist = info_ptr->hist;
return (PNG_INFO_hIST);
@@ -733,22 +792,27 @@ png_get_hIST(png_const_structp png_ptr, png_const_infop info_ptr,
#endif
png_uint_32 PNGAPI
-png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
+png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
png_uint_32 *width, png_uint_32 *height, int *bit_depth,
int *color_type, int *interlace_type, int *compression_type,
int *filter_type)
-
{
png_debug1(1, "in %s retrieval function", "IHDR");
- if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
- height == NULL || bit_depth == NULL || color_type == NULL)
+ if (png_ptr == NULL || info_ptr == NULL)
return (0);
- *width = info_ptr->width;
- *height = info_ptr->height;
- *bit_depth = info_ptr->bit_depth;
- *color_type = info_ptr->color_type;
+ if (width != NULL)
+ *width = info_ptr->width;
+
+ if (height != NULL)
+ *height = info_ptr->height;
+
+ if (bit_depth != NULL)
+ *bit_depth = info_ptr->bit_depth;
+
+ if (color_type != NULL)
+ *color_type = info_ptr->color_type;
if (compression_type != NULL)
*compression_type = info_ptr->compression_type;
@@ -764,7 +828,7 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
* application has ignored our advice not to mess with the members
* of info_ptr directly.
*/
- png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height,
+ png_check_IHDR(png_ptr, info_ptr->width, info_ptr->height,
info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
info_ptr->compression_type, info_ptr->filter_type);
@@ -773,13 +837,14 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_oFFs_SUPPORTED
png_uint_32 PNGAPI
-png_get_oFFs(png_const_structp png_ptr, png_const_infop info_ptr,
+png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr,
png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
{
png_debug1(1, "in %s retrieval function", "oFFs");
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
- && offset_x != NULL && offset_y != NULL && unit_type != NULL)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_oFFs) != 0 &&
+ offset_x != NULL && offset_y != NULL && unit_type != NULL)
{
*offset_x = info_ptr->x_offset;
*offset_y = info_ptr->y_offset;
@@ -793,14 +858,15 @@ png_get_oFFs(png_const_structp png_ptr, png_const_infop info_ptr,
#ifdef PNG_pCAL_SUPPORTED
png_uint_32 PNGAPI
-png_get_pCAL(png_const_structp png_ptr, png_const_infop info_ptr,
+png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
png_charp *units, png_charpp *params)
{
png_debug1(1, "in %s retrieval function", "pCAL");
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
- && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_pCAL) != 0 &&
+ purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
nparams != NULL && units != NULL && params != NULL)
{
*purpose = info_ptr->pcal_purpose;
@@ -819,16 +885,20 @@ png_get_pCAL(png_const_structp png_ptr, png_const_infop info_ptr,
#ifdef PNG_sCAL_SUPPORTED
# ifdef PNG_FIXED_POINT_SUPPORTED
-# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
+# if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
+ defined(PNG_FLOATING_POINT_SUPPORTED)
png_uint_32 PNGAPI
-png_get_sCAL_fixed(png_structp png_ptr, png_const_infop info_ptr,
+png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
int *unit, png_fixed_point *width, png_fixed_point *height)
{
if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_sCAL))
+ (info_ptr->valid & PNG_INFO_sCAL) != 0)
{
*unit = info_ptr->scal_unit;
- /*TODO: make this work without FP support */
+ /*TODO: make this work without FP support; the API is currently eliminated
+ * if neither floating point APIs nor internal floating point arithmetic
+ * are enabled.
+ */
*width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width");
*height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
"sCAL height");
@@ -841,11 +911,11 @@ png_get_sCAL_fixed(png_structp png_ptr, png_const_infop info_ptr,
# endif /* FIXED_POINT */
# ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI
-png_get_sCAL(png_const_structp png_ptr, png_const_infop info_ptr,
+png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
int *unit, double *width, double *height)
{
if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_sCAL))
+ (info_ptr->valid & PNG_INFO_sCAL) != 0)
{
*unit = info_ptr->scal_unit;
*width = atof(info_ptr->scal_s_width);
@@ -857,11 +927,11 @@ png_get_sCAL(png_const_structp png_ptr, png_const_infop info_ptr,
}
# endif /* FLOATING POINT */
png_uint_32 PNGAPI
-png_get_sCAL_s(png_const_structp png_ptr, png_const_infop info_ptr,
+png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr,
int *unit, png_charpp width, png_charpp height)
{
if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_sCAL))
+ (info_ptr->valid & PNG_INFO_sCAL) != 0)
{
*unit = info_ptr->scal_unit;
*width = info_ptr->scal_s_width;
@@ -875,7 +945,7 @@ png_get_sCAL_s(png_const_structp png_ptr, png_const_infop info_ptr,
#ifdef PNG_pHYs_SUPPORTED
png_uint_32 PNGAPI
-png_get_pHYs(png_const_structp png_ptr, png_const_infop info_ptr,
+png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr,
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
{
png_uint_32 retval = 0;
@@ -883,7 +953,7 @@ png_get_pHYs(png_const_structp png_ptr, png_const_infop info_ptr,
png_debug1(1, "in %s retrieval function", "pHYs");
if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_pHYs))
+ (info_ptr->valid & PNG_INFO_pHYs) != 0)
{
if (res_x != NULL)
{
@@ -909,13 +979,13 @@ png_get_pHYs(png_const_structp png_ptr, png_const_infop info_ptr,
#endif /* pHYs */
png_uint_32 PNGAPI
-png_get_PLTE(png_const_structp png_ptr, png_const_infop info_ptr,
+png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr,
png_colorp *palette, int *num_palette)
{
png_debug1(1, "in %s retrieval function", "PLTE");
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
- && palette != NULL)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_PLTE) != 0 && palette != NULL)
{
*palette = info_ptr->palette;
*num_palette = info_ptr->num_palette;
@@ -928,13 +998,13 @@ png_get_PLTE(png_const_structp png_ptr, png_const_infop info_ptr,
#ifdef PNG_sBIT_SUPPORTED
png_uint_32 PNGAPI
-png_get_sBIT(png_const_structp png_ptr, png_infop info_ptr,
+png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,
png_color_8p *sig_bit)
{
png_debug1(1, "in %s retrieval function", "sBIT");
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
- && sig_bit != NULL)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_sBIT) != 0 && sig_bit != NULL)
{
*sig_bit = &(info_ptr->sig_bit);
return (PNG_INFO_sBIT);
@@ -945,8 +1015,8 @@ png_get_sBIT(png_const_structp png_ptr, png_infop info_ptr,
#endif
#ifdef PNG_TEXT_SUPPORTED
-png_uint_32 PNGAPI
-png_get_text(png_const_structp png_ptr, png_const_infop info_ptr,
+int PNGAPI
+png_get_text(png_const_structrp png_ptr, png_inforp info_ptr,
png_textp *text_ptr, int *num_text)
{
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
@@ -960,7 +1030,7 @@ png_get_text(png_const_structp png_ptr, png_const_infop info_ptr,
if (num_text != NULL)
*num_text = info_ptr->num_text;
- return ((png_uint_32)info_ptr->num_text);
+ return info_ptr->num_text;
}
if (num_text != NULL)
@@ -972,12 +1042,13 @@ png_get_text(png_const_structp png_ptr, png_const_infop info_ptr,
#ifdef PNG_tIME_SUPPORTED
png_uint_32 PNGAPI
-png_get_tIME(png_const_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
+png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
+ png_timep *mod_time)
{
png_debug1(1, "in %s retrieval function", "tIME");
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
- && mod_time != NULL)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_tIME) != 0 && mod_time != NULL)
{
*mod_time = &(info_ptr->mod_time);
return (PNG_INFO_tIME);
@@ -989,11 +1060,12 @@ png_get_tIME(png_const_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
#ifdef PNG_tRNS_SUPPORTED
png_uint_32 PNGAPI
-png_get_tRNS(png_const_structp png_ptr, png_infop info_ptr,
+png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
{
png_uint_32 retval = 0;
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_tRNS) != 0)
{
png_debug1(1, "in %s retrieval function", "tRNS");
@@ -1032,9 +1104,9 @@ png_get_tRNS(png_const_structp png_ptr, png_infop info_ptr,
}
#endif
-#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
+#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
int PNGAPI
-png_get_unknown_chunks(png_const_structp png_ptr, png_const_infop info_ptr,
+png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr,
png_unknown_chunkpp unknowns)
{
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
@@ -1049,7 +1121,7 @@ png_get_unknown_chunks(png_const_structp png_ptr, png_const_infop info_ptr,
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
png_byte PNGAPI
-png_get_rgb_to_gray_status (png_const_structp png_ptr)
+png_get_rgb_to_gray_status (png_const_structrp png_ptr)
{
return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
}
@@ -1057,68 +1129,91 @@ png_get_rgb_to_gray_status (png_const_structp png_ptr)
#ifdef PNG_USER_CHUNKS_SUPPORTED
png_voidp PNGAPI
-png_get_user_chunk_ptr(png_const_structp png_ptr)
+png_get_user_chunk_ptr(png_const_structrp png_ptr)
{
return (png_ptr ? png_ptr->user_chunk_ptr : NULL);
}
#endif
png_size_t PNGAPI
-png_get_compression_buffer_size(png_const_structp png_ptr)
+png_get_compression_buffer_size(png_const_structrp png_ptr)
{
- return (png_ptr ? png_ptr->zbuf_size : 0);
+ if (png_ptr == NULL)
+ return 0;
+
+#ifdef PNG_WRITE_SUPPORTED
+ if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
+#endif
+ {
+#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
+ return png_ptr->IDAT_read_size;
+#else
+ return PNG_IDAT_READ_SIZE;
+#endif
+ }
+
+#ifdef PNG_WRITE_SUPPORTED
+ else
+ return png_ptr->zbuffer_size;
+#endif
}
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
/* These functions were added to libpng 1.2.6 and were enabled
* by default in libpng-1.4.0 */
png_uint_32 PNGAPI
-png_get_user_width_max (png_const_structp png_ptr)
+png_get_user_width_max (png_const_structrp png_ptr)
{
return (png_ptr ? png_ptr->user_width_max : 0);
}
png_uint_32 PNGAPI
-png_get_user_height_max (png_const_structp png_ptr)
+png_get_user_height_max (png_const_structrp png_ptr)
{
return (png_ptr ? png_ptr->user_height_max : 0);
}
/* This function was added to libpng 1.4.0 */
png_uint_32 PNGAPI
-png_get_chunk_cache_max (png_const_structp png_ptr)
+png_get_chunk_cache_max (png_const_structrp png_ptr)
{
return (png_ptr ? png_ptr->user_chunk_cache_max : 0);
}
/* This function was added to libpng 1.4.1 */
png_alloc_size_t PNGAPI
-png_get_chunk_malloc_max (png_const_structp png_ptr)
+png_get_chunk_malloc_max (png_const_structrp png_ptr)
{
return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
}
-#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
+#endif /* SET_USER_LIMITS */
/* These functions were added to libpng 1.4.0 */
#ifdef PNG_IO_STATE_SUPPORTED
png_uint_32 PNGAPI
-png_get_io_state (png_structp png_ptr)
+png_get_io_state (png_const_structrp png_ptr)
{
return png_ptr->io_state;
}
png_uint_32 PNGAPI
-png_get_io_chunk_type (png_const_structp png_ptr)
+png_get_io_chunk_type (png_const_structrp png_ptr)
{
return png_ptr->chunk_name;
}
+#endif /* IO_STATE */
-png_const_bytep PNGAPI
-png_get_io_chunk_name (png_structp png_ptr)
+#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
+# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
+int PNGAPI
+png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr)
{
- PNG_CSTRING_FROM_CHUNK(png_ptr->io_chunk_string, png_ptr->chunk_name);
- return png_ptr->io_chunk_string;
+ if (png_ptr != NULL && info_ptr != NULL)
+ return png_ptr->num_palette_max;
+
+ return (-1);
}
-#endif /* ?PNG_IO_STATE_SUPPORTED */
+# endif
+#endif
-#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
+#endif /* READ || WRITE */