2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* pngget.c - retrieval of values from info struct
|
|
|
|
*
|
2010-07-22 00:00:30 -07:00
|
|
|
* Last changed in libpng 1.4.2 [May 6, 2010]
|
2010-01-05 13:46:26 -08:00
|
|
|
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
2007-03-22 10:30:00 -07:00
|
|
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
|
|
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
2009-11-10 17:39:31 -08:00
|
|
|
*
|
|
|
|
* This code is released under the libpng license.
|
|
|
|
* For conditions of distribution and use, see the disclaimer
|
|
|
|
* and license in png.h
|
|
|
|
*
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#define PNG_NO_PEDANTIC_WARNINGS
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "png.h"
|
|
|
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
2010-01-05 13:46:26 -08:00
|
|
|
#include "pngpriv.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return(info_ptr->valid & flag);
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
else
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
png_size_t PNGAPI
|
2007-03-22 10:30:00 -07:00
|
|
|
png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return(info_ptr->rowbytes);
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
else
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_INFO_IMAGE_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
png_bytepp PNGAPI
|
|
|
|
png_get_rows(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return(info_ptr->row_pointers);
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
else
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
2009-11-10 17:39:31 -08:00
|
|
|
/* Easy access to info, added in libpng-0.99 */
|
2007-03-22 10:30:00 -07:00
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_image_width(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return info_ptr->width;
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_image_height(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return info_ptr->height;
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_byte PNGAPI
|
|
|
|
png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return info_ptr->bit_depth;
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_byte PNGAPI
|
|
|
|
png_get_color_type(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return info_ptr->color_type;
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_byte PNGAPI
|
|
|
|
png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return info_ptr->filter_type;
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_byte PNGAPI
|
|
|
|
png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return info_ptr->interlace_type;
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_byte PNGAPI
|
|
|
|
png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return info_ptr->compression_type;
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_pHYs_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
if (info_ptr->valid & PNG_INFO_pHYs)
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter");
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2008-09-10 13:56:22 -07:00
|
|
|
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
2007-03-22 10:30:00 -07:00
|
|
|
return (0);
|
2009-11-10 17:39:31 -08:00
|
|
|
|
|
|
|
else
|
|
|
|
return (info_ptr->x_pixels_per_unit);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
return (0);
|
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_pHYs_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
if (info_ptr->valid & PNG_INFO_pHYs)
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter");
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2008-09-10 13:56:22 -07:00
|
|
|
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
2007-03-22 10:30:00 -07:00
|
|
|
return (0);
|
2009-11-10 17:39:31 -08:00
|
|
|
|
|
|
|
else
|
|
|
|
return (info_ptr->y_pixels_per_unit);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
return (0);
|
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_pHYs_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
if (info_ptr->valid & PNG_INFO_pHYs)
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2008-09-10 13:56:22 -07:00
|
|
|
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
|
2007-03-22 10:30:00 -07:00
|
|
|
info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
|
|
|
|
return (0);
|
2009-11-10 17:39:31 -08:00
|
|
|
|
|
|
|
else
|
|
|
|
return (info_ptr->x_pixels_per_unit);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
return (0);
|
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
|
|
|
float PNGAPI
|
|
|
|
png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_pHYs_SUPPORTED
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (info_ptr->valid & PNG_INFO_pHYs)
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
|
2010-01-05 13:46:26 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (info_ptr->x_pixels_per_unit == 0)
|
|
|
|
return ((float)0.0);
|
2010-01-05 13:46:26 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
else
|
|
|
|
return ((float)((float)info_ptr->y_pixels_per_unit
|
|
|
|
/(float)info_ptr->x_pixels_per_unit));
|
|
|
|
}
|
|
|
|
#else
|
2009-11-10 17:39:31 -08:00
|
|
|
return (0.0);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
return ((float)0.0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
png_int_32 PNGAPI
|
|
|
|
png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_oFFs_SUPPORTED
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (info_ptr->valid & PNG_INFO_oFFs)
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2008-09-10 13:56:22 -07:00
|
|
|
if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
2007-03-22 10:30:00 -07:00
|
|
|
return (0);
|
2009-11-10 17:39:31 -08:00
|
|
|
|
|
|
|
else
|
|
|
|
return (info_ptr->x_offset);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#else
|
2009-11-10 17:39:31 -08:00
|
|
|
return (0);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_int_32 PNGAPI
|
|
|
|
png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_oFFs_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
if (info_ptr->valid & PNG_INFO_oFFs)
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2008-09-10 13:56:22 -07:00
|
|
|
if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
2007-03-22 10:30:00 -07:00
|
|
|
return (0);
|
2009-11-10 17:39:31 -08:00
|
|
|
|
|
|
|
else
|
|
|
|
return (info_ptr->y_offset);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
return (0);
|
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_int_32 PNGAPI
|
|
|
|
png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_oFFs_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
if (info_ptr->valid & PNG_INFO_oFFs)
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2008-09-10 13:56:22 -07:00
|
|
|
if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
2007-03-22 10:30:00 -07:00
|
|
|
return (0);
|
2009-11-10 17:39:31 -08:00
|
|
|
|
|
|
|
else
|
|
|
|
return (info_ptr->x_offset);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
return (0);
|
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_int_32 PNGAPI
|
|
|
|
png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_oFFs_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
if (info_ptr->valid & PNG_INFO_oFFs)
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2008-09-10 13:56:22 -07:00
|
|
|
if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
2007-03-22 10:30:00 -07:00
|
|
|
return (0);
|
2009-11-10 17:39:31 -08:00
|
|
|
|
|
|
|
else
|
|
|
|
return (info_ptr->y_offset);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
return (0);
|
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr)
|
|
|
|
*.0254 +.5));
|
|
|
|
}
|
|
|
|
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr)
|
|
|
|
*.0254 +.5));
|
|
|
|
}
|
|
|
|
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr)
|
|
|
|
*.0254 +.5));
|
|
|
|
}
|
|
|
|
|
|
|
|
float PNGAPI
|
|
|
|
png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
return ((float)png_get_x_offset_microns(png_ptr, info_ptr)
|
|
|
|
*.00003937);
|
|
|
|
}
|
|
|
|
|
|
|
|
float PNGAPI
|
|
|
|
png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
|
|
|
|
*.00003937);
|
|
|
|
}
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_pHYs_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_pHYs_dpi(png_structp png_ptr, png_infop 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))
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "pHYs");
|
2010-01-05 13:46:26 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (res_x != NULL)
|
|
|
|
{
|
|
|
|
*res_x = info_ptr->x_pixels_per_unit;
|
|
|
|
retval |= PNG_INFO_pHYs;
|
|
|
|
}
|
|
|
|
if (res_y != NULL)
|
|
|
|
{
|
|
|
|
*res_y = info_ptr->y_pixels_per_unit;
|
|
|
|
retval |= PNG_INFO_pHYs;
|
|
|
|
}
|
|
|
|
if (unit_type != NULL)
|
|
|
|
{
|
|
|
|
*unit_type = (int)info_ptr->phys_unit_type;
|
|
|
|
retval |= PNG_INFO_pHYs;
|
2008-09-10 13:56:22 -07:00
|
|
|
if (*unit_type == 1)
|
2007-03-22 10:30:00 -07: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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (retval);
|
|
|
|
}
|
|
|
|
#endif /* PNG_pHYs_SUPPORTED */
|
|
|
|
#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
|
|
|
|
|
|
|
|
/* png_get_channels really belongs in here, too, but it's been around longer */
|
|
|
|
|
|
|
|
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
|
|
|
|
|
|
|
png_byte PNGAPI
|
|
|
|
png_get_channels(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return(info_ptr->channels);
|
|
|
|
else
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_bytep PNGAPI
|
|
|
|
png_get_signature(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return(info_ptr->signature);
|
|
|
|
else
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_bKGD_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
|
|
|
|
png_color_16p *background)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
|
|
|
|
&& background != NULL)
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "bKGD");
|
2010-01-05 13:46:26 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
*background = &(info_ptr->background);
|
|
|
|
return (PNG_INFO_bKGD);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_cHRM_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_cHRM(png_structp png_ptr, png_infop 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))
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "cHRM");
|
2010-01-05 13:46:26 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (white_x != NULL)
|
|
|
|
*white_x = (double)info_ptr->x_white;
|
|
|
|
if (white_y != NULL)
|
|
|
|
*white_y = (double)info_ptr->y_white;
|
|
|
|
if (red_x != NULL)
|
|
|
|
*red_x = (double)info_ptr->x_red;
|
|
|
|
if (red_y != NULL)
|
|
|
|
*red_y = (double)info_ptr->y_red;
|
|
|
|
if (green_x != NULL)
|
|
|
|
*green_x = (double)info_ptr->x_green;
|
|
|
|
if (green_y != NULL)
|
|
|
|
*green_y = (double)info_ptr->y_green;
|
|
|
|
if (blue_x != NULL)
|
|
|
|
*blue_x = (double)info_ptr->x_blue;
|
|
|
|
if (blue_y != NULL)
|
|
|
|
*blue_y = (double)info_ptr->y_blue;
|
|
|
|
return (PNG_INFO_cHRM);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_cHRM_fixed(png_structp png_ptr, png_infop 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)
|
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "cHRM");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
|
|
|
{
|
|
|
|
if (white_x != NULL)
|
|
|
|
*white_x = info_ptr->int_x_white;
|
|
|
|
if (white_y != NULL)
|
|
|
|
*white_y = info_ptr->int_y_white;
|
|
|
|
if (red_x != NULL)
|
|
|
|
*red_x = info_ptr->int_x_red;
|
|
|
|
if (red_y != NULL)
|
|
|
|
*red_y = info_ptr->int_y_red;
|
|
|
|
if (green_x != NULL)
|
|
|
|
*green_x = info_ptr->int_x_green;
|
|
|
|
if (green_y != NULL)
|
|
|
|
*green_y = info_ptr->int_y_green;
|
|
|
|
if (blue_x != NULL)
|
|
|
|
*blue_x = info_ptr->int_x_blue;
|
|
|
|
if (blue_y != NULL)
|
|
|
|
*blue_y = info_ptr->int_y_blue;
|
|
|
|
return (PNG_INFO_cHRM);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_gAMA_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
|
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "gAMA");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
|
|
|
|
&& file_gamma != NULL)
|
|
|
|
{
|
|
|
|
*file_gamma = (double)info_ptr->gamma;
|
|
|
|
return (PNG_INFO_gAMA);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
|
|
|
|
png_fixed_point *int_file_gamma)
|
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "gAMA");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
|
|
|
|
&& int_file_gamma != NULL)
|
|
|
|
{
|
|
|
|
*int_file_gamma = info_ptr->int_gamma;
|
|
|
|
return (PNG_INFO_gAMA);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_sRGB_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
|
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "sRGB");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
|
|
|
|
&& file_srgb_intent != NULL)
|
|
|
|
{
|
|
|
|
*file_srgb_intent = (int)info_ptr->srgb_intent;
|
|
|
|
return (PNG_INFO_sRGB);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_iCCP_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
|
|
|
|
png_charpp name, int *compression_type,
|
|
|
|
png_charpp profile, png_uint_32 *proflen)
|
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "iCCP");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
|
|
|
|
&& name != NULL && profile != NULL && proflen != NULL)
|
|
|
|
{
|
|
|
|
*name = info_ptr->iccp_name;
|
|
|
|
*profile = info_ptr->iccp_profile;
|
2009-11-10 17:39:31 -08:00
|
|
|
/* Compression_type is a dummy so the API won't have to change
|
|
|
|
* if we introduce multiple compression types later.
|
|
|
|
*/
|
2007-03-22 10:30:00 -07:00
|
|
|
*proflen = (int)info_ptr->iccp_proflen;
|
|
|
|
*compression_type = (int)info_ptr->iccp_compression;
|
|
|
|
return (PNG_INFO_iCCP);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_sPLT_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
|
|
|
|
png_sPLT_tpp spalettes)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
|
2007-11-06 20:24:14 -08:00
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
*spalettes = info_ptr->splt_palettes;
|
2007-11-06 20:24:14 -08:00
|
|
|
return ((png_uint_32)info_ptr->splt_palettes_num);
|
|
|
|
}
|
|
|
|
return (0);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_hIST_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
|
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "hIST");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
|
|
|
|
&& hist != NULL)
|
|
|
|
{
|
|
|
|
*hist = info_ptr->hist;
|
|
|
|
return (PNG_INFO_hIST);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_IHDR(png_structp png_ptr, png_infop 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)
|
|
|
|
|
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "IHDR");
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
|
|
|
|
height == NULL || bit_depth == NULL || color_type == NULL)
|
|
|
|
return (0);
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
*width = info_ptr->width;
|
|
|
|
*height = info_ptr->height;
|
|
|
|
*bit_depth = info_ptr->bit_depth;
|
|
|
|
*color_type = info_ptr->color_type;
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
if (compression_type != NULL)
|
|
|
|
*compression_type = info_ptr->compression_type;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
if (filter_type != NULL)
|
|
|
|
*filter_type = info_ptr->filter_type;
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
if (interlace_type != NULL)
|
|
|
|
*interlace_type = info_ptr->interlace_type;
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2010-01-05 13:46:26 -08: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-11-10 17:39:31 -08:00
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
return (1);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_oFFs_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
|
|
|
|
png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
|
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "oFFs");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
|
|
|
|
&& offset_x != NULL && offset_y != NULL && unit_type != NULL)
|
|
|
|
{
|
|
|
|
*offset_x = info_ptr->x_offset;
|
|
|
|
*offset_y = info_ptr->y_offset;
|
|
|
|
*unit_type = (int)info_ptr->offset_unit_type;
|
|
|
|
return (PNG_INFO_oFFs);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_pCAL_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
|
|
|
|
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
|
|
|
|
png_charp *units, png_charpp *params)
|
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "pCAL");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
|
2009-11-10 17:39:31 -08:00
|
|
|
&& purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
|
|
|
|
nparams != NULL && units != NULL && params != NULL)
|
2007-03-22 10:30:00 -07: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);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_sCAL_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
|
|
|
|
int *unit, double *width, double *height)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL &&
|
2009-11-10 17:39:31 -08:00
|
|
|
(info_ptr->valid & PNG_INFO_sCAL))
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
*unit = info_ptr->scal_unit;
|
|
|
|
*width = info_ptr->scal_pixel_width;
|
|
|
|
*height = info_ptr->scal_pixel_height;
|
|
|
|
return (PNG_INFO_sCAL);
|
|
|
|
}
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
|
|
|
int *unit, png_charpp width, png_charpp height)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL &&
|
2009-11-10 17:39:31 -08:00
|
|
|
(info_ptr->valid & PNG_INFO_sCAL))
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
*unit = info_ptr->scal_unit;
|
|
|
|
*width = info_ptr->scal_s_width;
|
|
|
|
*height = info_ptr->scal_s_height;
|
|
|
|
return (PNG_INFO_sCAL);
|
|
|
|
}
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_pHYs_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
|
|
|
|
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
|
|
|
|
{
|
|
|
|
png_uint_32 retval = 0;
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "pHYs");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL &&
|
|
|
|
(info_ptr->valid & PNG_INFO_pHYs))
|
|
|
|
{
|
|
|
|
if (res_x != NULL)
|
|
|
|
{
|
|
|
|
*res_x = info_ptr->x_pixels_per_unit;
|
|
|
|
retval |= PNG_INFO_pHYs;
|
|
|
|
}
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (res_y != NULL)
|
|
|
|
{
|
|
|
|
*res_y = info_ptr->y_pixels_per_unit;
|
|
|
|
retval |= PNG_INFO_pHYs;
|
|
|
|
}
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (unit_type != NULL)
|
|
|
|
{
|
|
|
|
*unit_type = (int)info_ptr->phys_unit_type;
|
|
|
|
retval |= PNG_INFO_pHYs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (retval);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
|
|
|
|
int *num_palette)
|
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "PLTE");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
|
|
|
|
&& palette != NULL)
|
|
|
|
{
|
|
|
|
*palette = info_ptr->palette;
|
|
|
|
*num_palette = info_ptr->num_palette;
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug1(3, "num_palette = %d", *num_palette);
|
2007-03-22 10:30:00 -07:00
|
|
|
return (PNG_INFO_PLTE);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_sBIT_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
|
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "sBIT");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
|
|
|
|
&& sig_bit != NULL)
|
|
|
|
{
|
|
|
|
*sig_bit = &(info_ptr->sig_bit);
|
|
|
|
return (PNG_INFO_sBIT);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_TEXT_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
|
|
|
|
int *num_text)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug1(1, "in %s retrieval function",
|
2007-03-22 10:30:00 -07:00
|
|
|
(png_ptr->chunk_name[0] == '\0' ? "text"
|
|
|
|
: (png_const_charp)png_ptr->chunk_name));
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (text_ptr != NULL)
|
|
|
|
*text_ptr = info_ptr->text;
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (num_text != NULL)
|
|
|
|
*num_text = info_ptr->num_text;
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return ((png_uint_32)info_ptr->num_text);
|
|
|
|
}
|
|
|
|
if (num_text != NULL)
|
|
|
|
*num_text = 0;
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_tIME_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
|
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "tIME");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
|
|
|
|
&& mod_time != NULL)
|
|
|
|
{
|
|
|
|
*mod_time = &(info_ptr->mod_time);
|
|
|
|
return (PNG_INFO_tIME);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_tRNS_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
|
2010-01-05 13:46:26 -08:00
|
|
|
png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
png_uint_32 retval = 0;
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "tRNS");
|
2010-01-05 13:46:26 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
if (trans_alpha != NULL)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
*trans_alpha = info_ptr->trans_alpha;
|
2007-03-22 10:30:00 -07:00
|
|
|
retval |= PNG_INFO_tRNS;
|
|
|
|
}
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
if (trans_color != NULL)
|
|
|
|
*trans_color = &(info_ptr->trans_color);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
|
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
if (trans_color != NULL)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
*trans_color = &(info_ptr->trans_color);
|
2007-03-22 10:30:00 -07:00
|
|
|
retval |= PNG_INFO_tRNS;
|
|
|
|
}
|
2009-11-10 17:39:31 -08:00
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
if (trans_alpha != NULL)
|
|
|
|
*trans_alpha = NULL;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2008-09-10 13:56:22 -07:00
|
|
|
if (num_trans != NULL)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
*num_trans = info_ptr->num_trans;
|
|
|
|
retval |= PNG_INFO_tRNS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (retval);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(PNG_APNG_SUPPORTED)
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_acTL(png_structp png_ptr, png_infop info_ptr,
|
2007-04-19 13:40:53 -07:00
|
|
|
png_uint_32 *num_frames, png_uint_32 *num_plays)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "acTL");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL &&
|
|
|
|
(info_ptr->valid & PNG_INFO_acTL) &&
|
2007-04-19 13:40:53 -07:00
|
|
|
num_frames != NULL && num_plays != NULL)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
*num_frames = info_ptr->num_frames;
|
2007-04-19 13:40:53 -07:00
|
|
|
*num_plays = info_ptr->num_plays;
|
2007-03-22 10:30:00 -07:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_num_frames(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug(1, "in png_get_num_frames()");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return (info_ptr->num_frames);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_uint_32 PNGAPI
|
2007-04-19 13:40:53 -07:00
|
|
|
png_get_num_plays(png_structp png_ptr, png_infop info_ptr)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug(1, "in png_get_num_plays()");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
2007-04-19 13:40:53 -07:00
|
|
|
return (info_ptr->num_plays);
|
2007-03-22 10:30:00 -07:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
|
|
|
|
png_uint_32 *width, png_uint_32 *height,
|
|
|
|
png_uint_32 *x_offset, png_uint_32 *y_offset,
|
|
|
|
png_uint_16 *delay_num, png_uint_16 *delay_den,
|
2007-03-22 16:35:51 -07:00
|
|
|
png_byte *dispose_op, png_byte *blend_op)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug1(1, "in %s retrieval function", "fcTL");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL &&
|
|
|
|
(info_ptr->valid & PNG_INFO_fcTL) &&
|
|
|
|
width != NULL && height != NULL &&
|
|
|
|
x_offset != NULL && x_offset != NULL &&
|
2007-03-22 16:35:51 -07:00
|
|
|
delay_num != NULL && delay_den != NULL &&
|
|
|
|
dispose_op != NULL && blend_op != NULL)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
*width = info_ptr->next_frame_width;
|
|
|
|
*height = info_ptr->next_frame_height;
|
|
|
|
*x_offset = info_ptr->next_frame_x_offset;
|
|
|
|
*y_offset = info_ptr->next_frame_y_offset;
|
|
|
|
*delay_num = info_ptr->next_frame_delay_num;
|
|
|
|
*delay_den = info_ptr->next_frame_delay_den;
|
2007-03-22 16:35:51 -07:00
|
|
|
*dispose_op = info_ptr->next_frame_dispose_op;
|
|
|
|
*blend_op = info_ptr->next_frame_blend_op;
|
2007-03-22 10:30:00 -07:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_next_frame_width(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug(1, "in png_get_next_frame_width()");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return (info_ptr->next_frame_width);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_next_frame_height(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug(1, "in png_get_next_frame_height()");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return (info_ptr->next_frame_height);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_next_frame_x_offset(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug(1, "in png_get_next_frame_x_offset()");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return (info_ptr->next_frame_x_offset);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_next_frame_y_offset(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug(1, "in png_get_next_frame_y_offset()");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return (info_ptr->next_frame_y_offset);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_uint_16 PNGAPI
|
|
|
|
png_get_next_frame_delay_num(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug(1, "in png_get_next_frame_delay_num()");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return (info_ptr->next_frame_delay_num);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_uint_16 PNGAPI
|
|
|
|
png_get_next_frame_delay_den(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug(1, "in png_get_next_frame_delay_den()");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return (info_ptr->next_frame_delay_den);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_byte PNGAPI
|
2007-03-22 16:35:51 -07:00
|
|
|
png_get_next_frame_dispose_op(png_structp png_ptr, png_infop info_ptr)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug(1, "in png_get_next_frame_dispose_op()");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
2007-03-22 16:35:51 -07:00
|
|
|
return (info_ptr->next_frame_dispose_op);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_byte PNGAPI
|
|
|
|
png_get_next_frame_blend_op(png_structp png_ptr, png_infop info_ptr)
|
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug(1, "in png_get_next_frame_blend_op()");
|
2007-03-22 16:35:51 -07:00
|
|
|
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL)
|
|
|
|
return (info_ptr->next_frame_blend_op);
|
2007-03-22 10:30:00 -07:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_byte PNGAPI
|
2007-04-19 13:40:53 -07:00
|
|
|
png_get_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-12-22 15:40:01 -08:00
|
|
|
png_debug(1, "in png_first_frame_is_hidden()");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-04-19 13:40:53 -07:00
|
|
|
if (png_ptr != NULL)
|
2007-11-06 20:24:14 -08:00
|
|
|
return (png_byte)(png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* PNG_APNG_SUPPORTED */
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
png_uint_32 PNGAPI
|
|
|
|
png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
|
|
|
|
png_unknown_chunkpp unknowns)
|
|
|
|
{
|
|
|
|
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
|
2007-11-06 20:24:14 -08:00
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
*unknowns = info_ptr->unknown_chunks;
|
2007-11-06 20:24:14 -08:00
|
|
|
return ((png_uint_32)info_ptr->unknown_chunks_num);
|
|
|
|
}
|
|
|
|
return (0);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
png_byte PNGAPI
|
|
|
|
png_get_rgb_to_gray_status (png_structp png_ptr)
|
|
|
|
{
|
|
|
|
return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_USER_CHUNKS_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
png_voidp PNGAPI
|
|
|
|
png_get_user_chunk_ptr(png_structp png_ptr)
|
|
|
|
{
|
|
|
|
return (png_ptr? png_ptr->user_chunk_ptr : NULL);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
png_size_t PNGAPI
|
2007-03-22 10:30:00 -07:00
|
|
|
png_get_compression_buffer_size(png_structp png_ptr)
|
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
return (png_ptr ? png_ptr->zbuf_size : 0L);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
2010-03-09 10:22:44 -08:00
|
|
|
/* These functions were added to libpng 1.2.6 and were enabled
|
|
|
|
* by default in libpng-1.4.0 */
|
2007-03-22 10:30:00 -07:00
|
|
|
png_uint_32 PNGAPI
|
2010-01-05 13:46:26 -08:00
|
|
|
png_get_user_width_max (png_structp png_ptr)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
return (png_ptr? png_ptr->user_width_max : 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
png_uint_32 PNGAPI
|
2010-01-05 13:46:26 -08:00
|
|
|
png_get_user_height_max (png_structp png_ptr)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
return (png_ptr? png_ptr->user_height_max : 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-03-09 10:22:44 -08:00
|
|
|
|
2010-01-05 13:46:26 -08:00
|
|
|
/* This function was added to libpng 1.4.0 */
|
2007-03-22 10:30:00 -07:00
|
|
|
png_uint_32 PNGAPI
|
2010-01-05 13:46:26 -08:00
|
|
|
png_get_chunk_cache_max (png_structp png_ptr)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-03-09 10:22:44 -08:00
|
|
|
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_structp png_ptr)
|
|
|
|
{
|
|
|
|
return (png_ptr?
|
|
|
|
png_ptr->user_chunk_malloc_max : 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-01-05 13:46:26 -08:00
|
|
|
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-03-09 10:22:44 -08:00
|
|
|
/* These functions were added to libpng 1.4.0 */
|
2010-01-05 13:46:26 -08:00
|
|
|
#ifdef PNG_IO_STATE_SUPPORTED
|
2007-03-22 10:30:00 -07:00
|
|
|
png_uint_32 PNGAPI
|
2010-01-05 13:46:26 -08:00
|
|
|
png_get_io_state (png_structp png_ptr)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
return png_ptr->io_state;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-01-05 13:46:26 -08:00
|
|
|
|
|
|
|
png_bytep PNGAPI
|
|
|
|
png_get_io_chunk_name (png_structp png_ptr)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-01-05 13:46:26 -08:00
|
|
|
return png_ptr->chunk_name;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-01-05 13:46:26 -08:00
|
|
|
#endif /* ?PNG_IO_STATE_SUPPORTED */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|