blob: c6a7dbd190df6a109e81bc237c6dd8f4274fc018 [file] [log] [blame]
Andreas Dilger47a0c421997-05-16 02:46:07 -05001
2/* pngget.c - retrieval of values from info struct
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06003 *
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -05004 * Last changed in libpng 1.4.0 [August 15, 2009]
Glenn Randers-Pehrson79134c62009-02-14 10:32:18 -06005 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05006 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
Glenn Randers-Pehrson3e61d792009-06-24 09:31:28 -05008 *
Glenn Randers-Pehrsonbfbf8652009-06-26 21:46:52 -05009 * This code is released under the libpng license.
Glenn Randers-Pehrsonc332bbc2009-06-25 13:43:50 -050010 * For conditions of distribution and use, see the disclaimer
Glenn Randers-Pehrson037023b2009-06-24 10:27:36 -050011 * and license in png.h
Glenn Randers-Pehrson3e61d792009-06-24 09:31:28 -050012 *
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060013 */
Andreas Dilger47a0c421997-05-16 02:46:07 -050014
Andreas Dilger47a0c421997-05-16 02:46:07 -050015#include "png.h"
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -060016#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -050017#include "pngpriv.h"
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -060018
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050019png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -050020png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
21{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060022 if (png_ptr != NULL && info_ptr != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -050023 return(info_ptr->valid & flag);
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -050024
Andreas Dilger47a0c421997-05-16 02:46:07 -050025 else
26 return(0);
27}
28
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -050029png_size_t PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -050030png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
31{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060032 if (png_ptr != NULL && info_ptr != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -050033 return(info_ptr->rowbytes);
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -050034
Andreas Dilger47a0c421997-05-16 02:46:07 -050035 else
36 return(0);
37}
38
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -060039#if defined(PNG_INFO_IMAGE_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050040png_bytepp PNGAPI
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -060041png_get_rows(png_structp png_ptr, png_infop info_ptr)
42{
43 if (png_ptr != NULL && info_ptr != NULL)
44 return(info_ptr->row_pointers);
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -050045
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -060046 else
47 return(0);
48}
49#endif
50
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060051#ifdef PNG_EASY_ACCESS_SUPPORTED
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -050052/* Easy access to info, added in libpng-0.99 */
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050053png_uint_32 PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060054png_get_image_width(png_structp png_ptr, png_infop info_ptr)
55{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060056 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060057 return info_ptr->width;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -050058
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060059 return (0);
60}
61
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050062png_uint_32 PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060063png_get_image_height(png_structp png_ptr, png_infop info_ptr)
64{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060065 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060066 return info_ptr->height;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -050067
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060068 return (0);
69}
70
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050071png_byte PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060072png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
73{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060074 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060075 return info_ptr->bit_depth;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -050076
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060077 return (0);
78}
79
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050080png_byte PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060081png_get_color_type(png_structp png_ptr, png_infop info_ptr)
82{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060083 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060084 return info_ptr->color_type;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -050085
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060086 return (0);
87}
88
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050089png_byte PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060090png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
91{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060092 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060093 return info_ptr->filter_type;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -050094
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060095 return (0);
96}
97
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050098png_byte PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060099png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
100{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600101 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600102 return info_ptr->interlace_type;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500103
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600104 return (0);
105}
106
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500107png_byte PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600108png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
109{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600110 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600111 return info_ptr->compression_type;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500112
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600113 return (0);
114}
115
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500116png_uint_32 PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600117png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
118{
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500119 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600120#if defined(PNG_pHYs_SUPPORTED)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500121 if (info_ptr->valid & PNG_INFO_pHYs)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600122 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500123 png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500124
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500125 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600126 return (0);
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500127
Glenn Randers-Pehrsond8eb62f2009-05-30 20:19:20 -0500128 else
129 return (info_ptr->x_pixels_per_unit);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600130 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500131#else
132 return (0);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600133#endif
134 return (0);
135}
136
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500137png_uint_32 PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600138png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
139{
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500140 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600141#if defined(PNG_pHYs_SUPPORTED)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500142 if (info_ptr->valid & PNG_INFO_pHYs)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600143 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500144 png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500145
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500146 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600147 return (0);
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500148
Glenn Randers-Pehrsond8eb62f2009-05-30 20:19:20 -0500149 else
150 return (info_ptr->y_pixels_per_unit);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600151 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500152#else
153 return (0);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600154#endif
155 return (0);
156}
157
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500158png_uint_32 PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600159png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
160{
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500161 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600162#if defined(PNG_pHYs_SUPPORTED)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500163 if (info_ptr->valid & PNG_INFO_pHYs)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600164 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500165 png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500166
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500167 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600168 info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600169 return (0);
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500170
Glenn Randers-Pehrsond8eb62f2009-05-30 20:19:20 -0500171 else
172 return (info_ptr->x_pixels_per_unit);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600173 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500174#else
175 return (0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600176#endif
177 return (0);
178}
179
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600180#ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500181float PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600182png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
183 {
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500184 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600185#if defined(PNG_pHYs_SUPPORTED)
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500186
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500187 if (info_ptr->valid & PNG_INFO_pHYs)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600188 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500189 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500190
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600191 if (info_ptr->x_pixels_per_unit == 0)
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600192 return ((float)0.0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600193 else
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500194 return ((float)((float)info_ptr->y_pixels_per_unit
195 /(float)info_ptr->x_pixels_per_unit));
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600196 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500197#else
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500198 return (0.0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600199#endif
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500200 return ((float)0.0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600201}
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600202#endif
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600203
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500204png_int_32 PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600205png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
206{
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500207 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600208#if defined(PNG_oFFs_SUPPORTED)
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500209
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500210 if (info_ptr->valid & PNG_INFO_oFFs)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600211 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500212 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500213
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500214 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600215 return (0);
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500216
Glenn Randers-Pehrsond8eb62f2009-05-30 20:19:20 -0500217 else
218 return (info_ptr->x_offset);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600219 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500220#else
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500221 return (0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600222#endif
223 return (0);
224}
225
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500226png_int_32 PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600227png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
228{
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500229 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500230
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600231#if defined(PNG_oFFs_SUPPORTED)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500232 if (info_ptr->valid & PNG_INFO_oFFs)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600233 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500234 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500235
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500236 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600237 return (0);
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500238
Glenn Randers-Pehrsond8eb62f2009-05-30 20:19:20 -0500239 else
240 return (info_ptr->y_offset);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600241 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500242#else
243 return (0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600244#endif
245 return (0);
246}
247
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500248png_int_32 PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600249png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
250{
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500251 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500252
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600253#if defined(PNG_oFFs_SUPPORTED)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500254 if (info_ptr->valid & PNG_INFO_oFFs)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600255 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500256 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500257
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500258 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600259 return (0);
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500260
Glenn Randers-Pehrsond8eb62f2009-05-30 20:19:20 -0500261 else
262 return (info_ptr->x_offset);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600263 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500264#else
265 return (0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600266#endif
267 return (0);
268}
269
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500270png_int_32 PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600271png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
272{
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500273 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500274
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600275#if defined(PNG_oFFs_SUPPORTED)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500276 if (info_ptr->valid & PNG_INFO_oFFs)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600277 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500278 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500279
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500280 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600281 return (0);
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500282
Glenn Randers-Pehrsond8eb62f2009-05-30 20:19:20 -0500283 else
284 return (info_ptr->y_offset);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600285 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500286#else
287 return (0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600288#endif
289 return (0);
290}
291
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600292#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500293png_uint_32 PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600294png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
295{
296 return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500297 *.0254 +.5));
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600298}
299
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500300png_uint_32 PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600301png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
302{
303 return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500304 *.0254 +.5));
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600305}
306
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500307png_uint_32 PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600308png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
309{
310 return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500311 *.0254 +.5));
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600312}
313
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500314float PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600315png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
316{
317 return ((float)png_get_x_offset_microns(png_ptr, info_ptr)
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600318 *.00003937);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600319}
320
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500321float PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600322png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
323{
324 return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500325 *.00003937);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600326}
327
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500328#if defined(PNG_pHYs_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500329png_uint_32 PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600330png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
331 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
332{
333 png_uint_32 retval = 0;
334
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600335 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600336 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500337 png_debug1(1, "in %s retrieval function", "pHYs");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500338
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600339 if (res_x != NULL)
340 {
341 *res_x = info_ptr->x_pixels_per_unit;
342 retval |= PNG_INFO_pHYs;
343 }
344 if (res_y != NULL)
345 {
346 *res_y = info_ptr->y_pixels_per_unit;
347 retval |= PNG_INFO_pHYs;
348 }
349 if (unit_type != NULL)
350 {
351 *unit_type = (int)info_ptr->phys_unit_type;
352 retval |= PNG_INFO_pHYs;
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500353 if (*unit_type == 1)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600354 {
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600355 if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
356 if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600357 }
358 }
359 }
360 return (retval);
361}
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500362#endif /* PNG_pHYs_SUPPORTED */
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600363#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600364
365/* png_get_channels really belongs in here, too, but it's been around longer */
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500366
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600367#endif /* PNG_EASY_ACCESS_SUPPORTED */
368
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500369png_byte PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500370png_get_channels(png_structp png_ptr, png_infop info_ptr)
371{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600372 if (png_ptr != NULL && info_ptr != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500373 return(info_ptr->channels);
374 else
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600375 return (0);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500376}
377
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500378png_bytep PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500379png_get_signature(png_structp png_ptr, png_infop info_ptr)
380{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600381 if (png_ptr != NULL && info_ptr != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500382 return(info_ptr->signature);
383 else
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600384 return (NULL);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500385}
386
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500387#if defined(PNG_bKGD_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500388png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500389png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
390 png_color_16p *background)
391{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600392 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
393 && background != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500394 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500395 png_debug1(1, "in %s retrieval function", "bKGD");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500396
Andreas Dilger47a0c421997-05-16 02:46:07 -0500397 *background = &(info_ptr->background);
398 return (PNG_INFO_bKGD);
399 }
400 return (0);
401}
402#endif
403
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500404#if defined(PNG_cHRM_SUPPORTED)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600405#ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500406png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500407png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
408 double *white_x, double *white_y, double *red_x, double *red_y,
409 double *green_x, double *green_y, double *blue_x, double *blue_y)
410{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600411 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
Andreas Dilger47a0c421997-05-16 02:46:07 -0500412 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500413 png_debug1(1, "in %s retrieval function", "cHRM");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500414
Andreas Dilger47a0c421997-05-16 02:46:07 -0500415 if (white_x != NULL)
416 *white_x = (double)info_ptr->x_white;
417 if (white_y != NULL)
418 *white_y = (double)info_ptr->y_white;
419 if (red_x != NULL)
420 *red_x = (double)info_ptr->x_red;
421 if (red_y != NULL)
422 *red_y = (double)info_ptr->y_red;
423 if (green_x != NULL)
424 *green_x = (double)info_ptr->x_green;
425 if (green_y != NULL)
426 *green_y = (double)info_ptr->y_green;
427 if (blue_x != NULL)
428 *blue_x = (double)info_ptr->x_blue;
429 if (blue_y != NULL)
430 *blue_y = (double)info_ptr->y_blue;
431 return (PNG_INFO_cHRM);
432 }
433 return (0);
434}
435#endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600436#ifdef PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500437png_uint_32 PNGAPI
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600438png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600439 png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
440 png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
441 png_fixed_point *blue_x, png_fixed_point *blue_y)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600442{
443 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
444 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500445 png_debug1(1, "in %s retrieval function", "cHRM");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500446
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600447 if (white_x != NULL)
448 *white_x = info_ptr->int_x_white;
449 if (white_y != NULL)
450 *white_y = info_ptr->int_y_white;
451 if (red_x != NULL)
452 *red_x = info_ptr->int_x_red;
453 if (red_y != NULL)
454 *red_y = info_ptr->int_y_red;
455 if (green_x != NULL)
456 *green_x = info_ptr->int_x_green;
457 if (green_y != NULL)
458 *green_y = info_ptr->int_y_green;
459 if (blue_x != NULL)
460 *blue_x = info_ptr->int_x_blue;
461 if (blue_y != NULL)
462 *blue_y = info_ptr->int_y_blue;
463 return (PNG_INFO_cHRM);
464 }
465 return (0);
466}
467#endif
468#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500469
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500470#if defined(PNG_gAMA_SUPPORTED)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600471#ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500472png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500473png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
474{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600475 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
476 && file_gamma != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500477 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500478 png_debug1(1, "in %s retrieval function", "gAMA");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500479
Andreas Dilger47a0c421997-05-16 02:46:07 -0500480 *file_gamma = (double)info_ptr->gamma;
481 return (PNG_INFO_gAMA);
482 }
483 return (0);
484}
485#endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500486#ifdef PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500487png_uint_32 PNGAPI
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600488png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600489 png_fixed_point *int_file_gamma)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600490{
491 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
492 && int_file_gamma != NULL)
493 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500494 png_debug1(1, "in %s retrieval function", "gAMA");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500495
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600496 *int_file_gamma = info_ptr->int_gamma;
497 return (PNG_INFO_gAMA);
498 }
499 return (0);
500}
501#endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500502#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500503
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500504#if defined(PNG_sRGB_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500505png_uint_32 PNGAPI
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600506png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600507{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600508 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
509 && file_srgb_intent != NULL)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600510 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500511 png_debug1(1, "in %s retrieval function", "sRGB");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500512
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600513 *file_srgb_intent = (int)info_ptr->srgb_intent;
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600514 return (PNG_INFO_sRGB);
515 }
516 return (0);
517}
518#endif
519
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500520#if defined(PNG_iCCP_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500521png_uint_32 PNGAPI
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600522png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
523 png_charpp name, int *compression_type,
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600524 png_charpp profile, png_uint_32 *proflen)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600525{
526 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
527 && name != NULL && profile != NULL && proflen != NULL)
528 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500529 png_debug1(1, "in %s retrieval function", "iCCP");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500530
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600531 *name = info_ptr->iccp_name;
532 *profile = info_ptr->iccp_profile;
Glenn Randers-Pehrson4bb4d012009-05-20 12:45:29 -0500533 /* Compression_type is a dummy so the API won't have to change
534 * if we introduce multiple compression types later.
535 */
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600536 *proflen = (int)info_ptr->iccp_proflen;
537 *compression_type = (int)info_ptr->iccp_compression;
538 return (PNG_INFO_iCCP);
539 }
540 return (0);
541}
542#endif
543
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500544#if defined(PNG_sPLT_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500545png_uint_32 PNGAPI
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600546png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -0600547 png_sPLT_tpp spalettes)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600548{
549 if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500550 {
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600551 *spalettes = info_ptr->splt_palettes;
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500552 return ((png_uint_32)info_ptr->splt_palettes_num);
553 }
554 return (0);
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600555}
556#endif
557
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500558#if defined(PNG_hIST_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500559png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500560png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
561{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600562 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
563 && hist != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500564 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500565 png_debug1(1, "in %s retrieval function", "hIST");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500566
Andreas Dilger47a0c421997-05-16 02:46:07 -0500567 *hist = info_ptr->hist;
568 return (PNG_INFO_hIST);
569 }
570 return (0);
571}
572#endif
573
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500574png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500575png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
576 png_uint_32 *width, png_uint_32 *height, int *bit_depth,
577 int *color_type, int *interlace_type, int *compression_type,
578 int *filter_type)
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600579
Andreas Dilger47a0c421997-05-16 02:46:07 -0500580{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600581 if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
Andreas Dilger47a0c421997-05-16 02:46:07 -0500582 bit_depth != NULL && color_type != NULL)
583 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500584 png_debug1(1, "in %s retrieval function", "IHDR");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500585
Andreas Dilger47a0c421997-05-16 02:46:07 -0500586 *width = info_ptr->width;
587 *height = info_ptr->height;
588 *bit_depth = info_ptr->bit_depth;
Glenn Randers-Pehrson73d57cb2002-03-25 18:49:08 -0600589 if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16)
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500590 png_error(png_ptr, "Invalid bit depth");
591
Andreas Dilger47a0c421997-05-16 02:46:07 -0500592 *color_type = info_ptr->color_type;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500593
Glenn Randers-Pehrson73d57cb2002-03-25 18:49:08 -0600594 if (info_ptr->color_type > 6)
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500595 png_error(png_ptr, "Invalid color type");
596
Andreas Dilger47a0c421997-05-16 02:46:07 -0500597 if (compression_type != NULL)
598 *compression_type = info_ptr->compression_type;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500599
Andreas Dilger47a0c421997-05-16 02:46:07 -0500600 if (filter_type != NULL)
601 *filter_type = info_ptr->filter_type;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500602
Andreas Dilger47a0c421997-05-16 02:46:07 -0500603 if (interlace_type != NULL)
604 *interlace_type = info_ptr->interlace_type;
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600605
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500606 /* Check for potential overflow of rowbytes */
Glenn Randers-Pehrson16e11662004-11-01 14:13:40 -0600607 if (*width == 0 || *width > PNG_UINT_31_MAX)
Glenn Randers-Pehrsonc6de22d2002-02-23 18:55:25 -0600608 png_error(png_ptr, "Invalid image width");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500609
Glenn Randers-Pehrson16e11662004-11-01 14:13:40 -0600610 if (*height == 0 || *height > PNG_UINT_31_MAX)
Glenn Randers-Pehrsonc6de22d2002-02-23 18:55:25 -0600611 png_error(png_ptr, "Invalid image height");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500612
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500613 if (info_ptr->width > (PNG_UINT_32_MAX
614 >> 3) /* 8-byte RGBA pixels */
615 - 64 /* bigrowbuf hack */
616 - 1 /* filter byte */
617 - 7*8 /* rounding of width to multiple of 8 pixels */
618 - 8) /* extra max_pixel_depth pad */
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600619 {
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500620 png_warning(png_ptr,
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500621 "Width too large for libpng to process image data");
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600622 }
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500623
Andreas Dilger47a0c421997-05-16 02:46:07 -0500624 return (1);
625 }
626 return (0);
627}
628
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500629#if defined(PNG_oFFs_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500630png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500631png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600632 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500633{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600634 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
635 && offset_x != NULL && offset_y != NULL && unit_type != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500636 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500637 png_debug1(1, "in %s retrieval function", "oFFs");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500638
Andreas Dilger47a0c421997-05-16 02:46:07 -0500639 *offset_x = info_ptr->x_offset;
640 *offset_y = info_ptr->y_offset;
641 *unit_type = (int)info_ptr->offset_unit_type;
642 return (PNG_INFO_oFFs);
643 }
644 return (0);
645}
646#endif
647
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500648#if defined(PNG_pCAL_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500649png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500650png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
651 png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
652 png_charp *units, png_charpp *params)
653{
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600654 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500655 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
656 nparams != NULL && units != NULL && params != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500657 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500658 png_debug1(1, "in %s retrieval function", "pCAL");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500659
Andreas Dilger47a0c421997-05-16 02:46:07 -0500660 *purpose = info_ptr->pcal_purpose;
661 *X0 = info_ptr->pcal_X0;
662 *X1 = info_ptr->pcal_X1;
663 *type = (int)info_ptr->pcal_type;
664 *nparams = (int)info_ptr->pcal_nparams;
665 *units = info_ptr->pcal_units;
666 *params = info_ptr->pcal_params;
667 return (PNG_INFO_pCAL);
668 }
669 return (0);
670}
671#endif
672
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500673#if defined(PNG_sCAL_SUPPORTED)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600674#ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500675png_uint_32 PNGAPI
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600676png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600677 int *unit, double *width, double *height)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600678{
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600679 if (png_ptr != NULL && info_ptr != NULL &&
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500680 (info_ptr->valid & PNG_INFO_sCAL))
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600681 {
682 *unit = info_ptr->scal_unit;
683 *width = info_ptr->scal_pixel_width;
684 *height = info_ptr->scal_pixel_height;
685 return (PNG_INFO_sCAL);
686 }
687 return(0);
688}
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600689#else
690#ifdef PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500691png_uint_32 PNGAPI
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600692png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600693 int *unit, png_charpp width, png_charpp height)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600694{
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600695 if (png_ptr != NULL && info_ptr != NULL &&
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500696 (info_ptr->valid & PNG_INFO_sCAL))
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600697 {
698 *unit = info_ptr->scal_unit;
699 *width = info_ptr->scal_s_width;
700 *height = info_ptr->scal_s_height;
701 return (PNG_INFO_sCAL);
702 }
703 return(0);
704}
705#endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600706#endif
707#endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600708
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500709#if defined(PNG_pHYs_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500710png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500711png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
712 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
713{
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600714 png_uint_32 retval = 0;
715
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600716 if (png_ptr != NULL && info_ptr != NULL &&
717 (info_ptr->valid & PNG_INFO_pHYs))
Andreas Dilger47a0c421997-05-16 02:46:07 -0500718 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500719 png_debug1(1, "in %s retrieval function", "pHYs");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500720
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600721 if (res_x != NULL)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600722 {
723 *res_x = info_ptr->x_pixels_per_unit;
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600724 retval |= PNG_INFO_pHYs;
725 }
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500726
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600727 if (res_y != NULL)
728 {
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600729 *res_y = info_ptr->y_pixels_per_unit;
730 retval |= PNG_INFO_pHYs;
731 }
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500732
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600733 if (unit_type != NULL)
734 {
735 *unit_type = (int)info_ptr->phys_unit_type;
736 retval |= PNG_INFO_pHYs;
737 }
Andreas Dilger47a0c421997-05-16 02:46:07 -0500738 }
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600739 return (retval);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500740}
741#endif
742
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500743png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500744png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
745 int *num_palette)
746{
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600747 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
748 && palette != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500749 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500750 png_debug1(1, "in %s retrieval function", "PLTE");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500751
Andreas Dilger47a0c421997-05-16 02:46:07 -0500752 *palette = info_ptr->palette;
753 *num_palette = info_ptr->num_palette;
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500754 png_debug1(3, "num_palette = %d", *num_palette);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500755 return (PNG_INFO_PLTE);
756 }
757 return (0);
758}
759
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500760#if defined(PNG_sBIT_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500761png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500762png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
763{
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600764 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
765 && sig_bit != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500766 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500767 png_debug1(1, "in %s retrieval function", "sBIT");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500768
Andreas Dilger47a0c421997-05-16 02:46:07 -0500769 *sig_bit = &(info_ptr->sig_bit);
770 return (PNG_INFO_sBIT);
771 }
772 return (0);
773}
774#endif
775
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500776#if defined(PNG_TEXT_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500777png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500778png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
779 int *num_text)
780{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600781 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500782 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500783 png_debug1(1, "in %s retrieval function",
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600784 (png_ptr->chunk_name[0] == '\0' ? "text"
785 : (png_const_charp)png_ptr->chunk_name));
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500786
Andreas Dilger47a0c421997-05-16 02:46:07 -0500787 if (text_ptr != NULL)
788 *text_ptr = info_ptr->text;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500789
Andreas Dilger47a0c421997-05-16 02:46:07 -0500790 if (num_text != NULL)
791 *num_text = info_ptr->num_text;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500792
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600793 return ((png_uint_32)info_ptr->num_text);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500794 }
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600795 if (num_text != NULL)
796 *num_text = 0;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500797 return(0);
798}
799#endif
800
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500801#if defined(PNG_tIME_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500802png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500803png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
804{
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600805 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
806 && mod_time != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500807 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500808 png_debug1(1, "in %s retrieval function", "tIME");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500809
Andreas Dilger47a0c421997-05-16 02:46:07 -0500810 *mod_time = &(info_ptr->mod_time);
811 return (PNG_INFO_tIME);
812 }
813 return (0);
814}
815#endif
816
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500817#if defined(PNG_tRNS_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500818png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500819png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson6abea752009-08-08 16:52:06 -0500820 png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500821{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600822 png_uint_32 retval = 0;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600823 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
Andreas Dilger47a0c421997-05-16 02:46:07 -0500824 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500825 png_debug1(1, "in %s retrieval function", "tRNS");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500826
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600827 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500828 {
Glenn Randers-Pehrson6abea752009-08-08 16:52:06 -0500829 if (trans_alpha != NULL)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600830 {
Glenn Randers-Pehrson6abea752009-08-08 16:52:06 -0500831 *trans_alpha = info_ptr->trans_alpha;
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600832 retval |= PNG_INFO_tRNS;
833 }
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500834
Glenn Randers-Pehrson56f63962008-10-06 10:16:17 -0500835 if (trans_color != NULL)
836 *trans_color = &(info_ptr->trans_color);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500837 }
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600838 else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500839 {
Glenn Randers-Pehrson56f63962008-10-06 10:16:17 -0500840 if (trans_color != NULL)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600841 {
Glenn Randers-Pehrson56f63962008-10-06 10:16:17 -0500842 *trans_color = &(info_ptr->trans_color);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600843 retval |= PNG_INFO_tRNS;
844 }
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500845
Glenn Randers-Pehrson6abea752009-08-08 16:52:06 -0500846 if (trans_alpha != NULL)
847 *trans_alpha = NULL;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500848 }
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500849 if (num_trans != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500850 {
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600851 *num_trans = info_ptr->num_trans;
852 retval |= PNG_INFO_tRNS;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500853 }
Andreas Dilger47a0c421997-05-16 02:46:07 -0500854 }
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600855 return (retval);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500856}
857#endif
858
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500859#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500860png_uint_32 PNGAPI
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600861png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
862 png_unknown_chunkpp unknowns)
863{
864 if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500865 {
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600866 *unknowns = info_ptr->unknown_chunks;
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500867 return ((png_uint_32)info_ptr->unknown_chunks_num);
868 }
869 return (0);
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600870}
871#endif
872
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600873#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500874png_byte PNGAPI
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600875png_get_rgb_to_gray_status (png_structp png_ptr)
876{
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600877 return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0);
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600878}
879#endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600880
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500881#if defined(PNG_USER_CHUNKS_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500882png_voidp PNGAPI
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600883png_get_user_chunk_ptr(png_structp png_ptr)
884{
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600885 return (png_ptr? png_ptr->user_chunk_ptr : NULL);
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600886}
887#endif
888
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -0500889#ifdef PNG_WRITE_SUPPORTED
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500890png_size_t PNGAPI
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -0500891png_get_compression_buffer_size(png_structp png_ptr)
892{
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500893 return (png_ptr ? png_ptr->zbuf_size : 0L);
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -0500894}
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -0500895#endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500896
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500897
898#ifdef PNG_SET_USER_LIMITS_SUPPORTED
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -0500899/* These functions were added to libpng 1.2.6 */
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500900png_uint_32 PNGAPI
901png_get_user_width_max (png_structp png_ptr)
902{
903 return (png_ptr? png_ptr->user_width_max : 0);
904}
905png_uint_32 PNGAPI
906png_get_user_height_max (png_structp png_ptr)
907{
908 return (png_ptr? png_ptr->user_height_max : 0);
909}
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -0500910/* This function was added to libpng 1.4.0 */
911png_uint_32 PNGAPI
912png_get_chunk_cache_max (png_structp png_ptr)
913{
914 return (png_ptr? png_ptr->user_chunk_cache_max? 0x7fffffffL :
915 png_ptr->user_chunk_cache_max - 1 : 0);
916}
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500917#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
Glenn Randers-Pehrsond60c8862009-06-15 21:56:14 -0500918
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500919#ifdef PNG_IO_STATE_SUPPORTED
920png_uint_32 PNGAPI
921png_get_io_state (png_structp png_ptr)
922{
923 return png_ptr->io_state;
924}
925
926png_bytep PNGAPI
927png_get_io_chunk_name (png_structp png_ptr)
928{
929 return png_ptr->chunk_name;
930}
931#endif /* ?PNG_IO_STATE_SUPPORTED */
932
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600933#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */