blob: 172f50a90015c829eda4087bc33624c0c800ead3 [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-Pehrson212fd572014-06-11 21:10:16 -05004 * Last changed in libpng 1.6.11 [June 5, 2014]
Cosmin Truta6572c7d2014-03-22 09:20:53 -05005 * Copyright (c) 1998-2014 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
John Bowler5d567862011-12-24 09:12:00 -060020png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrsonb86b4922011-01-21 23:12:51 -060021 png_uint_32 flag)
Andreas Dilger47a0c421997-05-16 02:46:07 -050022{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060023 if (png_ptr != NULL && info_ptr != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -050024 return(info_ptr->valid & flag);
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -050025
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -050026 return(0);
Andreas Dilger47a0c421997-05-16 02:46:07 -050027}
28
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -050029png_size_t PNGAPI
John Bowler5d567862011-12-24 09:12:00 -060030png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr)
Andreas Dilger47a0c421997-05-16 02:46:07 -050031{
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
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -050035 return(0);
Andreas Dilger47a0c421997-05-16 02:46:07 -050036}
37
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -050038#ifdef PNG_INFO_IMAGE_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050039png_bytepp PNGAPI
John Bowler5d567862011-12-24 09:12:00 -060040png_get_rows(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -060041{
42 if (png_ptr != NULL && info_ptr != NULL)
43 return(info_ptr->row_pointers);
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -050044
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -050045 return(0);
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -060046}
47#endif
48
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060049#ifdef PNG_EASY_ACCESS_SUPPORTED
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -050050/* Easy access to info, added in libpng-0.99 */
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050051png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -060052png_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060053{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060054 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060055 return info_ptr->width;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -050056
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060057 return (0);
58}
59
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050060png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -060061png_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060062{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060063 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060064 return info_ptr->height;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -050065
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060066 return (0);
67}
68
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050069png_byte PNGAPI
John Bowler5d567862011-12-24 09:12:00 -060070png_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060071{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060072 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060073 return info_ptr->bit_depth;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -050074
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060075 return (0);
76}
77
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050078png_byte PNGAPI
John Bowler5d567862011-12-24 09:12:00 -060079png_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060080{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060081 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060082 return info_ptr->color_type;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -050083
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060084 return (0);
85}
86
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050087png_byte PNGAPI
John Bowler5d567862011-12-24 09:12:00 -060088png_get_filter_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060089{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060090 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060091 return info_ptr->filter_type;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -050092
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060093 return (0);
94}
95
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -050096png_byte PNGAPI
John Bowler5d567862011-12-24 09:12:00 -060097png_get_interlace_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060098{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060099 if (png_ptr != NULL && info_ptr != NULL)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600100 return info_ptr->interlace_type;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500101
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600102 return (0);
103}
104
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500105png_byte PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600106png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600107{
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 return info_ptr->compression_type;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500110
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600111 return (0);
112}
113
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500114png_uint_32 PNGAPI
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600115png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
116 info_ptr)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600117{
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500118#ifdef PNG_pHYs_SUPPORTED
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500119 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
120 {
121 png_debug1(1, "in %s retrieval function",
122 "png_get_x_pixels_per_meter");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500123
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500124 if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
125 return (info_ptr->x_pixels_per_unit);
126 }
Cosmin Truta6572c7d2014-03-22 09:20:53 -0500127#else
128 PNG_UNUSED(png_ptr)
129 PNG_UNUSED(info_ptr)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600130#endif
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500131
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600132 return (0);
133}
134
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500135png_uint_32 PNGAPI
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600136png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
137 info_ptr)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600138{
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500139#ifdef PNG_pHYs_SUPPORTED
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500140 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600141 {
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500142 png_debug1(1, "in %s retrieval function",
143 "png_get_y_pixels_per_meter");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500144
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500145 if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600146 return (info_ptr->y_pixels_per_unit);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600147 }
Cosmin Truta6572c7d2014-03-22 09:20:53 -0500148#else
149 PNG_UNUSED(png_ptr)
150 PNG_UNUSED(info_ptr)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600151#endif
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500152
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600153 return (0);
154}
155
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500156png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600157png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600158{
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500159#ifdef PNG_pHYs_SUPPORTED
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500160 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600161 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500162 png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500163
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500164 if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER &&
165 info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600166 return (info_ptr->x_pixels_per_unit);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600167 }
Cosmin Truta6572c7d2014-03-22 09:20:53 -0500168#else
169 PNG_UNUSED(png_ptr)
170 PNG_UNUSED(info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600171#endif
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500172
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600173 return (0);
174}
175
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600176#ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500177float PNGAPI
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600178png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp
179 info_ptr)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600180{
Glenn Randers-Pehrson4009a762010-07-31 06:34:36 -0500181#ifdef PNG_READ_pHYs_SUPPORTED
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500182 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600183 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500184 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500185
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500186 if (info_ptr->x_pixels_per_unit != 0)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500187 return ((float)((float)info_ptr->y_pixels_per_unit
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600188 /(float)info_ptr->x_pixels_per_unit));
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600189 }
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600190#else
191 PNG_UNUSED(png_ptr)
192 PNG_UNUSED(info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600193#endif
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500194
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500195 return ((float)0.0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600196}
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600197#endif
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600198
Glenn Randers-Pehrson4009a762010-07-31 06:34:36 -0500199#ifdef PNG_FIXED_POINT_SUPPORTED
200png_fixed_point PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600201png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
202 png_const_inforp info_ptr)
Glenn Randers-Pehrson4009a762010-07-31 06:34:36 -0500203{
204#ifdef PNG_READ_pHYs_SUPPORTED
205 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -0500206 && info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0
207 && info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX
208 && info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX)
Glenn Randers-Pehrson4009a762010-07-31 06:34:36 -0500209 {
210 png_fixed_point res;
211
212 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio_fixed");
213
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -0500214 /* The following casts work because a PNG 4 byte integer only has a valid
215 * range of 0..2^31-1; otherwise the cast might overflow.
216 */
217 if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1,
218 (png_int_32)info_ptr->x_pixels_per_unit))
Glenn Randers-Pehrson3df324d2010-07-31 13:45:04 -0500219 return res;
Glenn Randers-Pehrson4009a762010-07-31 06:34:36 -0500220 }
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600221#else
222 PNG_UNUSED(png_ptr)
223 PNG_UNUSED(info_ptr)
Glenn Randers-Pehrson4009a762010-07-31 06:34:36 -0500224#endif
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500225
Glenn Randers-Pehrson4009a762010-07-31 06:34:36 -0500226 return 0;
227}
228#endif
229
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500230png_int_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600231png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600232{
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500233#ifdef PNG_oFFs_SUPPORTED
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500234 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600235 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500236 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500237
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500238 if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600239 return (info_ptr->x_offset);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600240 }
Cosmin Truta6572c7d2014-03-22 09:20:53 -0500241#else
242 PNG_UNUSED(png_ptr)
243 PNG_UNUSED(info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600244#endif
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500245
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600246 return (0);
247}
248
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500249png_int_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600250png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600251{
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500252#ifdef PNG_oFFs_SUPPORTED
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500253 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600254 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500255 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500256
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500257 if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600258 return (info_ptr->y_offset);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600259 }
Cosmin Truta6572c7d2014-03-22 09:20:53 -0500260#else
261 PNG_UNUSED(png_ptr)
262 PNG_UNUSED(info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600263#endif
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500264
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600265 return (0);
266}
267
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500268png_int_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600269png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600270{
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500271#ifdef PNG_oFFs_SUPPORTED
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500272 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600273 {
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500274 png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500275
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500276 if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600277 return (info_ptr->x_offset);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600278 }
Cosmin Truta6572c7d2014-03-22 09:20:53 -0500279#else
280 PNG_UNUSED(png_ptr)
281 PNG_UNUSED(info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600282#endif
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500283
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600284 return (0);
285}
286
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500287png_int_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600288png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600289{
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500290#ifdef PNG_oFFs_SUPPORTED
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500291 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600292 {
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500293 png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500294
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500295 if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600296 return (info_ptr->y_offset);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600297 }
Cosmin Truta6572c7d2014-03-22 09:20:53 -0500298#else
299 PNG_UNUSED(png_ptr)
300 PNG_UNUSED(info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600301#endif
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500302
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600303 return (0);
304}
305
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500306#ifdef PNG_INCH_CONVERSIONS_SUPPORTED
307static png_uint_32
308ppi_from_ppm(png_uint_32 ppm)
309{
310#if 0
Glenn Randers-Pehrson233357e2010-07-29 21:49:38 -0500311 /* The conversion is *(2.54/100), in binary (32 digits):
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500312 * .00000110100000001001110101001001
313 */
314 png_uint_32 t1001, t1101;
315 ppm >>= 1; /* .1 */
316 t1001 = ppm + (ppm >> 3); /* .1001 */
317 t1101 = t1001 + (ppm >> 1); /* .1101 */
318 ppm >>= 20; /* .000000000000000000001 */
319 t1101 += t1101 >> 15; /* .1101000000000001101 */
320 t1001 >>= 11; /* .000000000001001 */
321 t1001 += t1001 >> 12; /* .000000000001001000000001001 */
322 ppm += t1001; /* .000000000001001000001001001 */
323 ppm += t1101; /* .110100000001001110101001001 */
324 return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */
325#else
326 /* The argument is a PNG unsigned integer, so it is not permitted
327 * to be bigger than 2^31.
328 */
329 png_fixed_point result;
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -0500330 if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127,
331 5000))
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500332 return result;
333
334 /* Overflow. */
335 return 0;
336#endif
337}
338
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500339png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600340png_get_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600341{
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500342 return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr));
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600343}
344
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500345png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600346png_get_x_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600347{
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500348 return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr));
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600349}
350
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500351png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600352png_get_y_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600353{
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500354 return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr));
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600355}
356
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500357#ifdef PNG_FIXED_POINT_SUPPORTED
358static png_fixed_point
John Bowler5d567862011-12-24 09:12:00 -0600359png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns)
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500360{
361 /* Convert from metres * 1,000,000 to inches * 100,000, meters to
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500362 * inches is simply *(100/2.54), so we want *(10/2.54) == 500/127.
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500363 * Notice that this can overflow - a warning is output and 0 is
364 * returned.
365 */
366 return png_muldiv_warn(png_ptr, microns, 500, 127);
367}
368
369png_fixed_point PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600370png_get_x_offset_inches_fixed(png_const_structrp png_ptr,
371 png_const_inforp info_ptr)
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500372{
373 return png_fixed_inches_from_microns(png_ptr,
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -0500374 png_get_x_offset_microns(png_ptr, info_ptr));
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500375}
376#endif
377
378#ifdef PNG_FIXED_POINT_SUPPORTED
379png_fixed_point PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600380png_get_y_offset_inches_fixed(png_const_structrp png_ptr,
381 png_const_inforp info_ptr)
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500382{
383 return png_fixed_inches_from_microns(png_ptr,
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -0500384 png_get_y_offset_microns(png_ptr, info_ptr));
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500385}
386#endif
387
388#ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500389float PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600390png_get_x_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600391{
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500392 /* To avoid the overflow do the conversion directly in floating
393 * point.
394 */
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -0500395 return (float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600396}
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500397#endif
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600398
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500399#ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500400float PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600401png_get_y_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600402{
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500403 /* To avoid the overflow do the conversion directly in floating
404 * point.
405 */
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -0500406 return (float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600407}
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500408#endif
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600409
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500410#ifdef PNG_pHYs_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500411png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600412png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600413 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600414{
415 png_uint_32 retval = 0;
416
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600417 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600418 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500419 png_debug1(1, "in %s retrieval function", "pHYs");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500420
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600421 if (res_x != NULL)
422 {
423 *res_x = info_ptr->x_pixels_per_unit;
424 retval |= PNG_INFO_pHYs;
425 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500426
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600427 if (res_y != NULL)
428 {
429 *res_y = info_ptr->y_pixels_per_unit;
430 retval |= PNG_INFO_pHYs;
431 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500432
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600433 if (unit_type != NULL)
434 {
435 *unit_type = (int)info_ptr->phys_unit_type;
436 retval |= PNG_INFO_pHYs;
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -0500437
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500438 if (*unit_type == 1)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600439 {
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600440 if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
441 if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600442 }
443 }
444 }
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500445
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600446 return (retval);
447}
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500448#endif /* PNG_pHYs_SUPPORTED */
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500449#endif /* PNG_INCH_CONVERSIONS_SUPPORTED */
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600450
451/* png_get_channels really belongs in here, too, but it's been around longer */
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500452
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600453#endif /* PNG_EASY_ACCESS_SUPPORTED */
454
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600455
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500456png_byte PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600457png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500458{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600459 if (png_ptr != NULL && info_ptr != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500460 return(info_ptr->channels);
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500461
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500462 return (0);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500463}
464
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600465#ifdef PNG_READ_SUPPORTED
Glenn Randers-Pehrsone600c512010-08-18 07:25:46 -0500466png_const_bytep PNGAPI
John Bowler4f67e402011-12-28 08:43:37 -0600467png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500468{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600469 if (png_ptr != NULL && info_ptr != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500470 return(info_ptr->signature);
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500471
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500472 return (NULL);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500473}
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600474#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500475
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500476#ifdef PNG_bKGD_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500477png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600478png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
Andreas Dilger47a0c421997-05-16 02:46:07 -0500479 png_color_16p *background)
480{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600481 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600482 && background != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500483 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500484 png_debug1(1, "in %s retrieval function", "bKGD");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500485
Andreas Dilger47a0c421997-05-16 02:46:07 -0500486 *background = &(info_ptr->background);
487 return (PNG_INFO_bKGD);
488 }
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500489
Andreas Dilger47a0c421997-05-16 02:46:07 -0500490 return (0);
491}
492#endif
493
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500494#ifdef PNG_cHRM_SUPPORTED
John Bowler736f40f2011-08-25 16:19:44 -0500495/* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the
496 * same time to correct the rgb grayscale coefficient defaults obtained from the
497 * cHRM chunk in 1.5.4
498 */
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500499# ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500500png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600501png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600502 double *white_x, double *white_y, double *red_x, double *red_y,
503 double *green_x, double *green_y, double *blue_x, double *blue_y)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500504{
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600505 /* Quiet API change: this code used to only return the end points if a cHRM
506 * chunk was present, but the end points can also come from iCCP or sRGB
507 * chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and
508 * the png_set_ APIs merely check that set end points are mutually
509 * consistent.
510 */
511 if (png_ptr != NULL && info_ptr != NULL &&
512 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
Andreas Dilger47a0c421997-05-16 02:46:07 -0500513 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500514 png_debug1(1, "in %s retrieval function", "cHRM");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500515
Andreas Dilger47a0c421997-05-16 02:46:07 -0500516 if (white_x != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600517 *white_x = png_float(png_ptr,
518 info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
Andreas Dilger47a0c421997-05-16 02:46:07 -0500519 if (white_y != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600520 *white_y = png_float(png_ptr,
521 info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y");
Andreas Dilger47a0c421997-05-16 02:46:07 -0500522 if (red_x != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600523 *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx,
524 "cHRM red X");
Andreas Dilger47a0c421997-05-16 02:46:07 -0500525 if (red_y != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600526 *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy,
527 "cHRM red Y");
Andreas Dilger47a0c421997-05-16 02:46:07 -0500528 if (green_x != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600529 *green_x = png_float(png_ptr,
530 info_ptr->colorspace.end_points_xy.greenx, "cHRM green X");
Andreas Dilger47a0c421997-05-16 02:46:07 -0500531 if (green_y != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600532 *green_y = png_float(png_ptr,
533 info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y");
Andreas Dilger47a0c421997-05-16 02:46:07 -0500534 if (blue_x != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600535 *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex,
536 "cHRM blue X");
Andreas Dilger47a0c421997-05-16 02:46:07 -0500537 if (blue_y != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600538 *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,
539 "cHRM blue Y");
Andreas Dilger47a0c421997-05-16 02:46:07 -0500540 return (PNG_INFO_cHRM);
541 }
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500542
Andreas Dilger47a0c421997-05-16 02:46:07 -0500543 return (0);
544}
John Bowler736f40f2011-08-25 16:19:44 -0500545
546png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600547png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
John Bowler736f40f2011-08-25 16:19:44 -0500548 double *red_X, double *red_Y, double *red_Z, double *green_X,
549 double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
550 double *blue_Z)
551{
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600552 if (png_ptr != NULL && info_ptr != NULL &&
553 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
Glenn Randers-Pehrsonf3af7062012-02-02 23:11:45 -0600554 {
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600555 png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
556
John Bowler736f40f2011-08-25 16:19:44 -0500557 if (red_X != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600558 *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X,
559 "cHRM red X");
John Bowler736f40f2011-08-25 16:19:44 -0500560 if (red_Y != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600561 *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y,
562 "cHRM red Y");
John Bowler736f40f2011-08-25 16:19:44 -0500563 if (red_Z != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600564 *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z,
565 "cHRM red Z");
John Bowler736f40f2011-08-25 16:19:44 -0500566 if (green_X != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600567 *green_X = png_float(png_ptr,
568 info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X");
John Bowler736f40f2011-08-25 16:19:44 -0500569 if (green_Y != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600570 *green_Y = png_float(png_ptr,
571 info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y");
John Bowler736f40f2011-08-25 16:19:44 -0500572 if (green_Z != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600573 *green_Z = png_float(png_ptr,
574 info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z");
John Bowler736f40f2011-08-25 16:19:44 -0500575 if (blue_X != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600576 *blue_X = png_float(png_ptr,
577 info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X");
John Bowler736f40f2011-08-25 16:19:44 -0500578 if (blue_Y != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600579 *blue_Y = png_float(png_ptr,
580 info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y");
John Bowler736f40f2011-08-25 16:19:44 -0500581 if (blue_Z != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600582 *blue_Z = png_float(png_ptr,
583 info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
John Bowler736f40f2011-08-25 16:19:44 -0500584 return (PNG_INFO_cHRM);
585 }
586
587 return (0);
588}
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500589# endif
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500590
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500591# ifdef PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500592png_uint_32 PNGAPI
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600593png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
594 png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
595 png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
596 png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
597 png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
598 png_fixed_point *int_blue_Z)
599{
600 if (png_ptr != NULL && info_ptr != NULL &&
601 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
602 {
603 png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
604
605 if (int_red_X != NULL)
606 *int_red_X = info_ptr->colorspace.end_points_XYZ.red_X;
607 if (int_red_Y != NULL)
608 *int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y;
609 if (int_red_Z != NULL)
610 *int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z;
611 if (int_green_X != NULL)
612 *int_green_X = info_ptr->colorspace.end_points_XYZ.green_X;
613 if (int_green_Y != NULL)
614 *int_green_Y = info_ptr->colorspace.end_points_XYZ.green_Y;
615 if (int_green_Z != NULL)
616 *int_green_Z = info_ptr->colorspace.end_points_XYZ.green_Z;
617 if (int_blue_X != NULL)
618 *int_blue_X = info_ptr->colorspace.end_points_XYZ.blue_X;
619 if (int_blue_Y != NULL)
620 *int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y;
621 if (int_blue_Z != NULL)
622 *int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z;
623 return (PNG_INFO_cHRM);
624 }
625
626 return (0);
627}
628
629png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600630png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600631 png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
632 png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
633 png_fixed_point *blue_x, png_fixed_point *blue_y)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600634{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500635 png_debug1(1, "in %s retrieval function", "cHRM");
636
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600637 if (png_ptr != NULL && info_ptr != NULL &&
638 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600639 {
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600640 if (white_x != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600641 *white_x = info_ptr->colorspace.end_points_xy.whitex;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600642 if (white_y != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600643 *white_y = info_ptr->colorspace.end_points_xy.whitey;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600644 if (red_x != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600645 *red_x = info_ptr->colorspace.end_points_xy.redx;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600646 if (red_y != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600647 *red_y = info_ptr->colorspace.end_points_xy.redy;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600648 if (green_x != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600649 *green_x = info_ptr->colorspace.end_points_xy.greenx;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600650 if (green_y != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600651 *green_y = info_ptr->colorspace.end_points_xy.greeny;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600652 if (blue_x != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600653 *blue_x = info_ptr->colorspace.end_points_xy.bluex;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600654 if (blue_y != NULL)
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600655 *blue_y = info_ptr->colorspace.end_points_xy.bluey;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600656 return (PNG_INFO_cHRM);
657 }
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500658
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600659 return (0);
660}
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500661# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600662#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500663
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500664#ifdef PNG_gAMA_SUPPORTED
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600665# ifdef PNG_FIXED_POINT_SUPPORTED
666png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600667png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500668 png_fixed_point *file_gamma)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500669{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500670 png_debug1(1, "in %s retrieval function", "gAMA");
671
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600672 if (png_ptr != NULL && info_ptr != NULL &&
673 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
674 file_gamma != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500675 {
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600676 *file_gamma = info_ptr->colorspace.gamma;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500677 return (PNG_INFO_gAMA);
678 }
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500679
Andreas Dilger47a0c421997-05-16 02:46:07 -0500680 return (0);
681}
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600682# endif
683
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500684# ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500685png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600686png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrsonb86b4922011-01-21 23:12:51 -0600687 double *file_gamma)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600688{
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600689 png_debug1(1, "in %s retrieval function", "gAMA(float)");
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500690
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600691 if (png_ptr != NULL && info_ptr != NULL &&
692 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
693 file_gamma != NULL)
694 {
695 *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
696 "png_get_gAMA");
697 return (PNG_INFO_gAMA);
698 }
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500699
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600700 return (0);
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600701}
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500702# endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500703#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500704
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500705#ifdef PNG_sRGB_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500706png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600707png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrsonb86b4922011-01-21 23:12:51 -0600708 int *file_srgb_intent)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600709{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500710 png_debug1(1, "in %s retrieval function", "sRGB");
711
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600712 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600713 && file_srgb_intent != NULL)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600714 {
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600715 *file_srgb_intent = info_ptr->colorspace.rendering_intent;
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600716 return (PNG_INFO_sRGB);
717 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500718
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600719 return (0);
720}
721#endif
722
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500723#ifdef PNG_iCCP_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500724png_uint_32 PNGAPI
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600725png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600726 png_charpp name, int *compression_type,
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500727 png_bytepp profile, png_uint_32 *proflen)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600728{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500729 png_debug1(1, "in %s retrieval function", "iCCP");
730
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600731 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
John Bowler88bcdc22011-11-04 20:11:16 -0500732 && name != NULL && compression_type != NULL && profile != NULL &&
733 proflen != NULL)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600734 {
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600735 *name = info_ptr->iccp_name;
736 *profile = info_ptr->iccp_profile;
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600737 *proflen = png_get_uint_32(info_ptr->iccp_profile);
738 /* This is somewhat irrelevant since the profile data returned has
739 * actually been uncompressed.
Glenn Randers-Pehrson4bb4d012009-05-20 12:45:29 -0500740 */
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600741 *compression_type = PNG_COMPRESSION_TYPE_BASE;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600742 return (PNG_INFO_iCCP);
743 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500744
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600745 return (0);
746}
747#endif
748
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500749#ifdef PNG_sPLT_SUPPORTED
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600750int PNGAPI
751png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600752 png_sPLT_tpp spalettes)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600753{
754 if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500755 {
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600756 *spalettes = info_ptr->splt_palettes;
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600757 return info_ptr->splt_palettes_num;
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500758 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500759
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500760 return (0);
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600761}
762#endif
763
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500764#ifdef PNG_hIST_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500765png_uint_32 PNGAPI
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600766png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
Glenn Randers-Pehrsonb86b4922011-01-21 23:12:51 -0600767 png_uint_16p *hist)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500768{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500769 png_debug1(1, "in %s retrieval function", "hIST");
770
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600771 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600772 && hist != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500773 {
Andreas Dilger47a0c421997-05-16 02:46:07 -0500774 *hist = info_ptr->hist;
775 return (PNG_INFO_hIST);
776 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500777
Andreas Dilger47a0c421997-05-16 02:46:07 -0500778 return (0);
779}
780#endif
781
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500782png_uint_32 PNGAPI
John Bowler4f67e402011-12-28 08:43:37 -0600783png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600784 png_uint_32 *width, png_uint_32 *height, int *bit_depth,
785 int *color_type, int *interlace_type, int *compression_type,
786 int *filter_type)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500787{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500788 png_debug1(1, "in %s retrieval function", "IHDR");
789
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500790 if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
791 height == NULL || bit_depth == NULL || color_type == NULL)
792 return (0);
793
794 *width = info_ptr->width;
795 *height = info_ptr->height;
796 *bit_depth = info_ptr->bit_depth;
797 *color_type = info_ptr->color_type;
798
799 if (compression_type != NULL)
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500800 *compression_type = info_ptr->compression_type;
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500801
802 if (filter_type != NULL)
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500803 *filter_type = info_ptr->filter_type;
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500804
805 if (interlace_type != NULL)
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500806 *interlace_type = info_ptr->interlace_type;
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500807
Glenn Randers-Pehrsonb35a7452009-09-30 23:12:13 -0500808 /* This is redundant if we can be sure that the info_ptr values were all
809 * assigned in png_set_IHDR(). We do the check anyhow in case an
810 * application has ignored our advice not to mess with the members
811 * of info_ptr directly.
812 */
Glenn Randers-Pehrsonad41b882011-12-22 07:31:13 -0600813 png_check_IHDR(png_ptr, info_ptr->width, info_ptr->height,
Glenn Randers-Pehrsonb35a7452009-09-30 23:12:13 -0500814 info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
815 info_ptr->compression_type, info_ptr->filter_type);
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500816
817 return (1);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500818}
819
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500820#ifdef PNG_oFFs_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500821png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600822png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600823 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500824{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500825 png_debug1(1, "in %s retrieval function", "oFFs");
826
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600827 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600828 && offset_x != NULL && offset_y != NULL && unit_type != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500829 {
Andreas Dilger47a0c421997-05-16 02:46:07 -0500830 *offset_x = info_ptr->x_offset;
831 *offset_y = info_ptr->y_offset;
832 *unit_type = (int)info_ptr->offset_unit_type;
833 return (PNG_INFO_oFFs);
834 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500835
Andreas Dilger47a0c421997-05-16 02:46:07 -0500836 return (0);
837}
838#endif
839
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500840#ifdef PNG_pCAL_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500841png_uint_32 PNGAPI
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600842png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600843 png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
844 png_charp *units, png_charpp *params)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500845{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500846 png_debug1(1, "in %s retrieval function", "pCAL");
847
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600848 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500849 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
850 nparams != NULL && units != NULL && params != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500851 {
Andreas Dilger47a0c421997-05-16 02:46:07 -0500852 *purpose = info_ptr->pcal_purpose;
853 *X0 = info_ptr->pcal_X0;
854 *X1 = info_ptr->pcal_X1;
855 *type = (int)info_ptr->pcal_type;
856 *nparams = (int)info_ptr->pcal_nparams;
857 *units = info_ptr->pcal_units;
858 *params = info_ptr->pcal_params;
859 return (PNG_INFO_pCAL);
860 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500861
Andreas Dilger47a0c421997-05-16 02:46:07 -0500862 return (0);
863}
864#endif
865
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500866#ifdef PNG_sCAL_SUPPORTED
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500867# ifdef PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600868# if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
869 defined(PNG_FLOATING_POINT_SUPPORTED)
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500870png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600871png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500872 int *unit, png_fixed_point *width, png_fixed_point *height)
873{
874 if (png_ptr != NULL && info_ptr != NULL &&
875 (info_ptr->valid & PNG_INFO_sCAL))
876 {
877 *unit = info_ptr->scal_unit;
John Bowler29fca0d2011-12-24 07:57:43 -0600878 /*TODO: make this work without FP support; the API is currently eliminated
879 * if neither floating point APIs nor internal floating point arithmetic
880 * are enabled.
881 */
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500882 *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width");
883 *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
884 "sCAL height");
885 return (PNG_INFO_sCAL);
886 }
887
888 return(0);
889}
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500890# endif /* FLOATING_ARITHMETIC */
891# endif /* FIXED_POINT */
892# ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500893png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600894png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600895 int *unit, double *width, double *height)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600896{
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600897 if (png_ptr != NULL && info_ptr != NULL &&
898 (info_ptr->valid & PNG_INFO_sCAL))
899 {
900 *unit = info_ptr->scal_unit;
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500901 *width = atof(info_ptr->scal_s_width);
902 *height = atof(info_ptr->scal_s_height);
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600903 return (PNG_INFO_sCAL);
904 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500905
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600906 return(0);
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600907}
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500908# endif /* FLOATING POINT */
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500909png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600910png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -0500911 int *unit, png_charpp width, png_charpp height)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600912{
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600913 if (png_ptr != NULL && info_ptr != NULL &&
914 (info_ptr->valid & PNG_INFO_sCAL))
915 {
916 *unit = info_ptr->scal_unit;
917 *width = info_ptr->scal_s_width;
918 *height = info_ptr->scal_s_height;
919 return (PNG_INFO_sCAL);
920 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500921
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600922 return(0);
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600923}
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500924#endif /* sCAL */
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600925
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500926#ifdef PNG_pHYs_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500927png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600928png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600929 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500930{
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600931 png_uint_32 retval = 0;
932
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500933 png_debug1(1, "in %s retrieval function", "pHYs");
934
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600935 if (png_ptr != NULL && info_ptr != NULL &&
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600936 (info_ptr->valid & PNG_INFO_pHYs))
Andreas Dilger47a0c421997-05-16 02:46:07 -0500937 {
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600938 if (res_x != NULL)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600939 {
940 *res_x = info_ptr->x_pixels_per_unit;
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600941 retval |= PNG_INFO_pHYs;
942 }
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500943
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600944 if (res_y != NULL)
945 {
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600946 *res_y = info_ptr->y_pixels_per_unit;
947 retval |= PNG_INFO_pHYs;
948 }
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500949
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600950 if (unit_type != NULL)
951 {
952 *unit_type = (int)info_ptr->phys_unit_type;
953 retval |= PNG_INFO_pHYs;
954 }
Andreas Dilger47a0c421997-05-16 02:46:07 -0500955 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500956
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600957 return (retval);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500958}
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500959#endif /* pHYs */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500960
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500961png_uint_32 PNGAPI
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600962png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr,
Glenn Randers-Pehrsonb86b4922011-01-21 23:12:51 -0600963 png_colorp *palette, int *num_palette)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500964{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500965 png_debug1(1, "in %s retrieval function", "PLTE");
966
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600967 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
968 && palette != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500969 {
Andreas Dilger47a0c421997-05-16 02:46:07 -0500970 *palette = info_ptr->palette;
971 *num_palette = info_ptr->num_palette;
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500972 png_debug1(3, "num_palette = %d", *num_palette);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500973 return (PNG_INFO_PLTE);
974 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500975
Andreas Dilger47a0c421997-05-16 02:46:07 -0500976 return (0);
977}
978
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500979#ifdef PNG_sBIT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500980png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600981png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,
Glenn Randers-Pehrsonb86b4922011-01-21 23:12:51 -0600982 png_color_8p *sig_bit)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500983{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500984 png_debug1(1, "in %s retrieval function", "sBIT");
985
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600986 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600987 && sig_bit != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500988 {
Andreas Dilger47a0c421997-05-16 02:46:07 -0500989 *sig_bit = &(info_ptr->sig_bit);
990 return (PNG_INFO_sBIT);
991 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500992
Andreas Dilger47a0c421997-05-16 02:46:07 -0500993 return (0);
994}
995#endif
996
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500997#ifdef PNG_TEXT_SUPPORTED
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600998int PNGAPI
999png_get_text(png_const_structrp png_ptr, png_inforp info_ptr,
Glenn Randers-Pehrsonb86b4922011-01-21 23:12:51 -06001000 png_textp *text_ptr, int *num_text)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001001{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001002 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001003 {
Glenn Randers-Pehrsonbb5cb142011-09-22 12:41:58 -05001004 png_debug1(1, "in 0x%lx retrieval function",
1005 (unsigned long)png_ptr->chunk_name);
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -05001006
Andreas Dilger47a0c421997-05-16 02:46:07 -05001007 if (text_ptr != NULL)
1008 *text_ptr = info_ptr->text;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -05001009
Andreas Dilger47a0c421997-05-16 02:46:07 -05001010 if (num_text != NULL)
1011 *num_text = info_ptr->num_text;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -05001012
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -06001013 return info_ptr->num_text;
Andreas Dilger47a0c421997-05-16 02:46:07 -05001014 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -05001015
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001016 if (num_text != NULL)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -06001017 *num_text = 0;
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -05001018
Andreas Dilger47a0c421997-05-16 02:46:07 -05001019 return(0);
1020}
1021#endif
1022
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -05001023#ifdef PNG_tIME_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001024png_uint_32 PNGAPI
John Bowler4f67e402011-12-28 08:43:37 -06001025png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
1026 png_timep *mod_time)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001027{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -05001028 png_debug1(1, "in %s retrieval function", "tIME");
1029
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001030 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
1031 && mod_time != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001032 {
Andreas Dilger47a0c421997-05-16 02:46:07 -05001033 *mod_time = &(info_ptr->mod_time);
1034 return (PNG_INFO_tIME);
1035 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -05001036
Andreas Dilger47a0c421997-05-16 02:46:07 -05001037 return (0);
1038}
1039#endif
1040
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -05001041#ifdef PNG_tRNS_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001042png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001043png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -06001044 png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001045{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001046 png_uint_32 retval = 0;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001047 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
Andreas Dilger47a0c421997-05-16 02:46:07 -05001048 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -05001049 png_debug1(1, "in %s retrieval function", "tRNS");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -05001050
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001051 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001052 {
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -06001053 if (trans_alpha != NULL)
1054 {
1055 *trans_alpha = info_ptr->trans_alpha;
1056 retval |= PNG_INFO_tRNS;
1057 }
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -05001058
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -06001059 if (trans_color != NULL)
1060 *trans_color = &(info_ptr->trans_color);
Andreas Dilger47a0c421997-05-16 02:46:07 -05001061 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -05001062
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001063 else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001064 {
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -06001065 if (trans_color != NULL)
1066 {
1067 *trans_color = &(info_ptr->trans_color);
1068 retval |= PNG_INFO_tRNS;
1069 }
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -05001070
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -06001071 if (trans_alpha != NULL)
1072 *trans_alpha = NULL;
Andreas Dilger47a0c421997-05-16 02:46:07 -05001073 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -05001074
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05001075 if (num_trans != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001076 {
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001077 *num_trans = info_ptr->num_trans;
1078 retval |= PNG_INFO_tRNS;
Andreas Dilger47a0c421997-05-16 02:46:07 -05001079 }
Andreas Dilger47a0c421997-05-16 02:46:07 -05001080 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -05001081
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001082 return (retval);
Andreas Dilger47a0c421997-05-16 02:46:07 -05001083}
1084#endif
1085
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -06001086#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -05001087int PNGAPI
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -06001088png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -06001089 png_unknown_chunkpp unknowns)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001090{
1091 if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05001092 {
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -06001093 *unknowns = info_ptr->unknown_chunks;
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -05001094 return info_ptr->unknown_chunks_num;
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05001095 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -05001096
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05001097 return (0);
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001098}
1099#endif
1100
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -05001101#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001102png_byte PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001103png_get_rgb_to_gray_status (png_const_structrp png_ptr)
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001104{
Glenn Randers-Pehrsona565f0e2010-03-06 08:24:45 -06001105 return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001106}
1107#endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001108
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -05001109#ifdef PNG_USER_CHUNKS_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001110png_voidp PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001111png_get_user_chunk_ptr(png_const_structrp png_ptr)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001112{
Glenn Randers-Pehrsona565f0e2010-03-06 08:24:45 -06001113 return (png_ptr ? png_ptr->user_chunk_ptr : NULL);
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001114}
1115#endif
1116
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001117png_size_t PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001118png_get_compression_buffer_size(png_const_structrp png_ptr)
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05001119{
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -06001120 if (png_ptr == NULL)
1121 return 0;
1122
1123# ifdef PNG_WRITE_SUPPORTED
1124 if (png_ptr->mode & PNG_IS_READ_STRUCT)
1125# endif
1126 {
1127# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
1128 return png_ptr->IDAT_read_size;
1129# else
1130 return PNG_IDAT_READ_SIZE;
1131# endif
1132 }
1133
1134# ifdef PNG_WRITE_SUPPORTED
1135 else
1136 return png_ptr->zbuffer_size;
1137# endif
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05001138}
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -05001139
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -05001140#ifdef PNG_SET_USER_LIMITS_SUPPORTED
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06001141/* These functions were added to libpng 1.2.6 and were enabled
1142 * by default in libpng-1.4.0 */
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -05001143png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001144png_get_user_width_max (png_const_structrp png_ptr)
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -05001145{
Glenn Randers-Pehrsona565f0e2010-03-06 08:24:45 -06001146 return (png_ptr ? png_ptr->user_width_max : 0);
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -05001147}
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -05001148
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -05001149png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001150png_get_user_height_max (png_const_structrp png_ptr)
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -05001151{
Glenn Randers-Pehrsona565f0e2010-03-06 08:24:45 -06001152 return (png_ptr ? png_ptr->user_height_max : 0);
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -05001153}
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -05001154
Glenn Randers-Pehrson17ca3402009-11-09 06:51:16 -06001155/* This function was added to libpng 1.4.0 */
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -05001156png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001157png_get_chunk_cache_max (png_const_structrp png_ptr)
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -05001158{
Glenn Randers-Pehrsona565f0e2010-03-06 08:24:45 -06001159 return (png_ptr ? png_ptr->user_chunk_cache_max : 0);
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06001160}
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -05001161
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06001162/* This function was added to libpng 1.4.1 */
Glenn Randers-Pehrson7a5be532010-02-14 07:16:19 -06001163png_alloc_size_t PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001164png_get_chunk_malloc_max (png_const_structrp png_ptr)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06001165{
Glenn Randers-Pehrsona565f0e2010-03-06 08:24:45 -06001166 return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -05001167}
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -05001168#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
Glenn Randers-Pehrsond60c8862009-06-15 21:56:14 -05001169
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06001170/* These functions were added to libpng 1.4.0 */
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001171#ifdef PNG_IO_STATE_SUPPORTED
1172png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001173png_get_io_state (png_const_structrp png_ptr)
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001174{
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -06001175 return png_ptr->io_state;
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001176}
1177
Glenn Randers-Pehrsona63dbed2011-01-22 08:51:19 -06001178png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001179png_get_io_chunk_type (png_const_structrp png_ptr)
Glenn Randers-Pehrsona63dbed2011-01-22 08:51:19 -06001180{
Glenn Randers-Pehrsonbb5cb142011-09-22 12:41:58 -05001181 return png_ptr->chunk_name;
Glenn Randers-Pehrsona63dbed2011-01-22 08:51:19 -06001182}
Glenn Randers-Pehrsonf3af7062012-02-02 23:11:45 -06001183#endif /* ?PNG_IO_STATE_SUPPORTED */
Glenn Randers-Pehrson32d6a742013-02-04 20:07:43 -06001184
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -06001185#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
1186# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
1187int PNGAPI
1188png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr)
1189{
1190 if (png_ptr != NULL && info_ptr != NULL)
1191 return png_ptr->num_palette_max;
1192
1193 return (-1);
1194}
1195# endif
1196#endif
1197
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -06001198#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */