blob: 6d489f220ebf48b408660e15043ff9b4152487e8 [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-Pehrsonf24daf22010-05-06 09:44:04 -05004 * Last changed in libpng 1.4.1 [May 6, 2010]
Glenn Randers-Pehrsone69b55d2010-01-01 10:29:06 -06005 * Copyright (c) 1998-2010 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
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -050015#include "pngpriv.h"
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -060016
Glenn Randers-Pehrsonc3cd22b2010-03-08 21:10:25 -060017#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
18
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-Pehrsone26c0952009-09-23 11:22:08 -050039#ifdef 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-Pehrsone26c0952009-09-23 11:22:08 -0500120#ifdef 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-Pehrson16908a12010-03-06 07:34:28 -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
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600129 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-Pehrsone26c0952009-09-23 11:22:08 -0500141#ifdef 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-Pehrson16908a12010-03-06 07:34:28 -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
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600150 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-Pehrsone26c0952009-09-23 11:22:08 -0500162#ifdef 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-Pehrson16908a12010-03-06 07:34:28 -0600168 info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
169 return (0);
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500170
Glenn Randers-Pehrsond8eb62f2009-05-30 20:19:20 -0500171 else
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600172 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)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600183{
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500184 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500185#ifdef 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-Pehrsonb3ce3652009-08-15 21:47:03 -0500193
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600194 else
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500195 return ((float)((float)info_ptr->y_pixels_per_unit
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600196 /(float)info_ptr->x_pixels_per_unit));
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600197 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500198#else
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500199 return (0.0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600200#endif
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500201 return ((float)0.0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600202}
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600203#endif
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600204
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500205png_int_32 PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600206png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
207{
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500208 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500209#ifdef PNG_oFFs_SUPPORTED
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500210
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500211 if (info_ptr->valid & PNG_INFO_oFFs)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600212 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500213 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500214
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500215 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600216 return (0);
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500217
Glenn Randers-Pehrsond8eb62f2009-05-30 20:19:20 -0500218 else
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600219 return (info_ptr->x_offset);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600220 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500221#else
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500222 return (0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600223#endif
224 return (0);
225}
226
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500227png_int_32 PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600228png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
229{
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500230 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500231
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500232#ifdef PNG_oFFs_SUPPORTED
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500233 if (info_ptr->valid & PNG_INFO_oFFs)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600234 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500235 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500236
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500237 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600238 return (0);
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500239
Glenn Randers-Pehrsond8eb62f2009-05-30 20:19:20 -0500240 else
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600241 return (info_ptr->y_offset);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600242 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500243#else
244 return (0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600245#endif
246 return (0);
247}
248
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500249png_int_32 PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600250png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
251{
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500252 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500253
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500254#ifdef PNG_oFFs_SUPPORTED
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500255 if (info_ptr->valid & PNG_INFO_oFFs)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600256 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500257 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500258
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500259 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600260 return (0);
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500261
Glenn Randers-Pehrsond8eb62f2009-05-30 20:19:20 -0500262 else
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600263 return (info_ptr->x_offset);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600264 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500265#else
266 return (0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600267#endif
268 return (0);
269}
270
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500271png_int_32 PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600272png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
273{
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500274 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500275
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500276#ifdef PNG_oFFs_SUPPORTED
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500277 if (info_ptr->valid & PNG_INFO_oFFs)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600278 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500279 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500280
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500281 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600282 return (0);
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500283
Glenn Randers-Pehrsond8eb62f2009-05-30 20:19:20 -0500284 else
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600285 return (info_ptr->y_offset);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600286 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500287#else
288 return (0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600289#endif
290 return (0);
291}
292
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -0500293#if defined(PNG_INCH_CONVERSIONS_SUPPORTED) && \
294 defined(PNG_FLOATING_POINT_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500295png_uint_32 PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600296png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
297{
298 return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600299 *.0254 +.5));
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600300}
301
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500302png_uint_32 PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600303png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
304{
305 return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600306 *.0254 +.5));
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600307}
308
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500309png_uint_32 PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600310png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
311{
312 return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600313 *.0254 +.5));
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600314}
315
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500316float PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600317png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
318{
319 return ((float)png_get_x_offset_microns(png_ptr, info_ptr)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600320 *.00003937);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600321}
322
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500323float PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600324png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
325{
326 return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600327 *.00003937);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600328}
329
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500330#ifdef PNG_pHYs_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500331png_uint_32 PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600332png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600333 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600334{
335 png_uint_32 retval = 0;
336
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600337 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600338 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500339 png_debug1(1, "in %s retrieval function", "pHYs");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500340
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600341 if (res_x != NULL)
342 {
343 *res_x = info_ptr->x_pixels_per_unit;
344 retval |= PNG_INFO_pHYs;
345 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500346
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600347 if (res_y != NULL)
348 {
349 *res_y = info_ptr->y_pixels_per_unit;
350 retval |= PNG_INFO_pHYs;
351 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500352
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600353 if (unit_type != NULL)
354 {
355 *unit_type = (int)info_ptr->phys_unit_type;
356 retval |= PNG_INFO_pHYs;
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500357 if (*unit_type == 1)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600358 {
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600359 if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
360 if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600361 }
362 }
363 }
364 return (retval);
365}
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500366#endif /* PNG_pHYs_SUPPORTED */
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -0500367#endif /* PNG_INCH_CONVERSIONS_SUPPORTED && PNG_FLOATING_POINT_SUPPORTED */
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600368
369/* png_get_channels really belongs in here, too, but it's been around longer */
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500370
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600371#endif /* PNG_EASY_ACCESS_SUPPORTED */
372
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500373png_byte PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500374png_get_channels(png_structp png_ptr, png_infop info_ptr)
375{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600376 if (png_ptr != NULL && info_ptr != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500377 return(info_ptr->channels);
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500378
Andreas Dilger47a0c421997-05-16 02:46:07 -0500379 else
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600380 return (0);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500381}
382
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500383png_bytep PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500384png_get_signature(png_structp png_ptr, png_infop info_ptr)
385{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600386 if (png_ptr != NULL && info_ptr != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500387 return(info_ptr->signature);
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500388
Andreas Dilger47a0c421997-05-16 02:46:07 -0500389 else
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600390 return (NULL);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500391}
392
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500393#ifdef PNG_bKGD_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500394png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500395png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
396 png_color_16p *background)
397{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600398 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600399 && background != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500400 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500401 png_debug1(1, "in %s retrieval function", "bKGD");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500402
Andreas Dilger47a0c421997-05-16 02:46:07 -0500403 *background = &(info_ptr->background);
404 return (PNG_INFO_bKGD);
405 }
406 return (0);
407}
408#endif
409
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500410#ifdef PNG_cHRM_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600411#ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500412png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500413png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600414 double *white_x, double *white_y, double *red_x, double *red_y,
415 double *green_x, double *green_y, double *blue_x, double *blue_y)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500416{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600417 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
Andreas Dilger47a0c421997-05-16 02:46:07 -0500418 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500419 png_debug1(1, "in %s retrieval function", "cHRM");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500420
Andreas Dilger47a0c421997-05-16 02:46:07 -0500421 if (white_x != NULL)
422 *white_x = (double)info_ptr->x_white;
423 if (white_y != NULL)
424 *white_y = (double)info_ptr->y_white;
425 if (red_x != NULL)
426 *red_x = (double)info_ptr->x_red;
427 if (red_y != NULL)
428 *red_y = (double)info_ptr->y_red;
429 if (green_x != NULL)
430 *green_x = (double)info_ptr->x_green;
431 if (green_y != NULL)
432 *green_y = (double)info_ptr->y_green;
433 if (blue_x != NULL)
434 *blue_x = (double)info_ptr->x_blue;
435 if (blue_y != NULL)
436 *blue_y = (double)info_ptr->y_blue;
437 return (PNG_INFO_cHRM);
438 }
439 return (0);
440}
441#endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600442#ifdef PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500443png_uint_32 PNGAPI
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600444png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600445 png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
446 png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
447 png_fixed_point *blue_x, png_fixed_point *blue_y)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600448{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500449 png_debug1(1, "in %s retrieval function", "cHRM");
450
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600451 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
452 {
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600453 if (white_x != NULL)
454 *white_x = info_ptr->int_x_white;
455 if (white_y != NULL)
456 *white_y = info_ptr->int_y_white;
457 if (red_x != NULL)
458 *red_x = info_ptr->int_x_red;
459 if (red_y != NULL)
460 *red_y = info_ptr->int_y_red;
461 if (green_x != NULL)
462 *green_x = info_ptr->int_x_green;
463 if (green_y != NULL)
464 *green_y = info_ptr->int_y_green;
465 if (blue_x != NULL)
466 *blue_x = info_ptr->int_x_blue;
467 if (blue_y != NULL)
468 *blue_y = info_ptr->int_y_blue;
469 return (PNG_INFO_cHRM);
470 }
471 return (0);
472}
473#endif
474#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500475
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500476#ifdef PNG_gAMA_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600477#ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500478png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500479png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
480{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500481 png_debug1(1, "in %s retrieval function", "gAMA");
482
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600483 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600484 && file_gamma != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500485 {
Andreas Dilger47a0c421997-05-16 02:46:07 -0500486 *file_gamma = (double)info_ptr->gamma;
487 return (PNG_INFO_gAMA);
488 }
489 return (0);
490}
491#endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500492#ifdef PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500493png_uint_32 PNGAPI
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600494png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600495 png_fixed_point *int_file_gamma)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600496{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500497 png_debug1(1, "in %s retrieval function", "gAMA");
498
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600499 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600500 && int_file_gamma != NULL)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600501 {
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600502 *int_file_gamma = info_ptr->int_gamma;
503 return (PNG_INFO_gAMA);
504 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500505
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600506 return (0);
507}
508#endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500509#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500510
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500511#ifdef PNG_sRGB_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500512png_uint_32 PNGAPI
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600513png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600514{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500515 png_debug1(1, "in %s retrieval function", "sRGB");
516
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600517 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600518 && file_srgb_intent != NULL)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600519 {
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600520 *file_srgb_intent = (int)info_ptr->srgb_intent;
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600521 return (PNG_INFO_sRGB);
522 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500523
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600524 return (0);
525}
526#endif
527
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500528#ifdef PNG_iCCP_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500529png_uint_32 PNGAPI
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600530png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600531 png_charpp name, int *compression_type,
532 png_charpp profile, png_uint_32 *proflen)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600533{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500534 png_debug1(1, "in %s retrieval function", "iCCP");
535
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600536 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600537 && name != NULL && profile != NULL && proflen != NULL)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600538 {
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600539 *name = info_ptr->iccp_name;
540 *profile = info_ptr->iccp_profile;
Glenn Randers-Pehrson4bb4d012009-05-20 12:45:29 -0500541 /* Compression_type is a dummy so the API won't have to change
542 * if we introduce multiple compression types later.
543 */
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600544 *proflen = (int)info_ptr->iccp_proflen;
545 *compression_type = (int)info_ptr->iccp_compression;
546 return (PNG_INFO_iCCP);
547 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500548
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600549 return (0);
550}
551#endif
552
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500553#ifdef PNG_sPLT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500554png_uint_32 PNGAPI
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600555png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600556 png_sPLT_tpp spalettes)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600557{
558 if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500559 {
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600560 *spalettes = info_ptr->splt_palettes;
561 return ((png_uint_32)info_ptr->splt_palettes_num);
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500562 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500563
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500564 return (0);
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600565}
566#endif
567
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500568#ifdef PNG_hIST_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500569png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500570png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
571{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500572 png_debug1(1, "in %s retrieval function", "hIST");
573
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600574 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600575 && hist != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500576 {
Andreas Dilger47a0c421997-05-16 02:46:07 -0500577 *hist = info_ptr->hist;
578 return (PNG_INFO_hIST);
579 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500580
Andreas Dilger47a0c421997-05-16 02:46:07 -0500581 return (0);
582}
583#endif
584
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500585png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500586png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600587 png_uint_32 *width, png_uint_32 *height, int *bit_depth,
588 int *color_type, int *interlace_type, int *compression_type,
589 int *filter_type)
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600590
Andreas Dilger47a0c421997-05-16 02:46:07 -0500591{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500592 png_debug1(1, "in %s retrieval function", "IHDR");
593
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500594 if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
595 height == NULL || bit_depth == NULL || color_type == NULL)
596 return (0);
597
598 *width = info_ptr->width;
599 *height = info_ptr->height;
600 *bit_depth = info_ptr->bit_depth;
601 *color_type = info_ptr->color_type;
602
603 if (compression_type != NULL)
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500604 *compression_type = info_ptr->compression_type;
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500605
606 if (filter_type != NULL)
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500607 *filter_type = info_ptr->filter_type;
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500608
609 if (interlace_type != NULL)
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500610 *interlace_type = info_ptr->interlace_type;
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500611
Glenn Randers-Pehrsonb35a7452009-09-30 23:12:13 -0500612 /* This is redundant if we can be sure that the info_ptr values were all
613 * assigned in png_set_IHDR(). We do the check anyhow in case an
614 * application has ignored our advice not to mess with the members
615 * of info_ptr directly.
616 */
617 png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height,
618 info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
619 info_ptr->compression_type, info_ptr->filter_type);
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500620
621 return (1);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500622}
623
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500624#ifdef PNG_oFFs_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500625png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500626png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600627 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500628{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500629 png_debug1(1, "in %s retrieval function", "oFFs");
630
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600631 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600632 && offset_x != NULL && offset_y != NULL && unit_type != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500633 {
Andreas Dilger47a0c421997-05-16 02:46:07 -0500634 *offset_x = info_ptr->x_offset;
635 *offset_y = info_ptr->y_offset;
636 *unit_type = (int)info_ptr->offset_unit_type;
637 return (PNG_INFO_oFFs);
638 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500639
Andreas Dilger47a0c421997-05-16 02:46:07 -0500640 return (0);
641}
642#endif
643
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500644#ifdef PNG_pCAL_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500645png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500646png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600647 png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
648 png_charp *units, png_charpp *params)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500649{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500650 png_debug1(1, "in %s retrieval function", "pCAL");
651
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600652 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500653 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
654 nparams != NULL && units != NULL && params != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500655 {
Andreas Dilger47a0c421997-05-16 02:46:07 -0500656 *purpose = info_ptr->pcal_purpose;
657 *X0 = info_ptr->pcal_X0;
658 *X1 = info_ptr->pcal_X1;
659 *type = (int)info_ptr->pcal_type;
660 *nparams = (int)info_ptr->pcal_nparams;
661 *units = info_ptr->pcal_units;
662 *params = info_ptr->pcal_params;
663 return (PNG_INFO_pCAL);
664 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500665
Andreas Dilger47a0c421997-05-16 02:46:07 -0500666 return (0);
667}
668#endif
669
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500670#ifdef PNG_sCAL_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600671#ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500672png_uint_32 PNGAPI
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600673png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600674 int *unit, double *width, double *height)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600675{
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600676 if (png_ptr != NULL && info_ptr != NULL &&
677 (info_ptr->valid & PNG_INFO_sCAL))
678 {
679 *unit = info_ptr->scal_unit;
680 *width = info_ptr->scal_pixel_width;
681 *height = info_ptr->scal_pixel_height;
682 return (PNG_INFO_sCAL);
683 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500684
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600685 return(0);
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600686}
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600687#else
688#ifdef PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500689png_uint_32 PNGAPI
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600690png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600691 int *unit, png_charpp width, png_charpp height)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600692{
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600693 if (png_ptr != NULL && info_ptr != NULL &&
694 (info_ptr->valid & PNG_INFO_sCAL))
695 {
696 *unit = info_ptr->scal_unit;
697 *width = info_ptr->scal_s_width;
698 *height = info_ptr->scal_s_height;
699 return (PNG_INFO_sCAL);
700 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500701
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600702 return(0);
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600703}
704#endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600705#endif
706#endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600707
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500708#ifdef PNG_pHYs_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500709png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500710png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600711 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500712{
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600713 png_uint_32 retval = 0;
714
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500715 png_debug1(1, "in %s retrieval function", "pHYs");
716
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600717 if (png_ptr != NULL && info_ptr != NULL &&
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600718 (info_ptr->valid & PNG_INFO_pHYs))
Andreas Dilger47a0c421997-05-16 02:46:07 -0500719 {
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600720 if (res_x != NULL)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600721 {
722 *res_x = info_ptr->x_pixels_per_unit;
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600723 retval |= PNG_INFO_pHYs;
724 }
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500725
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600726 if (res_y != NULL)
727 {
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600728 *res_y = info_ptr->y_pixels_per_unit;
729 retval |= PNG_INFO_pHYs;
730 }
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500731
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600732 if (unit_type != NULL)
733 {
734 *unit_type = (int)info_ptr->phys_unit_type;
735 retval |= PNG_INFO_pHYs;
736 }
Andreas Dilger47a0c421997-05-16 02:46:07 -0500737 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -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,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600745 int *num_palette)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500746{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500747 png_debug1(1, "in %s retrieval function", "PLTE");
748
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600749 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
750 && palette != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -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 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500757
Andreas Dilger47a0c421997-05-16 02:46:07 -0500758 return (0);
759}
760
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500761#ifdef PNG_sBIT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500762png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500763png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
764{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500765 png_debug1(1, "in %s retrieval function", "sBIT");
766
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600767 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600768 && sig_bit != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500769 {
Andreas Dilger47a0c421997-05-16 02:46:07 -0500770 *sig_bit = &(info_ptr->sig_bit);
771 return (PNG_INFO_sBIT);
772 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500773
Andreas Dilger47a0c421997-05-16 02:46:07 -0500774 return (0);
775}
776#endif
777
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500778#ifdef PNG_TEXT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500779png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500780png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600781 int *num_text)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500782{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600783 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500784 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500785 png_debug1(1, "in %s retrieval function",
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600786 (png_ptr->chunk_name[0] == '\0' ? "text" :
787 (png_const_charp)png_ptr->chunk_name));
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500788
Andreas Dilger47a0c421997-05-16 02:46:07 -0500789 if (text_ptr != NULL)
790 *text_ptr = info_ptr->text;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500791
Andreas Dilger47a0c421997-05-16 02:46:07 -0500792 if (num_text != NULL)
793 *num_text = info_ptr->num_text;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500794
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600795 return ((png_uint_32)info_ptr->num_text);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500796 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500797
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600798 if (num_text != NULL)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600799 *num_text = 0;
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500800
Andreas Dilger47a0c421997-05-16 02:46:07 -0500801 return(0);
802}
803#endif
804
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500805#ifdef PNG_tIME_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500806png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500807png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
808{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500809 png_debug1(1, "in %s retrieval function", "tIME");
810
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600811 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
812 && mod_time != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500813 {
Andreas Dilger47a0c421997-05-16 02:46:07 -0500814 *mod_time = &(info_ptr->mod_time);
815 return (PNG_INFO_tIME);
816 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500817
Andreas Dilger47a0c421997-05-16 02:46:07 -0500818 return (0);
819}
820#endif
821
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500822#ifdef PNG_tRNS_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500823png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500824png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600825 png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500826{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600827 png_uint_32 retval = 0;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600828 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
Andreas Dilger47a0c421997-05-16 02:46:07 -0500829 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500830 png_debug1(1, "in %s retrieval function", "tRNS");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500831
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600832 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500833 {
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600834 if (trans_alpha != NULL)
835 {
836 *trans_alpha = info_ptr->trans_alpha;
837 retval |= PNG_INFO_tRNS;
838 }
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500839
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600840 if (trans_color != NULL)
841 *trans_color = &(info_ptr->trans_color);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500842 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500843
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600844 else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500845 {
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600846 if (trans_color != NULL)
847 {
848 *trans_color = &(info_ptr->trans_color);
849 retval |= PNG_INFO_tRNS;
850 }
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500851
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600852 if (trans_alpha != NULL)
853 *trans_alpha = NULL;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500854 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500855
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500856 if (num_trans != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500857 {
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600858 *num_trans = info_ptr->num_trans;
859 retval |= PNG_INFO_tRNS;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500860 }
Andreas Dilger47a0c421997-05-16 02:46:07 -0500861 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500862
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600863 return (retval);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500864}
865#endif
866
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500867#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500868png_uint_32 PNGAPI
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600869png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600870 png_unknown_chunkpp unknowns)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600871{
872 if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500873 {
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600874 *unknowns = info_ptr->unknown_chunks;
875 return ((png_uint_32)info_ptr->unknown_chunks_num);
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500876 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500877
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500878 return (0);
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600879}
880#endif
881
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500882#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500883png_byte PNGAPI
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600884png_get_rgb_to_gray_status (png_structp png_ptr)
885{
Glenn Randers-Pehrsona565f0e2010-03-06 08:24:45 -0600886 return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600887}
888#endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600889
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500890#ifdef PNG_USER_CHUNKS_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500891png_voidp PNGAPI
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600892png_get_user_chunk_ptr(png_structp png_ptr)
893{
Glenn Randers-Pehrsona565f0e2010-03-06 08:24:45 -0600894 return (png_ptr ? png_ptr->user_chunk_ptr : NULL);
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600895}
896#endif
897
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500898png_size_t PNGAPI
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -0500899png_get_compression_buffer_size(png_structp png_ptr)
900{
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500901 return (png_ptr ? png_ptr->zbuf_size : 0L);
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -0500902}
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500903
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500904
905#ifdef PNG_SET_USER_LIMITS_SUPPORTED
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600906/* These functions were added to libpng 1.2.6 and were enabled
907 * by default in libpng-1.4.0 */
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500908png_uint_32 PNGAPI
909png_get_user_width_max (png_structp png_ptr)
910{
Glenn Randers-Pehrsona565f0e2010-03-06 08:24:45 -0600911 return (png_ptr ? png_ptr->user_width_max : 0);
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500912}
913png_uint_32 PNGAPI
914png_get_user_height_max (png_structp png_ptr)
915{
Glenn Randers-Pehrsona565f0e2010-03-06 08:24:45 -0600916 return (png_ptr ? png_ptr->user_height_max : 0);
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500917}
Glenn Randers-Pehrson17ca3402009-11-09 06:51:16 -0600918/* This function was added to libpng 1.4.0 */
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -0500919png_uint_32 PNGAPI
920png_get_chunk_cache_max (png_structp png_ptr)
921{
Glenn Randers-Pehrsona565f0e2010-03-06 08:24:45 -0600922 return (png_ptr ? png_ptr->user_chunk_cache_max : 0);
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600923}
924/* This function was added to libpng 1.4.1 */
Glenn Randers-Pehrson7a5be532010-02-14 07:16:19 -0600925png_alloc_size_t PNGAPI
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600926png_get_chunk_malloc_max (png_structp png_ptr)
927{
Glenn Randers-Pehrsona565f0e2010-03-06 08:24:45 -0600928 return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -0500929}
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500930#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
Glenn Randers-Pehrsond60c8862009-06-15 21:56:14 -0500931
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600932/* These functions were added to libpng 1.4.0 */
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500933#ifdef PNG_IO_STATE_SUPPORTED
934png_uint_32 PNGAPI
935png_get_io_state (png_structp png_ptr)
936{
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600937 return png_ptr->io_state;
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500938}
939
940png_bytep PNGAPI
941png_get_io_chunk_name (png_structp png_ptr)
942{
943 return png_ptr->chunk_name;
944}
945#endif /* ?PNG_IO_STATE_SUPPORTED */
946
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600947#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */