1997-05-16 03:46:07 -04:00
|
|
|
|
|
|
|
/* pngget.c - retrieval of values from info struct
|
1998-01-01 08:13:13 -05:00
|
|
|
*
|
2010-08-26 08:07:37 -04:00
|
|
|
* Last changed in libpng 1.4.1 [August 26, 2010]
|
2010-01-01 11:29:06 -05:00
|
|
|
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
2000-06-04 15:29:29 -04:00
|
|
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
|
|
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
2009-06-24 10:31:28 -04:00
|
|
|
*
|
2009-06-26 22:46:52 -04:00
|
|
|
* This code is released under the libpng license.
|
2009-06-25 14:43:50 -04:00
|
|
|
* For conditions of distribution and use, see the disclaimer
|
2009-06-24 11:27:36 -04:00
|
|
|
* and license in png.h
|
2009-06-24 10:31:28 -04:00
|
|
|
*
|
1998-01-01 08:13:13 -05:00
|
|
|
*/
|
1997-05-16 03:46:07 -04:00
|
|
|
|
2008-07-10 10:13:13 -04:00
|
|
|
#include "pngpriv.h"
|
2006-02-20 23:09:05 -05:00
|
|
|
|
2010-03-08 22:10:25 -05:00
|
|
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
|
|
|
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1997-05-16 03:46:07 -04:00
|
|
|
png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
|
|
|
|
{
|
1998-02-08 21:56:40 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
1997-05-16 03:46:07 -04:00
|
|
|
return(info_ptr->valid & flag);
|
2009-05-15 21:39:34 -04:00
|
|
|
|
1997-05-16 03:46:07 -04:00
|
|
|
else
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2006-08-19 14:59:24 -04:00
|
|
|
png_size_t PNGAPI
|
1997-05-16 03:46:07 -04:00
|
|
|
png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
1998-02-08 21:56:40 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
1997-05-16 03:46:07 -04:00
|
|
|
return(info_ptr->rowbytes);
|
2009-05-15 21:39:34 -04:00
|
|
|
|
1997-05-16 03:46:07 -04:00
|
|
|
else
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_INFO_IMAGE_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_bytepp PNGAPI
|
2000-02-18 14:48:52 -05:00
|
|
|
png_get_rows(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return(info_ptr->row_pointers);
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2000-02-18 14:48:52 -05:00
|
|
|
else
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-01-30 22:45:12 -05:00
|
|
|
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
2009-05-15 21:39:34 -04:00
|
|
|
/* Easy access to info, added in libpng-0.99 */
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1998-01-30 22:45:12 -05:00
|
|
|
png_get_image_width(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
1998-02-08 21:56:40 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
1998-01-30 22:45:12 -05:00
|
|
|
return info_ptr->width;
|
2009-05-15 21:39:34 -04:00
|
|
|
|
1998-01-30 22:45:12 -05:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1998-01-30 22:45:12 -05:00
|
|
|
png_get_image_height(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
1998-02-08 21:56:40 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
1998-01-30 22:45:12 -05:00
|
|
|
return info_ptr->height;
|
2009-05-15 21:39:34 -04:00
|
|
|
|
1998-01-30 22:45:12 -05:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-05-06 15:09:57 -04:00
|
|
|
png_byte PNGAPI
|
1998-01-30 22:45:12 -05:00
|
|
|
png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
1998-02-08 21:56:40 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
1998-01-30 22:45:12 -05:00
|
|
|
return info_ptr->bit_depth;
|
2009-05-15 21:39:34 -04:00
|
|
|
|
1998-01-30 22:45:12 -05:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-05-06 15:09:57 -04:00
|
|
|
png_byte PNGAPI
|
1998-01-30 22:45:12 -05:00
|
|
|
png_get_color_type(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
1998-02-08 21:56:40 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
1998-01-30 22:45:12 -05:00
|
|
|
return info_ptr->color_type;
|
2009-05-15 21:39:34 -04:00
|
|
|
|
1998-01-30 22:45:12 -05:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-05-06 15:09:57 -04:00
|
|
|
png_byte PNGAPI
|
1998-01-30 22:45:12 -05:00
|
|
|
png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
1998-02-08 21:56:40 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
1998-01-30 22:45:12 -05:00
|
|
|
return info_ptr->filter_type;
|
2009-05-15 21:39:34 -04:00
|
|
|
|
1998-01-30 22:45:12 -05:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-05-06 15:09:57 -04:00
|
|
|
png_byte PNGAPI
|
1998-01-30 22:45:12 -05:00
|
|
|
png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
1998-02-08 21:56:40 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
1998-01-30 22:45:12 -05:00
|
|
|
return info_ptr->interlace_type;
|
2009-05-15 21:39:34 -04:00
|
|
|
|
1998-01-30 22:45:12 -05:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-05-06 15:09:57 -04:00
|
|
|
png_byte PNGAPI
|
1998-01-30 22:45:12 -05:00
|
|
|
png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
1998-02-08 21:56:40 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
1998-01-30 22:45:12 -05:00
|
|
|
return info_ptr->compression_type;
|
2009-05-15 21:39:34 -04:00
|
|
|
|
1998-01-30 22:45:12 -05:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1998-02-28 08:00:24 -05:00
|
|
|
png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2000-05-29 09:58:03 -04:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_pHYs_SUPPORTED
|
2000-05-29 09:58:03 -04:00
|
|
|
if (info_ptr->valid & PNG_INFO_pHYs)
|
1998-02-28 08:00:24 -05:00
|
|
|
{
|
2008-08-05 08:44:42 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter");
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2008-07-10 10:13:13 -04:00
|
|
|
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
2010-03-06 08:34:28 -05:00
|
|
|
return (0);
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2009-05-30 21:19:20 -04:00
|
|
|
else
|
2010-03-06 08:34:28 -05:00
|
|
|
return (info_ptr->x_pixels_per_unit);
|
1998-02-28 08:00:24 -05:00
|
|
|
}
|
2000-05-29 09:58:03 -04:00
|
|
|
#else
|
|
|
|
return (0);
|
1998-02-28 08:00:24 -05:00
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1998-02-28 08:00:24 -05:00
|
|
|
png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2000-05-29 09:58:03 -04:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_pHYs_SUPPORTED
|
2000-05-29 09:58:03 -04:00
|
|
|
if (info_ptr->valid & PNG_INFO_pHYs)
|
1998-02-28 08:00:24 -05:00
|
|
|
{
|
2008-08-05 08:44:42 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter");
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2008-07-10 10:13:13 -04:00
|
|
|
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
2010-03-06 08:34:28 -05:00
|
|
|
return (0);
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2009-05-30 21:19:20 -04:00
|
|
|
else
|
2010-03-06 08:34:28 -05:00
|
|
|
return (info_ptr->y_pixels_per_unit);
|
1998-02-28 08:00:24 -05:00
|
|
|
}
|
2000-05-29 09:58:03 -04:00
|
|
|
#else
|
|
|
|
return (0);
|
1998-02-28 08:00:24 -05:00
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1998-01-30 22:45:12 -05:00
|
|
|
png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2000-05-29 09:58:03 -04:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_pHYs_SUPPORTED
|
2000-05-29 09:58:03 -04:00
|
|
|
if (info_ptr->valid & PNG_INFO_pHYs)
|
1998-01-30 22:45:12 -05:00
|
|
|
{
|
2008-08-05 08:44:42 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2008-07-10 10:13:13 -04:00
|
|
|
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
|
2010-03-06 08:34:28 -05:00
|
|
|
info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
|
|
|
|
return (0);
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2009-05-30 21:19:20 -04:00
|
|
|
else
|
2010-03-06 08:34:28 -05:00
|
|
|
return (info_ptr->x_pixels_per_unit);
|
1998-01-30 22:45:12 -05:00
|
|
|
}
|
2000-05-29 09:58:03 -04:00
|
|
|
#else
|
|
|
|
return (0);
|
1998-01-30 22:45:12 -05:00
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1999-12-10 10:43:02 -05:00
|
|
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
float PNGAPI
|
1998-01-30 22:45:12 -05:00
|
|
|
png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
|
2010-03-06 08:34:28 -05:00
|
|
|
{
|
2000-05-29 09:58:03 -04:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
2010-07-31 07:34:36 -04:00
|
|
|
#ifdef PNG_READ_pHYs_SUPPORTED
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2000-05-29 09:58:03 -04:00
|
|
|
if (info_ptr->valid & PNG_INFO_pHYs)
|
1998-01-30 22:45:12 -05:00
|
|
|
{
|
2008-08-05 08:44:42 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
|
2009-08-15 14:25:47 -04:00
|
|
|
|
1998-01-30 22:45:12 -05:00
|
|
|
if (info_ptr->x_pixels_per_unit == 0)
|
1998-02-07 11:20:57 -05:00
|
|
|
return ((float)0.0);
|
2009-08-15 22:47:03 -04:00
|
|
|
|
1998-01-30 22:45:12 -05:00
|
|
|
else
|
2000-05-29 09:58:03 -04:00
|
|
|
return ((float)((float)info_ptr->y_pixels_per_unit
|
2010-03-06 08:34:28 -05:00
|
|
|
/(float)info_ptr->x_pixels_per_unit));
|
1998-01-30 22:45:12 -05:00
|
|
|
}
|
2000-05-29 09:58:03 -04:00
|
|
|
#else
|
2009-05-15 21:39:34 -04:00
|
|
|
return (0.0);
|
1998-01-30 22:45:12 -05:00
|
|
|
#endif
|
2000-05-29 09:58:03 -04:00
|
|
|
return ((float)0.0);
|
1998-01-30 22:45:12 -05:00
|
|
|
}
|
1999-12-10 10:43:02 -05:00
|
|
|
#endif
|
1998-01-30 22:45:12 -05:00
|
|
|
|
2010-07-31 07:34:36 -04:00
|
|
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
|
|
|
png_fixed_point PNGAPI
|
|
|
|
png_get_pixel_aspect_ratio_fixed(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
#ifdef PNG_READ_pHYs_SUPPORTED
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)
|
2010-08-19 17:52:01 -04:00
|
|
|
&& 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)
|
2010-07-31 07:34:36 -04:00
|
|
|
{
|
|
|
|
png_fixed_point res;
|
|
|
|
|
|
|
|
png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio_fixed");
|
|
|
|
|
2010-08-19 17:52:01 -04:00
|
|
|
/* The following casts work because a PNG 4 byte integer only has a valid
|
|
|
|
* 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))
|
2010-07-31 14:45:04 -04:00
|
|
|
return res;
|
2010-07-31 07:34:36 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-05-29 09:58:03 -04:00
|
|
|
png_int_32 PNGAPI
|
1998-01-30 22:45:12 -05:00
|
|
|
png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2000-05-29 09:58:03 -04:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_oFFs_SUPPORTED
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2000-05-29 09:58:03 -04:00
|
|
|
if (info_ptr->valid & PNG_INFO_oFFs)
|
1998-01-30 22:45:12 -05:00
|
|
|
{
|
2008-08-05 08:44:42 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2008-07-10 10:13:13 -04:00
|
|
|
if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
2010-03-06 08:34:28 -05:00
|
|
|
return (0);
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2009-05-30 21:19:20 -04:00
|
|
|
else
|
2010-03-06 08:34:28 -05:00
|
|
|
return (info_ptr->x_offset);
|
1998-01-30 22:45:12 -05:00
|
|
|
}
|
2000-05-29 09:58:03 -04:00
|
|
|
#else
|
2009-05-15 21:39:34 -04:00
|
|
|
return (0);
|
1998-01-30 22:45:12 -05:00
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-05-29 09:58:03 -04:00
|
|
|
png_int_32 PNGAPI
|
1998-01-30 22:45:12 -05:00
|
|
|
png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2000-05-29 09:58:03 -04:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_oFFs_SUPPORTED
|
2000-05-29 09:58:03 -04:00
|
|
|
if (info_ptr->valid & PNG_INFO_oFFs)
|
1998-01-30 22:45:12 -05:00
|
|
|
{
|
2008-08-05 08:44:42 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2008-07-10 10:13:13 -04:00
|
|
|
if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
2010-03-06 08:34:28 -05:00
|
|
|
return (0);
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2009-05-30 21:19:20 -04:00
|
|
|
else
|
2010-03-06 08:34:28 -05:00
|
|
|
return (info_ptr->y_offset);
|
1998-01-30 22:45:12 -05:00
|
|
|
}
|
2000-05-29 09:58:03 -04:00
|
|
|
#else
|
|
|
|
return (0);
|
1998-01-30 22:45:12 -05:00
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-05-29 09:58:03 -04:00
|
|
|
png_int_32 PNGAPI
|
1998-01-30 22:45:12 -05:00
|
|
|
png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2000-05-29 09:58:03 -04:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_oFFs_SUPPORTED
|
2000-05-29 09:58:03 -04:00
|
|
|
if (info_ptr->valid & PNG_INFO_oFFs)
|
1998-01-30 22:45:12 -05:00
|
|
|
{
|
2010-07-29 18:39:14 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels");
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2008-07-10 10:13:13 -04:00
|
|
|
if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
2010-03-06 08:34:28 -05:00
|
|
|
return (0);
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2009-05-30 21:19:20 -04:00
|
|
|
else
|
2010-03-06 08:34:28 -05:00
|
|
|
return (info_ptr->x_offset);
|
1998-01-30 22:45:12 -05:00
|
|
|
}
|
2000-05-29 09:58:03 -04:00
|
|
|
#else
|
|
|
|
return (0);
|
1998-01-30 22:45:12 -05:00
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-05-29 09:58:03 -04:00
|
|
|
png_int_32 PNGAPI
|
1998-01-30 22:45:12 -05:00
|
|
|
png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2000-05-29 09:58:03 -04:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_oFFs_SUPPORTED
|
2000-05-29 09:58:03 -04:00
|
|
|
if (info_ptr->valid & PNG_INFO_oFFs)
|
1998-01-30 22:45:12 -05:00
|
|
|
{
|
2010-07-29 18:39:14 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels");
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2008-07-10 10:13:13 -04:00
|
|
|
if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
2010-03-06 08:34:28 -05:00
|
|
|
return (0);
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2009-05-30 21:19:20 -04:00
|
|
|
else
|
2010-03-06 08:34:28 -05:00
|
|
|
return (info_ptr->y_offset);
|
1998-01-30 22:45:12 -05:00
|
|
|
}
|
2000-05-29 09:58:03 -04:00
|
|
|
#else
|
|
|
|
return (0);
|
1998-01-30 22:45:12 -05:00
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2010-07-29 18:39:14 -04:00
|
|
|
#ifdef PNG_INCH_CONVERSIONS_SUPPORTED
|
|
|
|
static png_uint_32
|
|
|
|
ppi_from_ppm(png_uint_32 ppm)
|
|
|
|
{
|
|
|
|
#if 0
|
2010-07-29 22:49:38 -04:00
|
|
|
/* The conversion is *(2.54/100), in binary (32 digits):
|
2010-07-29 18:39:14 -04:00
|
|
|
* .00000110100000001001110101001001
|
|
|
|
*/
|
|
|
|
png_uint_32 t1001, t1101;
|
|
|
|
ppm >>= 1; /* .1 */
|
|
|
|
t1001 = ppm + (ppm >> 3); /* .1001 */
|
|
|
|
t1101 = t1001 + (ppm >> 1); /* .1101 */
|
|
|
|
ppm >>= 20; /* .000000000000000000001 */
|
|
|
|
t1101 += t1101 >> 15; /* .1101000000000001101 */
|
|
|
|
t1001 >>= 11; /* .000000000001001 */
|
|
|
|
t1001 += t1001 >> 12; /* .000000000001001000000001001 */
|
|
|
|
ppm += t1001; /* .000000000001001000001001001 */
|
|
|
|
ppm += t1101; /* .110100000001001110101001001 */
|
|
|
|
return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */
|
|
|
|
#else
|
|
|
|
/* The argument is a PNG unsigned integer, so it is not permitted
|
|
|
|
* to be bigger than 2^31.
|
|
|
|
*/
|
|
|
|
png_fixed_point result;
|
2010-08-19 17:52:01 -04:00
|
|
|
if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127,
|
|
|
|
5000))
|
2010-07-29 18:39:14 -04:00
|
|
|
return result;
|
|
|
|
|
|
|
|
/* Overflow. */
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1998-02-28 08:00:24 -05:00
|
|
|
png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2010-07-29 18:39:14 -04:00
|
|
|
return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr));
|
1998-02-28 08:00:24 -05:00
|
|
|
}
|
|
|
|
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1998-02-28 08:00:24 -05:00
|
|
|
png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2010-07-29 18:39:14 -04:00
|
|
|
return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr));
|
1998-02-28 08:00:24 -05:00
|
|
|
}
|
|
|
|
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1998-02-28 08:00:24 -05:00
|
|
|
png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2010-07-29 18:39:14 -04:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
/* Convert from metres * 1,000,000 to inches * 100,000, meters to
|
|
|
|
* inches is simply *(100/2.54), so we want *(10/2.54) == 1000/254.
|
|
|
|
* Notice that this can overflow - a warning is output and 0 is
|
|
|
|
* returned.
|
|
|
|
*/
|
|
|
|
return png_muldiv_warn(png_ptr, microns, 500, 127);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_fixed_point PNGAPI
|
|
|
|
png_get_x_offset_inches_fixed(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
return png_fixed_inches_from_microns(png_ptr,
|
2010-08-19 17:52:01 -04:00
|
|
|
png_get_x_offset_microns(png_ptr, info_ptr));
|
2010-07-29 18:39:14 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
|
|
|
png_fixed_point PNGAPI
|
|
|
|
png_get_y_offset_inches_fixed(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
return png_fixed_inches_from_microns(png_ptr,
|
2010-08-19 17:52:01 -04:00
|
|
|
png_get_y_offset_microns(png_ptr, info_ptr));
|
1998-02-28 08:00:24 -05:00
|
|
|
}
|
2010-07-29 18:39:14 -04:00
|
|
|
#endif
|
1998-02-28 08:00:24 -05:00
|
|
|
|
2010-07-29 18:39:14 -04:00
|
|
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
float PNGAPI
|
1998-02-28 08:00:24 -05:00
|
|
|
png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2010-07-29 18:39:14 -04:00
|
|
|
/* To avoid the overflow do the conversion directly in floating
|
|
|
|
* point.
|
|
|
|
*/
|
2010-08-19 17:52:01 -04:00
|
|
|
return (float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937);
|
1998-02-28 08:00:24 -05:00
|
|
|
}
|
2010-07-29 18:39:14 -04:00
|
|
|
#endif
|
1998-02-28 08:00:24 -05:00
|
|
|
|
2010-07-29 18:39:14 -04:00
|
|
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
float PNGAPI
|
1998-02-28 08:00:24 -05:00
|
|
|
png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2010-07-29 18:39:14 -04:00
|
|
|
/* To avoid the overflow do the conversion directly in floating
|
|
|
|
* point.
|
|
|
|
*/
|
2010-08-19 17:52:01 -04:00
|
|
|
return (float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937);
|
1998-02-28 08:00:24 -05:00
|
|
|
}
|
2010-07-29 18:39:14 -04:00
|
|
|
#endif
|
1998-02-28 08:00:24 -05:00
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_pHYs_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1998-02-28 08:00:24 -05:00
|
|
|
png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
|
2010-03-06 08:34:28 -05:00
|
|
|
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
|
1998-02-28 08:00:24 -05:00
|
|
|
{
|
|
|
|
png_uint_32 retval = 0;
|
|
|
|
|
2000-02-05 00:40:16 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
1998-02-28 08:00:24 -05:00
|
|
|
{
|
2008-08-05 08:44:42 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "pHYs");
|
2009-08-15 14:25:47 -04:00
|
|
|
|
1998-02-28 08:00:24 -05:00
|
|
|
if (res_x != NULL)
|
|
|
|
{
|
|
|
|
*res_x = info_ptr->x_pixels_per_unit;
|
|
|
|
retval |= PNG_INFO_pHYs;
|
|
|
|
}
|
2010-05-06 10:44:04 -04:00
|
|
|
|
1998-02-28 08:00:24 -05:00
|
|
|
if (res_y != NULL)
|
|
|
|
{
|
|
|
|
*res_y = info_ptr->y_pixels_per_unit;
|
|
|
|
retval |= PNG_INFO_pHYs;
|
|
|
|
}
|
2010-05-06 10:44:04 -04:00
|
|
|
|
1998-02-28 08:00:24 -05:00
|
|
|
if (unit_type != NULL)
|
|
|
|
{
|
|
|
|
*unit_type = (int)info_ptr->phys_unit_type;
|
|
|
|
retval |= PNG_INFO_pHYs;
|
2010-08-19 17:52:01 -04:00
|
|
|
|
2008-07-10 10:13:13 -04:00
|
|
|
if (*unit_type == 1)
|
1998-02-28 08:00:24 -05:00
|
|
|
{
|
2000-02-18 14:48:52 -05:00
|
|
|
if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
|
|
|
|
if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
|
1998-02-28 08:00:24 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (retval);
|
|
|
|
}
|
2001-05-07 15:52:45 -04:00
|
|
|
#endif /* PNG_pHYs_SUPPORTED */
|
2010-07-29 18:39:14 -04:00
|
|
|
#endif /* PNG_INCH_CONVERSIONS_SUPPORTED */
|
1998-02-28 08:00:24 -05:00
|
|
|
|
|
|
|
/* png_get_channels really belongs in here, too, but it's been around longer */
|
1998-06-06 16:31:35 -04:00
|
|
|
|
1998-02-28 08:00:24 -05:00
|
|
|
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
|
|
|
|
2000-05-06 15:09:57 -04:00
|
|
|
png_byte PNGAPI
|
1997-05-16 03:46:07 -04:00
|
|
|
png_get_channels(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
1998-02-08 21:56:40 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
1997-05-16 03:46:07 -04:00
|
|
|
return(info_ptr->channels);
|
2010-05-06 10:44:04 -04:00
|
|
|
|
1997-05-16 03:46:07 -04:00
|
|
|
else
|
1998-02-07 11:20:57 -05:00
|
|
|
return (0);
|
1997-05-16 03:46:07 -04:00
|
|
|
}
|
|
|
|
|
2010-08-18 08:25:46 -04:00
|
|
|
png_const_bytep PNGAPI
|
1997-05-16 03:46:07 -04:00
|
|
|
png_get_signature(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
1998-02-08 21:56:40 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
1997-05-16 03:46:07 -04:00
|
|
|
return(info_ptr->signature);
|
2010-05-06 10:44:04 -04:00
|
|
|
|
1997-05-16 03:46:07 -04:00
|
|
|
else
|
1998-02-07 11:20:57 -05:00
|
|
|
return (NULL);
|
1997-05-16 03:46:07 -04:00
|
|
|
}
|
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_bKGD_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1997-05-16 03:46:07 -04:00
|
|
|
png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
|
|
|
|
png_color_16p *background)
|
|
|
|
{
|
1998-02-28 08:00:24 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
|
2010-03-06 08:34:28 -05:00
|
|
|
&& background != NULL)
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
2008-08-05 08:44:42 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "bKGD");
|
2009-08-15 14:25:47 -04:00
|
|
|
|
1997-05-16 03:46:07 -04:00
|
|
|
*background = &(info_ptr->background);
|
|
|
|
return (PNG_INFO_bKGD);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_cHRM_SUPPORTED
|
1999-12-10 10:43:02 -05:00
|
|
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1997-05-16 03:46:07 -04:00
|
|
|
png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
|
2010-03-06 08:34:28 -05:00
|
|
|
double *white_x, double *white_y, double *red_x, double *red_y,
|
|
|
|
double *green_x, double *green_y, double *blue_x, double *blue_y)
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
1998-02-28 08:00:24 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
2008-08-05 08:44:42 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "cHRM");
|
2009-08-15 14:25:47 -04:00
|
|
|
|
1997-05-16 03:46:07 -04:00
|
|
|
if (white_x != NULL)
|
2010-07-29 18:39:14 -04:00
|
|
|
*white_x = png_float(png_ptr, info_ptr->x_white, "cHRM white X");
|
1997-05-16 03:46:07 -04:00
|
|
|
if (white_y != NULL)
|
2010-07-29 18:39:14 -04:00
|
|
|
*white_y = png_float(png_ptr, info_ptr->y_white, "cHRM white Y");
|
1997-05-16 03:46:07 -04:00
|
|
|
if (red_x != NULL)
|
2010-07-29 18:39:14 -04:00
|
|
|
*red_x = png_float(png_ptr, info_ptr->x_red, "cHRM red X");
|
1997-05-16 03:46:07 -04:00
|
|
|
if (red_y != NULL)
|
2010-07-29 18:39:14 -04:00
|
|
|
*red_y = png_float(png_ptr, info_ptr->y_red, "cHRM red Y");
|
1997-05-16 03:46:07 -04:00
|
|
|
if (green_x != NULL)
|
2010-07-29 18:39:14 -04:00
|
|
|
*green_x = png_float(png_ptr, info_ptr->x_green, "cHRM green X");
|
1997-05-16 03:46:07 -04:00
|
|
|
if (green_y != NULL)
|
2010-07-29 18:39:14 -04:00
|
|
|
*green_y = png_float(png_ptr, info_ptr->y_green, "cHRM green Y");
|
1997-05-16 03:46:07 -04:00
|
|
|
if (blue_x != NULL)
|
2010-07-29 18:39:14 -04:00
|
|
|
*blue_x = png_float(png_ptr, info_ptr->x_blue, "cHRM blue X");
|
1997-05-16 03:46:07 -04:00
|
|
|
if (blue_y != NULL)
|
2010-07-29 18:39:14 -04:00
|
|
|
*blue_y = png_float(png_ptr, info_ptr->y_blue, "cHRM blue Y");
|
1997-05-16 03:46:07 -04:00
|
|
|
return (PNG_INFO_cHRM);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
2010-07-29 18:39:14 -04:00
|
|
|
|
1999-12-10 10:43:02 -05:00
|
|
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1999-12-10 10:43:02 -05:00
|
|
|
png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
|
2010-03-06 08:34:28 -05:00
|
|
|
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)
|
1999-12-10 10:43:02 -05:00
|
|
|
{
|
2009-08-15 22:47:03 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "cHRM");
|
|
|
|
|
1999-12-10 10:43:02 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
|
|
|
{
|
|
|
|
if (white_x != NULL)
|
2010-07-29 18:39:14 -04:00
|
|
|
*white_x = info_ptr->x_white;
|
1999-12-10 10:43:02 -05:00
|
|
|
if (white_y != NULL)
|
2010-07-29 18:39:14 -04:00
|
|
|
*white_y = info_ptr->y_white;
|
1999-12-10 10:43:02 -05:00
|
|
|
if (red_x != NULL)
|
2010-07-29 18:39:14 -04:00
|
|
|
*red_x = info_ptr->x_red;
|
1999-12-10 10:43:02 -05:00
|
|
|
if (red_y != NULL)
|
2010-07-29 18:39:14 -04:00
|
|
|
*red_y = info_ptr->y_red;
|
1999-12-10 10:43:02 -05:00
|
|
|
if (green_x != NULL)
|
2010-07-29 18:39:14 -04:00
|
|
|
*green_x = info_ptr->x_green;
|
1999-12-10 10:43:02 -05:00
|
|
|
if (green_y != NULL)
|
2010-07-29 18:39:14 -04:00
|
|
|
*green_y = info_ptr->y_green;
|
1999-12-10 10:43:02 -05:00
|
|
|
if (blue_x != NULL)
|
2010-07-29 18:39:14 -04:00
|
|
|
*blue_x = info_ptr->x_blue;
|
1999-12-10 10:43:02 -05:00
|
|
|
if (blue_y != NULL)
|
2010-07-29 18:39:14 -04:00
|
|
|
*blue_y = info_ptr->y_blue;
|
1999-12-10 10:43:02 -05:00
|
|
|
return (PNG_INFO_cHRM);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
1997-05-16 03:46:07 -04:00
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_gAMA_SUPPORTED
|
2010-07-29 18:39:14 -04:00
|
|
|
png_uint_32 PNGFAPI
|
|
|
|
png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
|
|
|
|
png_fixed_point *file_gamma)
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
2009-08-15 22:47:03 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "gAMA");
|
|
|
|
|
1998-02-28 08:00:24 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
|
2010-03-06 08:34:28 -05:00
|
|
|
&& file_gamma != NULL)
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
2010-07-29 18:39:14 -04:00
|
|
|
*file_gamma = info_ptr->gamma;
|
1997-05-16 03:46:07 -04:00
|
|
|
return (PNG_INFO_gAMA);
|
|
|
|
}
|
2010-07-29 18:39:14 -04:00
|
|
|
|
1997-05-16 03:46:07 -04:00
|
|
|
return (0);
|
|
|
|
}
|
2010-07-29 18:39:14 -04:00
|
|
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
2010-07-29 18:39:14 -04:00
|
|
|
png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
|
1999-12-10 10:43:02 -05:00
|
|
|
{
|
2010-07-29 18:39:14 -04:00
|
|
|
png_fixed_point igamma;
|
|
|
|
png_uint_32 ok = png_get_gAMA_fixed(png_ptr, info_ptr, &igamma);
|
|
|
|
if (ok)
|
|
|
|
*file_gamma = png_float(png_ptr, igamma, "png_get_gAMA");
|
|
|
|
return ok;
|
1999-12-10 10:43:02 -05:00
|
|
|
}
|
|
|
|
#endif
|
2000-05-01 10:31:54 -04:00
|
|
|
#endif
|
1997-05-16 03:46:07 -04:00
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_sRGB_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1998-01-16 23:06:18 -05:00
|
|
|
png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
|
1998-01-01 08:13:13 -05:00
|
|
|
{
|
2009-08-15 22:47:03 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "sRGB");
|
|
|
|
|
1998-02-28 08:00:24 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
|
2010-03-06 08:34:28 -05:00
|
|
|
&& file_srgb_intent != NULL)
|
1998-01-01 08:13:13 -05:00
|
|
|
{
|
1998-01-16 23:06:18 -05:00
|
|
|
*file_srgb_intent = (int)info_ptr->srgb_intent;
|
1998-01-01 08:13:13 -05:00
|
|
|
return (PNG_INFO_sRGB);
|
|
|
|
}
|
2010-05-06 10:44:04 -04:00
|
|
|
|
1998-01-01 08:13:13 -05:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_iCCP_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1999-12-10 10:43:02 -05:00
|
|
|
png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
|
2010-03-06 08:34:28 -05:00
|
|
|
png_charpp name, int *compression_type,
|
2010-07-29 18:39:14 -04:00
|
|
|
png_bytepp profile, png_uint_32 *proflen)
|
1999-12-10 10:43:02 -05:00
|
|
|
{
|
2009-08-15 22:47:03 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "iCCP");
|
|
|
|
|
1999-12-10 10:43:02 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
|
2010-03-06 08:34:28 -05:00
|
|
|
&& name != NULL && profile != NULL && proflen != NULL)
|
1999-12-10 10:43:02 -05:00
|
|
|
{
|
|
|
|
*name = info_ptr->iccp_name;
|
|
|
|
*profile = info_ptr->iccp_profile;
|
2009-05-20 13:45:29 -04:00
|
|
|
/* Compression_type is a dummy so the API won't have to change
|
|
|
|
* if we introduce multiple compression types later.
|
|
|
|
*/
|
1999-12-10 10:43:02 -05:00
|
|
|
*proflen = (int)info_ptr->iccp_proflen;
|
|
|
|
*compression_type = (int)info_ptr->iccp_compression;
|
|
|
|
return (PNG_INFO_iCCP);
|
|
|
|
}
|
2010-05-06 10:44:04 -04:00
|
|
|
|
1999-12-10 10:43:02 -05:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_sPLT_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
2000-02-18 14:48:52 -05:00
|
|
|
png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
|
2010-03-06 08:34:28 -05:00
|
|
|
png_sPLT_tpp spalettes)
|
1999-12-10 10:43:02 -05:00
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
|
2008-07-10 10:13:13 -04:00
|
|
|
{
|
2010-03-06 08:34:28 -05:00
|
|
|
*spalettes = info_ptr->splt_palettes;
|
|
|
|
return ((png_uint_32)info_ptr->splt_palettes_num);
|
2008-07-10 10:13:13 -04:00
|
|
|
}
|
2010-05-06 10:44:04 -04:00
|
|
|
|
2008-07-10 10:13:13 -04:00
|
|
|
return (0);
|
1999-12-10 10:43:02 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_hIST_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1997-05-16 03:46:07 -04:00
|
|
|
png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
|
|
|
|
{
|
2009-08-15 22:47:03 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "hIST");
|
|
|
|
|
1998-02-28 08:00:24 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
|
2010-03-06 08:34:28 -05:00
|
|
|
&& hist != NULL)
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
|
|
|
*hist = info_ptr->hist;
|
|
|
|
return (PNG_INFO_hIST);
|
|
|
|
}
|
2010-05-06 10:44:04 -04:00
|
|
|
|
1997-05-16 03:46:07 -04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1997-05-16 03:46:07 -04:00
|
|
|
png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
|
2010-03-06 08:34:28 -05:00
|
|
|
png_uint_32 *width, png_uint_32 *height, int *bit_depth,
|
|
|
|
int *color_type, int *interlace_type, int *compression_type,
|
|
|
|
int *filter_type)
|
1998-12-29 12:47:59 -05:00
|
|
|
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
2009-09-24 19:10:49 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "IHDR");
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2009-09-24 19:10:49 -04:00
|
|
|
if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
|
|
|
|
height == NULL || bit_depth == NULL || color_type == NULL)
|
|
|
|
return (0);
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2009-09-24 19:10:49 -04:00
|
|
|
*width = info_ptr->width;
|
|
|
|
*height = info_ptr->height;
|
|
|
|
*bit_depth = info_ptr->bit_depth;
|
|
|
|
*color_type = info_ptr->color_type;
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2009-09-24 19:10:49 -04:00
|
|
|
if (compression_type != NULL)
|
|
|
|
*compression_type = info_ptr->compression_type;
|
1998-02-07 11:20:57 -05:00
|
|
|
|
2009-09-24 19:10:49 -04:00
|
|
|
if (filter_type != NULL)
|
|
|
|
*filter_type = info_ptr->filter_type;
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2009-09-24 19:10:49 -04:00
|
|
|
if (interlace_type != NULL)
|
|
|
|
*interlace_type = info_ptr->interlace_type;
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2009-10-01 00:12:13 -04:00
|
|
|
/* This is redundant if we can be sure that the info_ptr values were all
|
|
|
|
* assigned in png_set_IHDR(). We do the check anyhow in case an
|
|
|
|
* 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,
|
|
|
|
info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
|
|
|
|
info_ptr->compression_type, info_ptr->filter_type);
|
2009-05-15 21:39:34 -04:00
|
|
|
|
2009-09-24 19:10:49 -04:00
|
|
|
return (1);
|
1997-05-16 03:46:07 -04:00
|
|
|
}
|
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_oFFs_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1997-05-16 03:46:07 -04:00
|
|
|
png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
|
2010-03-06 08:34:28 -05:00
|
|
|
png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
2009-08-15 22:47:03 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "oFFs");
|
|
|
|
|
1998-02-28 08:00:24 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
|
2010-03-06 08:34:28 -05:00
|
|
|
&& offset_x != NULL && offset_y != NULL && unit_type != NULL)
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
|
|
|
*offset_x = info_ptr->x_offset;
|
|
|
|
*offset_y = info_ptr->y_offset;
|
|
|
|
*unit_type = (int)info_ptr->offset_unit_type;
|
|
|
|
return (PNG_INFO_oFFs);
|
|
|
|
}
|
2010-05-06 10:44:04 -04:00
|
|
|
|
1997-05-16 03:46:07 -04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_pCAL_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1997-05-16 03:46:07 -04:00
|
|
|
png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
|
2010-03-06 08:34:28 -05:00
|
|
|
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
|
|
|
|
png_charp *units, png_charpp *params)
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
2009-08-15 22:47:03 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "pCAL");
|
|
|
|
|
2000-02-05 00:40:16 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
|
2009-05-15 21:39:34 -04:00
|
|
|
&& purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
|
|
|
|
nparams != NULL && units != NULL && params != NULL)
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
|
|
|
*purpose = info_ptr->pcal_purpose;
|
|
|
|
*X0 = info_ptr->pcal_X0;
|
|
|
|
*X1 = info_ptr->pcal_X1;
|
|
|
|
*type = (int)info_ptr->pcal_type;
|
|
|
|
*nparams = (int)info_ptr->pcal_nparams;
|
|
|
|
*units = info_ptr->pcal_units;
|
|
|
|
*params = info_ptr->pcal_params;
|
|
|
|
return (PNG_INFO_pCAL);
|
|
|
|
}
|
2010-05-06 10:44:04 -04:00
|
|
|
|
1997-05-16 03:46:07 -04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_sCAL_SUPPORTED
|
2010-07-29 18:39:14 -04:00
|
|
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
2010-07-31 07:34:36 -04:00
|
|
|
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
2010-07-29 18:39:14 -04:00
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_sCAL_fixed(png_structp png_ptr, png_infop 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))
|
|
|
|
{
|
|
|
|
*unit = info_ptr->scal_unit;
|
2010-07-31 07:34:36 -04:00
|
|
|
/*TODO: make this work without FP support */
|
2010-07-29 18:39:14 -04:00
|
|
|
*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");
|
|
|
|
return (PNG_INFO_sCAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
2010-07-31 07:34:36 -04:00
|
|
|
#endif /*FLOATING_ARITHMETIC*/
|
|
|
|
#endif /*FIXED_POINT*/
|
1999-12-10 10:43:02 -05:00
|
|
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1999-12-10 10:43:02 -05:00
|
|
|
png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
|
2010-03-06 08:34:28 -05:00
|
|
|
int *unit, double *width, double *height)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL &&
|
|
|
|
(info_ptr->valid & PNG_INFO_sCAL))
|
|
|
|
{
|
|
|
|
*unit = info_ptr->scal_unit;
|
2010-07-29 18:39:14 -04:00
|
|
|
*width = atof(info_ptr->scal_s_width);
|
|
|
|
*height = atof(info_ptr->scal_s_height);
|
2010-03-06 08:34:28 -05:00
|
|
|
return (PNG_INFO_sCAL);
|
|
|
|
}
|
2010-05-06 10:44:04 -04:00
|
|
|
|
2010-03-06 08:34:28 -05:00
|
|
|
return(0);
|
1999-12-10 10:43:02 -05:00
|
|
|
}
|
2010-06-25 22:45:31 -04:00
|
|
|
#endif
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1999-12-10 10:43:02 -05:00
|
|
|
png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
2010-08-19 17:52:01 -04:00
|
|
|
int *unit, png_charpp width, png_charpp height)
|
1999-12-10 10:43:02 -05:00
|
|
|
{
|
2010-03-06 08:34:28 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL &&
|
|
|
|
(info_ptr->valid & PNG_INFO_sCAL))
|
|
|
|
{
|
|
|
|
*unit = info_ptr->scal_unit;
|
|
|
|
*width = info_ptr->scal_s_width;
|
|
|
|
*height = info_ptr->scal_s_height;
|
|
|
|
return (PNG_INFO_sCAL);
|
|
|
|
}
|
2010-05-06 10:44:04 -04:00
|
|
|
|
2010-03-06 08:34:28 -05:00
|
|
|
return(0);
|
1999-12-10 10:43:02 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_pHYs_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1997-05-16 03:46:07 -04:00
|
|
|
png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
|
2010-03-06 08:34:28 -05:00
|
|
|
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
1998-01-01 08:13:13 -05:00
|
|
|
png_uint_32 retval = 0;
|
|
|
|
|
2009-08-15 22:47:03 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "pHYs");
|
|
|
|
|
2000-02-05 00:40:16 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL &&
|
2010-03-06 08:34:28 -05:00
|
|
|
(info_ptr->valid & PNG_INFO_pHYs))
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
1998-02-28 08:00:24 -05:00
|
|
|
if (res_x != NULL)
|
1998-01-01 08:13:13 -05:00
|
|
|
{
|
|
|
|
*res_x = info_ptr->x_pixels_per_unit;
|
1998-02-28 08:00:24 -05:00
|
|
|
retval |= PNG_INFO_pHYs;
|
|
|
|
}
|
2009-05-15 21:39:34 -04:00
|
|
|
|
1998-02-28 08:00:24 -05:00
|
|
|
if (res_y != NULL)
|
|
|
|
{
|
1998-01-01 08:13:13 -05:00
|
|
|
*res_y = info_ptr->y_pixels_per_unit;
|
|
|
|
retval |= PNG_INFO_pHYs;
|
|
|
|
}
|
2009-05-15 21:39:34 -04:00
|
|
|
|
1998-01-01 08:13:13 -05:00
|
|
|
if (unit_type != NULL)
|
|
|
|
{
|
|
|
|
*unit_type = (int)info_ptr->phys_unit_type;
|
|
|
|
retval |= PNG_INFO_pHYs;
|
|
|
|
}
|
1997-05-16 03:46:07 -04:00
|
|
|
}
|
2010-05-06 10:44:04 -04:00
|
|
|
|
1998-02-28 08:00:24 -05:00
|
|
|
return (retval);
|
1997-05-16 03:46:07 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1997-05-16 03:46:07 -04:00
|
|
|
png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
|
2010-03-06 08:34:28 -05:00
|
|
|
int *num_palette)
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
2009-08-15 22:47:03 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "PLTE");
|
|
|
|
|
2000-02-05 00:40:16 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
|
|
|
|
&& palette != NULL)
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
|
|
|
*palette = info_ptr->palette;
|
|
|
|
*num_palette = info_ptr->num_palette;
|
2008-08-05 08:44:42 -04:00
|
|
|
png_debug1(3, "num_palette = %d", *num_palette);
|
1997-05-16 03:46:07 -04:00
|
|
|
return (PNG_INFO_PLTE);
|
|
|
|
}
|
2010-05-06 10:44:04 -04:00
|
|
|
|
1997-05-16 03:46:07 -04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_sBIT_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1997-05-16 03:46:07 -04:00
|
|
|
png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
|
|
|
|
{
|
2009-08-15 22:47:03 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "sBIT");
|
|
|
|
|
2000-02-05 00:40:16 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
|
2010-03-06 08:34:28 -05:00
|
|
|
&& sig_bit != NULL)
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
|
|
|
*sig_bit = &(info_ptr->sig_bit);
|
|
|
|
return (PNG_INFO_sBIT);
|
|
|
|
}
|
2010-05-06 10:44:04 -04:00
|
|
|
|
1997-05-16 03:46:07 -04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_TEXT_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1997-05-16 03:46:07 -04:00
|
|
|
png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
|
2010-03-06 08:34:28 -05:00
|
|
|
int *num_text)
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
1998-02-28 08:00:24 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
2008-08-05 08:44:42 -04:00
|
|
|
png_debug1(1, "in %s retrieval function",
|
2010-03-06 08:34:28 -05:00
|
|
|
(png_ptr->chunk_name[0] == '\0' ? "text" :
|
|
|
|
(png_const_charp)png_ptr->chunk_name));
|
2009-05-15 21:39:34 -04:00
|
|
|
|
1997-05-16 03:46:07 -04:00
|
|
|
if (text_ptr != NULL)
|
|
|
|
*text_ptr = info_ptr->text;
|
2009-05-15 21:39:34 -04:00
|
|
|
|
1997-05-16 03:46:07 -04:00
|
|
|
if (num_text != NULL)
|
|
|
|
*num_text = info_ptr->num_text;
|
2009-05-15 21:39:34 -04:00
|
|
|
|
1998-01-01 08:13:13 -05:00
|
|
|
return ((png_uint_32)info_ptr->num_text);
|
1997-05-16 03:46:07 -04:00
|
|
|
}
|
2010-05-06 10:44:04 -04:00
|
|
|
|
2000-02-18 14:48:52 -05:00
|
|
|
if (num_text != NULL)
|
2010-03-06 08:34:28 -05:00
|
|
|
*num_text = 0;
|
2010-05-06 10:44:04 -04:00
|
|
|
|
1997-05-16 03:46:07 -04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_tIME_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1997-05-16 03:46:07 -04:00
|
|
|
png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
|
|
|
|
{
|
2009-08-15 22:47:03 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "tIME");
|
|
|
|
|
2000-02-05 00:40:16 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
|
|
|
|
&& mod_time != NULL)
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
|
|
|
*mod_time = &(info_ptr->mod_time);
|
|
|
|
return (PNG_INFO_tIME);
|
|
|
|
}
|
2010-05-06 10:44:04 -04:00
|
|
|
|
1997-05-16 03:46:07 -04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_tRNS_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_uint_32 PNGAPI
|
1997-05-16 03:46:07 -04:00
|
|
|
png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
|
2010-03-06 08:34:28 -05:00
|
|
|
png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
1998-02-28 08:00:24 -05:00
|
|
|
png_uint_32 retval = 0;
|
2000-02-05 00:40:16 -05:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
2008-08-05 08:44:42 -04:00
|
|
|
png_debug1(1, "in %s retrieval function", "tRNS");
|
2009-08-15 14:25:47 -04:00
|
|
|
|
1998-02-28 08:00:24 -05:00
|
|
|
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
2010-03-06 08:34:28 -05:00
|
|
|
if (trans_alpha != NULL)
|
|
|
|
{
|
|
|
|
*trans_alpha = info_ptr->trans_alpha;
|
|
|
|
retval |= PNG_INFO_tRNS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (trans_color != NULL)
|
|
|
|
*trans_color = &(info_ptr->trans_color);
|
1997-05-16 03:46:07 -04:00
|
|
|
}
|
2010-05-06 10:44:04 -04:00
|
|
|
|
1998-02-28 08:00:24 -05:00
|
|
|
else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
2010-03-06 08:34:28 -05:00
|
|
|
if (trans_color != NULL)
|
|
|
|
{
|
|
|
|
*trans_color = &(info_ptr->trans_color);
|
|
|
|
retval |= PNG_INFO_tRNS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (trans_alpha != NULL)
|
|
|
|
*trans_alpha = NULL;
|
1997-05-16 03:46:07 -04:00
|
|
|
}
|
2010-05-06 10:44:04 -04:00
|
|
|
|
2008-07-10 10:13:13 -04:00
|
|
|
if (num_trans != NULL)
|
1997-05-16 03:46:07 -04:00
|
|
|
{
|
1998-02-28 08:00:24 -05:00
|
|
|
*num_trans = info_ptr->num_trans;
|
|
|
|
retval |= PNG_INFO_tRNS;
|
1997-05-16 03:46:07 -04:00
|
|
|
}
|
|
|
|
}
|
2010-05-06 10:44:04 -04:00
|
|
|
|
1998-02-28 08:00:24 -05:00
|
|
|
return (retval);
|
1997-05-16 03:46:07 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
2010-08-19 17:52:01 -04:00
|
|
|
int PNGAPI
|
1999-12-10 10:43:02 -05:00
|
|
|
png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
|
2010-03-06 08:34:28 -05:00
|
|
|
png_unknown_chunkpp unknowns)
|
1999-12-10 10:43:02 -05:00
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
|
2008-07-10 10:13:13 -04:00
|
|
|
{
|
2010-03-06 08:34:28 -05:00
|
|
|
*unknowns = info_ptr->unknown_chunks;
|
2010-08-19 17:52:01 -04:00
|
|
|
return info_ptr->unknown_chunks_num;
|
2008-07-10 10:13:13 -04:00
|
|
|
}
|
2010-05-06 10:44:04 -04:00
|
|
|
|
2008-07-10 10:13:13 -04:00
|
|
|
return (0);
|
1999-12-10 10:43:02 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_byte PNGAPI
|
1998-12-29 12:47:59 -05:00
|
|
|
png_get_rgb_to_gray_status (png_structp png_ptr)
|
|
|
|
{
|
2010-03-06 09:24:45 -05:00
|
|
|
return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
|
1998-12-29 12:47:59 -05:00
|
|
|
}
|
|
|
|
#endif
|
2000-02-05 00:40:16 -05:00
|
|
|
|
2009-09-23 12:22:08 -04:00
|
|
|
#ifdef PNG_USER_CHUNKS_SUPPORTED
|
2000-05-06 15:09:57 -04:00
|
|
|
png_voidp PNGAPI
|
2000-02-05 00:40:16 -05:00
|
|
|
png_get_user_chunk_ptr(png_structp png_ptr)
|
|
|
|
{
|
2010-03-06 09:24:45 -05:00
|
|
|
return (png_ptr ? png_ptr->user_chunk_ptr : NULL);
|
2000-02-05 00:40:16 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-08-19 14:59:24 -04:00
|
|
|
png_size_t PNGAPI
|
2000-04-24 00:14:02 -04:00
|
|
|
png_get_compression_buffer_size(png_structp png_ptr)
|
|
|
|
{
|
2008-07-10 10:13:13 -04:00
|
|
|
return (png_ptr ? png_ptr->zbuf_size : 0L);
|
2001-05-14 10:20:53 -04:00
|
|
|
}
|
|
|
|
|
2004-08-04 07:34:52 -04:00
|
|
|
|
|
|
|
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
2010-02-07 19:08:50 -05:00
|
|
|
/* These functions were added to libpng 1.2.6 and were enabled
|
|
|
|
* by default in libpng-1.4.0 */
|
2004-08-04 07:34:52 -04:00
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_user_width_max (png_structp png_ptr)
|
|
|
|
{
|
2010-03-06 09:24:45 -05:00
|
|
|
return (png_ptr ? png_ptr->user_width_max : 0);
|
2004-08-04 07:34:52 -04:00
|
|
|
}
|
2010-08-19 17:52:01 -04:00
|
|
|
|
2004-08-04 07:34:52 -04:00
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_user_height_max (png_structp png_ptr)
|
|
|
|
{
|
2010-03-06 09:24:45 -05:00
|
|
|
return (png_ptr ? png_ptr->user_height_max : 0);
|
2004-08-04 07:34:52 -04:00
|
|
|
}
|
2010-08-19 17:52:01 -04:00
|
|
|
|
2009-11-09 07:51:16 -05:00
|
|
|
/* This function was added to libpng 1.4.0 */
|
2008-08-20 18:25:21 -04:00
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_chunk_cache_max (png_structp png_ptr)
|
|
|
|
{
|
2010-03-06 09:24:45 -05:00
|
|
|
return (png_ptr ? png_ptr->user_chunk_cache_max : 0);
|
2010-02-07 19:08:50 -05:00
|
|
|
}
|
2010-08-19 17:52:01 -04:00
|
|
|
|
2010-02-07 19:08:50 -05:00
|
|
|
/* This function was added to libpng 1.4.1 */
|
2010-02-14 08:16:19 -05:00
|
|
|
png_alloc_size_t PNGAPI
|
2010-02-07 19:08:50 -05:00
|
|
|
png_get_chunk_malloc_max (png_structp png_ptr)
|
|
|
|
{
|
2010-03-06 09:24:45 -05:00
|
|
|
return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
|
2008-08-20 18:25:21 -04:00
|
|
|
}
|
2004-08-04 07:34:52 -04:00
|
|
|
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
|
2009-06-15 22:56:14 -04:00
|
|
|
|
2010-02-07 19:08:50 -05:00
|
|
|
/* These functions were added to libpng 1.4.0 */
|
2006-08-19 14:59:24 -04:00
|
|
|
#ifdef PNG_IO_STATE_SUPPORTED
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_io_state (png_structp png_ptr)
|
|
|
|
{
|
2010-03-06 08:34:28 -05:00
|
|
|
return png_ptr->io_state;
|
2006-08-19 14:59:24 -04:00
|
|
|
}
|
|
|
|
|
2010-08-18 08:25:46 -04:00
|
|
|
png_const_bytep PNGAPI
|
2006-08-19 14:59:24 -04:00
|
|
|
png_get_io_chunk_name (png_structp png_ptr)
|
|
|
|
{
|
|
|
|
return png_ptr->chunk_name;
|
|
|
|
}
|
|
|
|
#endif /* ?PNG_IO_STATE_SUPPORTED */
|
|
|
|
|
2006-02-20 23:09:05 -05:00
|
|
|
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|