blob: 1ff25f1d042eefffd4a01f0b168c208bcd3a6e9d [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-Pehrsond4366722000-06-04 14:29:29 -05004 * libpng 1.0.7beta16 - June 4, 2000
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06005 * For conditions of distribution and use, see copyright notice in png.h
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06006 * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05007 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06009 */
Andreas Dilger47a0c421997-05-16 02:46:07 -050010
11#define PNG_INTERNAL
12#include "png.h"
13
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050014png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -050015png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
16{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060017 if (png_ptr != NULL && info_ptr != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -050018 return(info_ptr->valid & flag);
19 else
20 return(0);
21}
22
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050023png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -050024png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
25{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060026 if (png_ptr != NULL && info_ptr != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -050027 return(info_ptr->rowbytes);
28 else
29 return(0);
30}
31
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -060032#if defined(PNG_INFO_IMAGE_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050033png_bytepp PNGAPI
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -060034png_get_rows(png_structp png_ptr, png_infop info_ptr)
35{
36 if (png_ptr != NULL && info_ptr != NULL)
37 return(info_ptr->row_pointers);
38 else
39 return(0);
40}
41#endif
42
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060043#ifdef PNG_EASY_ACCESS_SUPPORTED
44/* easy access to info, added in libpng-0.99 */
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050045png_uint_32 PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060046png_get_image_width(png_structp png_ptr, png_infop info_ptr)
47{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060048 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060049 {
50 return info_ptr->width;
51 }
52 return (0);
53}
54
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050055png_uint_32 PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060056png_get_image_height(png_structp png_ptr, png_infop info_ptr)
57{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060058 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060059 {
60 return info_ptr->height;
61 }
62 return (0);
63}
64
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050065png_byte PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060066png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
67{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060068 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060069 {
70 return info_ptr->bit_depth;
71 }
72 return (0);
73}
74
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050075png_byte PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060076png_get_color_type(png_structp png_ptr, png_infop info_ptr)
77{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060078 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060079 {
80 return info_ptr->color_type;
81 }
82 return (0);
83}
84
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050085png_byte PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060086png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
87{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060088 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060089 {
90 return info_ptr->filter_type;
91 }
92 return (0);
93}
94
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050095png_byte PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060096png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
97{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060098 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060099 {
100 return info_ptr->interlace_type;
101 }
102 return (0);
103}
104
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500105png_byte PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600106png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
107{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600108 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600109 {
110 return info_ptr->compression_type;
111 }
112 return (0);
113}
114
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500115png_uint_32 PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600116png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
117{
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500118 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600119#if defined(PNG_pHYs_SUPPORTED)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500120 if (info_ptr->valid & PNG_INFO_pHYs)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600121 {
122 png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter");
123 if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
124 return (0);
125 else return (info_ptr->x_pixels_per_unit);
126 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500127#else
128 return (0);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600129#endif
130 return (0);
131}
132
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500133png_uint_32 PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600134png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
135{
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500136 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600137#if defined(PNG_pHYs_SUPPORTED)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500138 if (info_ptr->valid & PNG_INFO_pHYs)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600139 {
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500140 png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter");
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600141 if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
142 return (0);
143 else return (info_ptr->y_pixels_per_unit);
144 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500145#else
146 return (0);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600147#endif
148 return (0);
149}
150
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500151png_uint_32 PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600152png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
153{
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500154 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600155#if defined(PNG_pHYs_SUPPORTED)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500156 if (info_ptr->valid & PNG_INFO_pHYs)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600157 {
158 png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter");
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600159 if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
160 info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600161 return (0);
162 else return (info_ptr->x_pixels_per_unit);
163 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500164#else
165 return (0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600166#endif
167 return (0);
168}
169
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600170#ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500171float PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600172png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
173 {
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500174 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600175#if defined(PNG_pHYs_SUPPORTED)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500176 if (info_ptr->valid & PNG_INFO_pHYs)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600177 {
178 png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio");
179 if (info_ptr->x_pixels_per_unit == 0)
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600180 return ((float)0.0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600181 else
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500182 return ((float)((float)info_ptr->y_pixels_per_unit
183 /(float)info_ptr->x_pixels_per_unit));
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600184 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500185#else
186 return (0.0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600187#endif
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500188 return ((float)0.0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600189}
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600190#endif
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600191
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500192png_int_32 PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600193png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
194{
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500195 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600196#if defined(PNG_oFFs_SUPPORTED)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500197 if (info_ptr->valid & PNG_INFO_oFFs)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600198 {
199 png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
200 if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
201 return (0);
202 else return (info_ptr->x_offset);
203 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500204#else
205 return (0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600206#endif
207 return (0);
208}
209
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500210png_int_32 PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600211png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
212{
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500213 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600214#if defined(PNG_oFFs_SUPPORTED)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500215 if (info_ptr->valid & PNG_INFO_oFFs)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600216 {
217 png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
218 if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
219 return (0);
220 else return (info_ptr->y_offset);
221 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500222#else
223 return (0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600224#endif
225 return (0);
226}
227
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500228png_int_32 PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600229png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
230{
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500231 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600232#if defined(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 {
235 png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
236 if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
237 return (0);
238 else return (info_ptr->x_offset);
239 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500240#else
241 return (0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600242#endif
243 return (0);
244}
245
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500246png_int_32 PNGAPI
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600247png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
248{
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500249 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600250#if defined(PNG_oFFs_SUPPORTED)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500251 if (info_ptr->valid & PNG_INFO_oFFs)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600252 {
253 png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
254 if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
255 return (0);
256 else return (info_ptr->y_offset);
257 }
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500258#else
259 return (0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600260#endif
261 return (0);
262}
263
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600264#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500265png_uint_32 PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600266png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
267{
268 return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500269 *.0254 +.5));
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600270}
271
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500272png_uint_32 PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600273png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
274{
275 return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500276 *.0254 +.5));
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600277}
278
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500279png_uint_32 PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600280png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
281{
282 return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500283 *.0254 +.5));
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600284}
285
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500286float PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600287png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
288{
289 return ((float)png_get_x_offset_microns(png_ptr, info_ptr)
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600290 *.00003937);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600291}
292
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500293float PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600294png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
295{
296 return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500297 *.00003937);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600298}
299
300#if defined(PNG_READ_pHYs_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500301png_uint_32 PNGAPI
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600302png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
303 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
304{
305 png_uint_32 retval = 0;
306
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600307 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600308 {
309 png_debug1(1, "in %s retrieval function\n", "pHYs");
310 if (res_x != NULL)
311 {
312 *res_x = info_ptr->x_pixels_per_unit;
313 retval |= PNG_INFO_pHYs;
314 }
315 if (res_y != NULL)
316 {
317 *res_y = info_ptr->y_pixels_per_unit;
318 retval |= PNG_INFO_pHYs;
319 }
320 if (unit_type != NULL)
321 {
322 *unit_type = (int)info_ptr->phys_unit_type;
323 retval |= PNG_INFO_pHYs;
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500324 if(*unit_type == 1)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600325 {
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600326 if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
327 if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600328 }
329 }
330 }
331 return (retval);
332}
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500333#endif /* PNG_READ_pHYs_SUPPORTED */
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600334#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600335
336/* png_get_channels really belongs in here, too, but it's been around longer */
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500337
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600338#endif /* PNG_EASY_ACCESS_SUPPORTED */
339
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500340png_byte PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500341png_get_channels(png_structp png_ptr, png_infop info_ptr)
342{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600343 if (png_ptr != NULL && info_ptr != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500344 return(info_ptr->channels);
345 else
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600346 return (0);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500347}
348
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500349png_bytep PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500350png_get_signature(png_structp png_ptr, png_infop info_ptr)
351{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600352 if (png_ptr != NULL && info_ptr != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500353 return(info_ptr->signature);
354 else
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600355 return (NULL);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500356}
357
358#if defined(PNG_READ_bKGD_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500359png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500360png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
361 png_color_16p *background)
362{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600363 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
364 && background != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500365 {
366 png_debug1(1, "in %s retrieval function\n", "bKGD");
367 *background = &(info_ptr->background);
368 return (PNG_INFO_bKGD);
369 }
370 return (0);
371}
372#endif
373
374#if defined(PNG_READ_cHRM_SUPPORTED)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600375#ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500376png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500377png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
378 double *white_x, double *white_y, double *red_x, double *red_y,
379 double *green_x, double *green_y, double *blue_x, double *blue_y)
380{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600381 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
Andreas Dilger47a0c421997-05-16 02:46:07 -0500382 {
383 png_debug1(1, "in %s retrieval function\n", "cHRM");
384 if (white_x != NULL)
385 *white_x = (double)info_ptr->x_white;
386 if (white_y != NULL)
387 *white_y = (double)info_ptr->y_white;
388 if (red_x != NULL)
389 *red_x = (double)info_ptr->x_red;
390 if (red_y != NULL)
391 *red_y = (double)info_ptr->y_red;
392 if (green_x != NULL)
393 *green_x = (double)info_ptr->x_green;
394 if (green_y != NULL)
395 *green_y = (double)info_ptr->y_green;
396 if (blue_x != NULL)
397 *blue_x = (double)info_ptr->x_blue;
398 if (blue_y != NULL)
399 *blue_y = (double)info_ptr->y_blue;
400 return (PNG_INFO_cHRM);
401 }
402 return (0);
403}
404#endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600405#ifdef PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500406png_uint_32 PNGAPI
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600407png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600408 png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
409 png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
410 png_fixed_point *blue_x, png_fixed_point *blue_y)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600411{
412 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
413 {
414 png_debug1(1, "in %s retrieval function\n", "cHRM");
415 if (white_x != NULL)
416 *white_x = info_ptr->int_x_white;
417 if (white_y != NULL)
418 *white_y = info_ptr->int_y_white;
419 if (red_x != NULL)
420 *red_x = info_ptr->int_x_red;
421 if (red_y != NULL)
422 *red_y = info_ptr->int_y_red;
423 if (green_x != NULL)
424 *green_x = info_ptr->int_x_green;
425 if (green_y != NULL)
426 *green_y = info_ptr->int_y_green;
427 if (blue_x != NULL)
428 *blue_x = info_ptr->int_x_blue;
429 if (blue_y != NULL)
430 *blue_y = info_ptr->int_y_blue;
431 return (PNG_INFO_cHRM);
432 }
433 return (0);
434}
435#endif
436#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500437
438#if defined(PNG_READ_gAMA_SUPPORTED)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600439#ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500440png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500441png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
442{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600443 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
444 && file_gamma != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500445 {
446 png_debug1(1, "in %s retrieval function\n", "gAMA");
447 *file_gamma = (double)info_ptr->gamma;
448 return (PNG_INFO_gAMA);
449 }
450 return (0);
451}
452#endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500453#ifdef PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500454png_uint_32 PNGAPI
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600455png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600456 png_fixed_point *int_file_gamma)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600457{
458 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
459 && int_file_gamma != NULL)
460 {
461 png_debug1(1, "in %s retrieval function\n", "gAMA");
462 *int_file_gamma = info_ptr->int_gamma;
463 return (PNG_INFO_gAMA);
464 }
465 return (0);
466}
467#endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500468#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500469
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600470#if defined(PNG_READ_sRGB_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500471png_uint_32 PNGAPI
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600472png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600473{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600474 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
475 && file_srgb_intent != NULL)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600476 {
477 png_debug1(1, "in %s retrieval function\n", "sRGB");
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600478 *file_srgb_intent = (int)info_ptr->srgb_intent;
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600479 return (PNG_INFO_sRGB);
480 }
481 return (0);
482}
483#endif
484
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600485#if defined(PNG_READ_iCCP_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500486png_uint_32 PNGAPI
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600487png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
488 png_charpp name, int *compression_type,
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600489 png_charpp profile, png_uint_32 *proflen)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600490{
491 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
492 && name != NULL && profile != NULL && proflen != NULL)
493 {
494 png_debug1(1, "in %s retrieval function\n", "iCCP");
495 *name = info_ptr->iccp_name;
496 *profile = info_ptr->iccp_profile;
497 /* compression_type is a dummy so the API won't have to change
498 if we introduce multiple compression types later. */
499 *proflen = (int)info_ptr->iccp_proflen;
500 *compression_type = (int)info_ptr->iccp_compression;
501 return (PNG_INFO_iCCP);
502 }
503 return (0);
504}
505#endif
506
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600507#if defined(PNG_READ_sPLT_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500508png_uint_32 PNGAPI
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600509png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -0600510 png_sPLT_tpp spalettes)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600511{
512 if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
513 *spalettes = info_ptr->splt_palettes;
514 return ((png_uint_32)info_ptr->splt_palettes_num);
515}
516#endif
517
Andreas Dilger47a0c421997-05-16 02:46:07 -0500518#if defined(PNG_READ_hIST_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500519png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500520png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
521{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600522 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
523 && hist != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500524 {
525 png_debug1(1, "in %s retrieval function\n", "hIST");
526 *hist = info_ptr->hist;
527 return (PNG_INFO_hIST);
528 }
529 return (0);
530}
531#endif
532
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500533png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500534png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
535 png_uint_32 *width, png_uint_32 *height, int *bit_depth,
536 int *color_type, int *interlace_type, int *compression_type,
537 int *filter_type)
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600538
Andreas Dilger47a0c421997-05-16 02:46:07 -0500539{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600540 if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
Andreas Dilger47a0c421997-05-16 02:46:07 -0500541 bit_depth != NULL && color_type != NULL)
542 {
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600543 int pixel_depth, channels;
544 png_uint_32 rowbytes_per_pixel;
545
Andreas Dilger47a0c421997-05-16 02:46:07 -0500546 png_debug1(1, "in %s retrieval function\n", "IHDR");
547 *width = info_ptr->width;
548 *height = info_ptr->height;
549 *bit_depth = info_ptr->bit_depth;
550 *color_type = info_ptr->color_type;
551 if (compression_type != NULL)
552 *compression_type = info_ptr->compression_type;
553 if (filter_type != NULL)
554 *filter_type = info_ptr->filter_type;
555 if (interlace_type != NULL)
556 *interlace_type = info_ptr->interlace_type;
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600557
558 /* check for potential overflow of rowbytes */
559 if (*color_type == PNG_COLOR_TYPE_PALETTE)
560 channels = 1;
561 else if (*color_type & PNG_COLOR_MASK_COLOR)
562 channels = 3;
563 else
564 channels = 1;
565 if (*color_type & PNG_COLOR_MASK_ALPHA)
566 channels++;
567 pixel_depth = *bit_depth * channels;
568 rowbytes_per_pixel = (pixel_depth + 7) >> 3;
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500569 if ((*width > PNG_MAX_UINT/rowbytes_per_pixel))
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600570 {
571 png_warning(png_ptr,
572 "Width too large for libpng to process image data.");
573 }
Andreas Dilger47a0c421997-05-16 02:46:07 -0500574 return (1);
575 }
576 return (0);
577}
578
579#if defined(PNG_READ_oFFs_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500580png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500581png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600582 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500583{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600584 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
585 && offset_x != NULL && offset_y != NULL && unit_type != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500586 {
587 png_debug1(1, "in %s retrieval function\n", "oFFs");
588 *offset_x = info_ptr->x_offset;
589 *offset_y = info_ptr->y_offset;
590 *unit_type = (int)info_ptr->offset_unit_type;
591 return (PNG_INFO_oFFs);
592 }
593 return (0);
594}
595#endif
596
597#if defined(PNG_READ_pCAL_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500598png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500599png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
600 png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
601 png_charp *units, png_charpp *params)
602{
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600603 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
604 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
Andreas Dilger47a0c421997-05-16 02:46:07 -0500605 nparams != NULL && units != NULL && params != NULL)
606 {
607 png_debug1(1, "in %s retrieval function\n", "pCAL");
608 *purpose = info_ptr->pcal_purpose;
609 *X0 = info_ptr->pcal_X0;
610 *X1 = info_ptr->pcal_X1;
611 *type = (int)info_ptr->pcal_type;
612 *nparams = (int)info_ptr->pcal_nparams;
613 *units = info_ptr->pcal_units;
614 *params = info_ptr->pcal_params;
615 return (PNG_INFO_pCAL);
616 }
617 return (0);
618}
619#endif
620
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600621#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED)
622#ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500623png_uint_32 PNGAPI
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600624png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600625 int *unit, double *width, double *height)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600626{
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600627 if (png_ptr != NULL && info_ptr != NULL &&
628 (info_ptr->valid & PNG_INFO_sCAL))
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600629 {
630 *unit = info_ptr->scal_unit;
631 *width = info_ptr->scal_pixel_width;
632 *height = info_ptr->scal_pixel_height;
633 return (PNG_INFO_sCAL);
634 }
635 return(0);
636}
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600637#else
638#ifdef PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500639png_uint_32 PNGAPI
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600640png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600641 int *unit, png_charpp width, png_charpp height)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600642{
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600643 if (png_ptr != NULL && info_ptr != NULL &&
644 (info_ptr->valid & PNG_INFO_sCAL))
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600645 {
646 *unit = info_ptr->scal_unit;
647 *width = info_ptr->scal_s_width;
648 *height = info_ptr->scal_s_height;
649 return (PNG_INFO_sCAL);
650 }
651 return(0);
652}
653#endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600654#endif
655#endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600656
Andreas Dilger47a0c421997-05-16 02:46:07 -0500657#if defined(PNG_READ_pHYs_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500658png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500659png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
660 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
661{
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600662 png_uint_32 retval = 0;
663
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600664 if (png_ptr != NULL && info_ptr != NULL &&
665 (info_ptr->valid & PNG_INFO_pHYs))
Andreas Dilger47a0c421997-05-16 02:46:07 -0500666 {
667 png_debug1(1, "in %s retrieval function\n", "pHYs");
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600668 if (res_x != NULL)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600669 {
670 *res_x = info_ptr->x_pixels_per_unit;
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600671 retval |= PNG_INFO_pHYs;
672 }
673 if (res_y != NULL)
674 {
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600675 *res_y = info_ptr->y_pixels_per_unit;
676 retval |= PNG_INFO_pHYs;
677 }
678 if (unit_type != NULL)
679 {
680 *unit_type = (int)info_ptr->phys_unit_type;
681 retval |= PNG_INFO_pHYs;
682 }
Andreas Dilger47a0c421997-05-16 02:46:07 -0500683 }
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600684 return (retval);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500685}
686#endif
687
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500688png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500689png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
690 int *num_palette)
691{
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600692 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
693 && palette != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500694 {
695 png_debug1(1, "in %s retrieval function\n", "PLTE");
696 *palette = info_ptr->palette;
697 *num_palette = info_ptr->num_palette;
698 png_debug1(3, "num_palette = %d\n", *num_palette);
699 return (PNG_INFO_PLTE);
700 }
701 return (0);
702}
703
704#if defined(PNG_READ_sBIT_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500705png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500706png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
707{
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600708 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
709 && sig_bit != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500710 {
711 png_debug1(1, "in %s retrieval function\n", "sBIT");
712 *sig_bit = &(info_ptr->sig_bit);
713 return (PNG_INFO_sBIT);
714 }
715 return (0);
716}
717#endif
718
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600719#if defined(PNG_READ_TEXT_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500720png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500721png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
722 int *num_text)
723{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600724 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500725 {
726 png_debug1(1, "in %s retrieval function\n",
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600727 (png_ptr->chunk_name[0] == '\0' ? "text"
728 : (png_const_charp)png_ptr->chunk_name));
Andreas Dilger47a0c421997-05-16 02:46:07 -0500729 if (text_ptr != NULL)
730 *text_ptr = info_ptr->text;
731 if (num_text != NULL)
732 *num_text = info_ptr->num_text;
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600733 return ((png_uint_32)info_ptr->num_text);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500734 }
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600735 if (num_text != NULL)
736 *num_text = 0;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500737 return(0);
738}
739#endif
740
741#if defined(PNG_READ_tIME_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500742png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500743png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
744{
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600745 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
746 && mod_time != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500747 {
748 png_debug1(1, "in %s retrieval function\n", "tIME");
749 *mod_time = &(info_ptr->mod_time);
750 return (PNG_INFO_tIME);
751 }
752 return (0);
753}
754#endif
755
756#if defined(PNG_READ_tRNS_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500757png_uint_32 PNGAPI
Andreas Dilger47a0c421997-05-16 02:46:07 -0500758png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
759 png_bytep *trans, int *num_trans, png_color_16p *trans_values)
760{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600761 png_uint_32 retval = 0;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600762 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
Andreas Dilger47a0c421997-05-16 02:46:07 -0500763 {
764 png_debug1(1, "in %s retrieval function\n", "tRNS");
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600765 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500766 {
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600767 if (trans != NULL)
768 {
769 *trans = info_ptr->trans;
770 retval |= PNG_INFO_tRNS;
771 }
772 if (trans_values != NULL)
773 *trans_values = &(info_ptr->trans_values);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500774 }
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600775 else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500776 {
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600777 if (trans_values != NULL)
778 {
779 *trans_values = &(info_ptr->trans_values);
780 retval |= PNG_INFO_tRNS;
781 }
782 if(trans != NULL)
783 *trans = NULL;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500784 }
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600785 if(num_trans != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500786 {
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600787 *num_trans = info_ptr->num_trans;
788 retval |= PNG_INFO_tRNS;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500789 }
Andreas Dilger47a0c421997-05-16 02:46:07 -0500790 }
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600791 return (retval);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500792}
793#endif
794
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600795#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500796png_uint_32 PNGAPI
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600797png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
798 png_unknown_chunkpp unknowns)
799{
800 if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
801 *unknowns = info_ptr->unknown_chunks;
802 return ((png_uint_32)info_ptr->unknown_chunks_num);
803}
804#endif
805
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600806#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500807png_byte PNGAPI
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600808png_get_rgb_to_gray_status (png_structp png_ptr)
809{
810 return png_ptr->rgb_to_gray_status;
811}
812#endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600813
814#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500815png_voidp PNGAPI
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600816png_get_user_chunk_ptr(png_structp png_ptr)
817{
818 return (png_ptr->user_chunk_ptr);
819}
820#endif
821
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -0500822
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500823png_uint_32 PNGAPI
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -0500824png_get_compression_buffer_size(png_structp png_ptr)
825{
826 return(png_ptr->zbuf_size);
827}