/* pngget.c - retrieval of values from info struct
*
- * libpng 1.2.4 - July 8, 2002
+ * libpng 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 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.)
*/
if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
bit_depth != NULL && color_type != NULL)
{
- int pixel_depth, channels;
- png_uint_32 rowbytes_per_pixel;
-
png_debug1(1, "in %s retrieval function\n", "IHDR");
*width = info_ptr->width;
*height = info_ptr->height;
*interlace_type = info_ptr->interlace_type;
/* check for potential overflow of rowbytes */
- if (*color_type == PNG_COLOR_TYPE_PALETTE)
- channels = 1;
- else if (*color_type & PNG_COLOR_MASK_COLOR)
- channels = 3;
- else
- channels = 1;
- if (*color_type & PNG_COLOR_MASK_ALPHA)
- channels++;
- pixel_depth = *bit_depth * channels;
- rowbytes_per_pixel = (pixel_depth + 7) >> 3;
- if (width == 0 || *width > PNG_MAX_UINT)
+ if (width == 0 || *width > PNG_UINT_31_MAX)
png_error(png_ptr, "Invalid image width");
- if (height == 0 || *height > PNG_MAX_UINT)
+ if (height == 0 || *height > PNG_UINT_31_MAX)
png_error(png_ptr, "Invalid image height");
- if (*width > PNG_MAX_UINT/rowbytes_per_pixel - 64)
+ if (info_ptr->width > (PNG_UINT_32_MAX
+ >> 3) /* 8-byte RGBA pixels */
+ - 64 /* bigrowbuf hack */
+ - 1 /* filter byte */
+ - 7*8 /* rounding of width to multiple of 8 pixels */
+ - 8) /* extra max_pixel_depth pad */
{
- png_error(png_ptr,
+ png_warning(png_ptr,
"Width too large for libpng to process image data.");
}
return (1);
}
#endif
-
+#ifdef PNG_WRITE_SUPPORTED
png_uint_32 PNGAPI
png_get_compression_buffer_size(png_structp png_ptr)
{
return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L);
}
-
+#endif
#ifndef PNG_1_0_X
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
{
return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L);
}
-#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
-#endif /* PNG_1_0_X */
+#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
+
+#ifdef PNG_SET_USER_LIMITS_SUPPORTED
+/* these functions were added to libpng 1.2.6 */
+png_uint_32 PNGAPI
+png_get_user_width_max (png_structp png_ptr)
+{
+ return (png_ptr? png_ptr->user_width_max : 0);
+}
+png_uint_32 PNGAPI
+png_get_user_height_max (png_structp png_ptr)
+{
+ return (png_ptr? png_ptr->user_height_max : 0);
+}
+#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
+
+#endif /* ?PNG_1_0_X */