blob: f92172385557df98bcaa76e1371ef2687cc6cdff [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-Pehrson67ee8ce2011-12-22 08:21:00 -06004 * Last changed in libpng 1.6.0 [(PENDING RELEASE)]
Glenn Randers-Pehrson1531bd62012-01-01 14:45:04 -06005 * Copyright (c) 1998-2012 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
John Bowler5d567862011-12-24 09:12:00 -0600115png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600116{
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500117#ifdef PNG_pHYs_SUPPORTED
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500118 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
119 {
120 png_debug1(1, "in %s retrieval function",
121 "png_get_x_pixels_per_meter");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500122
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500123 if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
124 return (info_ptr->x_pixels_per_unit);
125 }
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600126#endif
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500127
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600128 return (0);
129}
130
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500131png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600132png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600133{
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500134#ifdef PNG_pHYs_SUPPORTED
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500135 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600136 {
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500137 png_debug1(1, "in %s retrieval function",
138 "png_get_y_pixels_per_meter");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500139
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500140 if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600141 return (info_ptr->y_pixels_per_unit);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600142 }
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600143#endif
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500144
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600145 return (0);
146}
147
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500148png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600149png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600150{
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500151#ifdef PNG_pHYs_SUPPORTED
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500152 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600153 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500154 png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500155
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500156 if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER &&
157 info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600158 return (info_ptr->x_pixels_per_unit);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600159 }
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600160#endif
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500161
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600162 return (0);
163}
164
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600165#ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500166float PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600167png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600168{
Glenn Randers-Pehrson4009a762010-07-31 06:34:36 -0500169#ifdef PNG_READ_pHYs_SUPPORTED
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500170 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600171 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500172 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500173
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500174 if (info_ptr->x_pixels_per_unit != 0)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500175 return ((float)((float)info_ptr->y_pixels_per_unit
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600176 /(float)info_ptr->x_pixels_per_unit));
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600177 }
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600178#endif
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500179
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500180 return ((float)0.0);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600181}
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600182#endif
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600183
Glenn Randers-Pehrson4009a762010-07-31 06:34:36 -0500184#ifdef PNG_FIXED_POINT_SUPPORTED
185png_fixed_point PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600186png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
187 png_const_inforp info_ptr)
Glenn Randers-Pehrson4009a762010-07-31 06:34:36 -0500188{
189#ifdef PNG_READ_pHYs_SUPPORTED
190 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -0500191 && info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0
192 && info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX
193 && info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX)
Glenn Randers-Pehrson4009a762010-07-31 06:34:36 -0500194 {
195 png_fixed_point res;
196
197 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio_fixed");
198
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -0500199 /* The following casts work because a PNG 4 byte integer only has a valid
200 * range of 0..2^31-1; otherwise the cast might overflow.
201 */
202 if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1,
203 (png_int_32)info_ptr->x_pixels_per_unit))
Glenn Randers-Pehrson3df324d2010-07-31 13:45:04 -0500204 return res;
Glenn Randers-Pehrson4009a762010-07-31 06:34:36 -0500205 }
206#endif
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500207
Glenn Randers-Pehrson4009a762010-07-31 06:34:36 -0500208 return 0;
209}
210#endif
211
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500212png_int_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600213png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600214{
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500215#ifdef PNG_oFFs_SUPPORTED
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500216 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600217 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500218 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500219
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500220 if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600221 return (info_ptr->x_offset);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600222 }
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600223#endif
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500224
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600225 return (0);
226}
227
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500228png_int_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600229png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600230{
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500231#ifdef PNG_oFFs_SUPPORTED
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500232 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600233 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500234 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500235
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500236 if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600237 return (info_ptr->y_offset);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600238 }
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600239#endif
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500240
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600241 return (0);
242}
243
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500244png_int_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600245png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600246{
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500247#ifdef PNG_oFFs_SUPPORTED
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500248 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600249 {
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500250 png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500251
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500252 if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600253 return (info_ptr->x_offset);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600254 }
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600255#endif
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500256
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600257 return (0);
258}
259
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500260png_int_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600261png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600262{
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500263#ifdef PNG_oFFs_SUPPORTED
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500264 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600265 {
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500266 png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels");
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500267
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500268 if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600269 return (info_ptr->y_offset);
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600270 }
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600271#endif
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500272
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600273 return (0);
274}
275
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500276#ifdef PNG_INCH_CONVERSIONS_SUPPORTED
277static png_uint_32
278ppi_from_ppm(png_uint_32 ppm)
279{
280#if 0
Glenn Randers-Pehrson233357e2010-07-29 21:49:38 -0500281 /* The conversion is *(2.54/100), in binary (32 digits):
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500282 * .00000110100000001001110101001001
283 */
284 png_uint_32 t1001, t1101;
285 ppm >>= 1; /* .1 */
286 t1001 = ppm + (ppm >> 3); /* .1001 */
287 t1101 = t1001 + (ppm >> 1); /* .1101 */
288 ppm >>= 20; /* .000000000000000000001 */
289 t1101 += t1101 >> 15; /* .1101000000000001101 */
290 t1001 >>= 11; /* .000000000001001 */
291 t1001 += t1001 >> 12; /* .000000000001001000000001001 */
292 ppm += t1001; /* .000000000001001000001001001 */
293 ppm += t1101; /* .110100000001001110101001001 */
294 return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */
295#else
296 /* The argument is a PNG unsigned integer, so it is not permitted
297 * to be bigger than 2^31.
298 */
299 png_fixed_point result;
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -0500300 if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127,
301 5000))
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500302 return result;
303
304 /* Overflow. */
305 return 0;
306#endif
307}
308
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500309png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600310png_get_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600311{
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500312 return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr));
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600313}
314
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500315png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600316png_get_x_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600317{
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500318 return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr));
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600319}
320
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500321png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600322png_get_y_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600323{
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500324 return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr));
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600325}
326
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500327#ifdef PNG_FIXED_POINT_SUPPORTED
328static png_fixed_point
John Bowler5d567862011-12-24 09:12:00 -0600329png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns)
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500330{
331 /* Convert from metres * 1,000,000 to inches * 100,000, meters to
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500332 * inches is simply *(100/2.54), so we want *(10/2.54) == 500/127.
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500333 * Notice that this can overflow - a warning is output and 0 is
334 * returned.
335 */
336 return png_muldiv_warn(png_ptr, microns, 500, 127);
337}
338
339png_fixed_point PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600340png_get_x_offset_inches_fixed(png_const_structrp png_ptr,
341 png_const_inforp info_ptr)
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500342{
343 return png_fixed_inches_from_microns(png_ptr,
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -0500344 png_get_x_offset_microns(png_ptr, info_ptr));
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500345}
346#endif
347
348#ifdef PNG_FIXED_POINT_SUPPORTED
349png_fixed_point PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600350png_get_y_offset_inches_fixed(png_const_structrp png_ptr,
351 png_const_inforp info_ptr)
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500352{
353 return png_fixed_inches_from_microns(png_ptr,
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -0500354 png_get_y_offset_microns(png_ptr, info_ptr));
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500355}
356#endif
357
358#ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500359float PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600360png_get_x_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600361{
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500362 /* To avoid the overflow do the conversion directly in floating
363 * point.
364 */
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -0500365 return (float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600366}
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500367#endif
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600368
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500369#ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500370float PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600371png_get_y_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600372{
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500373 /* To avoid the overflow do the conversion directly in floating
374 * point.
375 */
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -0500376 return (float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600377}
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500378#endif
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600379
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500380#ifdef PNG_pHYs_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500381png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600382png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600383 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600384{
385 png_uint_32 retval = 0;
386
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600387 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600388 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500389 png_debug1(1, "in %s retrieval function", "pHYs");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500390
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600391 if (res_x != NULL)
392 {
393 *res_x = info_ptr->x_pixels_per_unit;
394 retval |= PNG_INFO_pHYs;
395 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500396
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600397 if (res_y != NULL)
398 {
399 *res_y = info_ptr->y_pixels_per_unit;
400 retval |= PNG_INFO_pHYs;
401 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500402
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600403 if (unit_type != NULL)
404 {
405 *unit_type = (int)info_ptr->phys_unit_type;
406 retval |= PNG_INFO_pHYs;
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -0500407
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500408 if (*unit_type == 1)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600409 {
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600410 if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
411 if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600412 }
413 }
414 }
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500415
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600416 return (retval);
417}
Glenn Randers-Pehrson3097f612001-05-07 14:52:45 -0500418#endif /* PNG_pHYs_SUPPORTED */
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500419#endif /* PNG_INCH_CONVERSIONS_SUPPORTED */
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600420
421/* png_get_channels really belongs in here, too, but it's been around longer */
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500422
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600423#endif /* PNG_EASY_ACCESS_SUPPORTED */
424
Glenn Randers-Pehrson4430b912012-08-09 22:24:04 -0500425
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500426png_byte PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600427png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500428{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600429 if (png_ptr != NULL && info_ptr != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500430 return(info_ptr->channels);
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500431
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500432 return (0);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500433}
434
Glenn Randers-Pehrson5d1df4f2012-08-10 07:49:44 -0500435#ifdef PNG_READ_SUPPORTED
Glenn Randers-Pehrsone600c512010-08-18 07:25:46 -0500436png_const_bytep PNGAPI
John Bowler4f67e402011-12-28 08:43:37 -0600437png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500438{
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600439 if (png_ptr != NULL && info_ptr != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500440 return(info_ptr->signature);
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500441
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500442 return (NULL);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500443}
Glenn Randers-Pehrson4430b912012-08-09 22:24:04 -0500444#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500445
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500446#ifdef PNG_bKGD_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500447png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600448png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
Andreas Dilger47a0c421997-05-16 02:46:07 -0500449 png_color_16p *background)
450{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600451 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600452 && background != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500453 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500454 png_debug1(1, "in %s retrieval function", "bKGD");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500455
Andreas Dilger47a0c421997-05-16 02:46:07 -0500456 *background = &(info_ptr->background);
457 return (PNG_INFO_bKGD);
458 }
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500459
Andreas Dilger47a0c421997-05-16 02:46:07 -0500460 return (0);
461}
462#endif
463
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500464#ifdef PNG_cHRM_SUPPORTED
John Bowler736f40f2011-08-25 16:19:44 -0500465/* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the
466 * same time to correct the rgb grayscale coefficient defaults obtained from the
467 * cHRM chunk in 1.5.4
468 */
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500469# ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500470png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600471png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600472 double *white_x, double *white_y, double *red_x, double *red_y,
473 double *green_x, double *green_y, double *blue_x, double *blue_y)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500474{
John Bowlerb11b31a2012-03-21 07:55:46 -0500475 /* Quiet API change: this code used to only return the end points if a cHRM
476 * chunk was present, but the end points can also come from iCCP or sRGB
477 * chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and
478 * the png_set_ APIs merely check that set end points are mutually
479 * consistent.
480 */
481 if (png_ptr != NULL && info_ptr != NULL &&
482 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
Andreas Dilger47a0c421997-05-16 02:46:07 -0500483 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500484 png_debug1(1, "in %s retrieval function", "cHRM");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -0500485
Andreas Dilger47a0c421997-05-16 02:46:07 -0500486 if (white_x != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500487 *white_x = png_float(png_ptr,
488 info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
Andreas Dilger47a0c421997-05-16 02:46:07 -0500489 if (white_y != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500490 *white_y = png_float(png_ptr,
491 info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y");
Andreas Dilger47a0c421997-05-16 02:46:07 -0500492 if (red_x != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500493 *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx,
494 "cHRM red X");
Andreas Dilger47a0c421997-05-16 02:46:07 -0500495 if (red_y != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500496 *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy,
497 "cHRM red Y");
Andreas Dilger47a0c421997-05-16 02:46:07 -0500498 if (green_x != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500499 *green_x = png_float(png_ptr,
500 info_ptr->colorspace.end_points_xy.greenx, "cHRM green X");
Andreas Dilger47a0c421997-05-16 02:46:07 -0500501 if (green_y != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500502 *green_y = png_float(png_ptr,
503 info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y");
Andreas Dilger47a0c421997-05-16 02:46:07 -0500504 if (blue_x != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500505 *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex,
506 "cHRM blue X");
Andreas Dilger47a0c421997-05-16 02:46:07 -0500507 if (blue_y != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500508 *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,
509 "cHRM blue Y");
Andreas Dilger47a0c421997-05-16 02:46:07 -0500510 return (PNG_INFO_cHRM);
511 }
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500512
Andreas Dilger47a0c421997-05-16 02:46:07 -0500513 return (0);
514}
John Bowler736f40f2011-08-25 16:19:44 -0500515
516png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600517png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
John Bowler736f40f2011-08-25 16:19:44 -0500518 double *red_X, double *red_Y, double *red_Z, double *green_X,
519 double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
520 double *blue_Z)
521{
John Bowlerb11b31a2012-03-21 07:55:46 -0500522 if (png_ptr != NULL && info_ptr != NULL &&
523 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
John Bowler736f40f2011-08-25 16:19:44 -0500524 {
John Bowlerb11b31a2012-03-21 07:55:46 -0500525 png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
526
John Bowler736f40f2011-08-25 16:19:44 -0500527 if (red_X != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500528 *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.redX,
529 "cHRM red X");
John Bowler736f40f2011-08-25 16:19:44 -0500530 if (red_Y != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500531 *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.redY,
532 "cHRM red Y");
John Bowler736f40f2011-08-25 16:19:44 -0500533 if (red_Z != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500534 *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.redZ,
535 "cHRM red Z");
John Bowler736f40f2011-08-25 16:19:44 -0500536 if (green_X != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500537 *green_X = png_float(png_ptr,
538 info_ptr->colorspace.end_points_XYZ.greenX, "cHRM green X");
John Bowler736f40f2011-08-25 16:19:44 -0500539 if (green_Y != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500540 *green_Y = png_float(png_ptr,
541 info_ptr->colorspace.end_points_XYZ.greenY, "cHRM green Y");
John Bowler736f40f2011-08-25 16:19:44 -0500542 if (green_Z != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500543 *green_Z = png_float(png_ptr,
544 info_ptr->colorspace.end_points_XYZ.greenZ, "cHRM green Z");
John Bowler736f40f2011-08-25 16:19:44 -0500545 if (blue_X != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500546 *blue_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.blueX,
547 "cHRM blue X");
John Bowler736f40f2011-08-25 16:19:44 -0500548 if (blue_Y != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500549 *blue_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.blueY,
550 "cHRM blue Y");
John Bowler736f40f2011-08-25 16:19:44 -0500551 if (blue_Z != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500552 *blue_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.blueZ,
553 "cHRM blue Z");
John Bowler736f40f2011-08-25 16:19:44 -0500554 return (PNG_INFO_cHRM);
555 }
556
557 return (0);
558}
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500559# endif
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500560
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500561# ifdef PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500562png_uint_32 PNGAPI
John Bowlerb11b31a2012-03-21 07:55:46 -0500563png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
564 png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
565 png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
566 png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
567 png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
568 png_fixed_point *int_blue_Z)
569{
570 if (png_ptr != NULL && info_ptr != NULL &&
571 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
572 {
573 png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
574
575 if (int_red_X != NULL)
576 *int_red_X = info_ptr->colorspace.end_points_XYZ.redX;
577 if (int_red_Y != NULL)
578 *int_red_Y = info_ptr->colorspace.end_points_XYZ.redY;
579 if (int_red_Z != NULL)
580 *int_red_Z = info_ptr->colorspace.end_points_XYZ.redZ;
581 if (int_green_X != NULL)
582 *int_green_X = info_ptr->colorspace.end_points_XYZ.greenX;
583 if (int_green_Y != NULL)
584 *int_green_Y = info_ptr->colorspace.end_points_XYZ.greenY;
585 if (int_green_Z != NULL)
586 *int_green_Z = info_ptr->colorspace.end_points_XYZ.greenZ;
587 if (int_blue_X != NULL)
588 *int_blue_X = info_ptr->colorspace.end_points_XYZ.blueX;
589 if (int_blue_Y != NULL)
590 *int_blue_Y = info_ptr->colorspace.end_points_XYZ.blueY;
591 if (int_blue_Z != NULL)
592 *int_blue_Z = info_ptr->colorspace.end_points_XYZ.blueZ;
593 return (PNG_INFO_cHRM);
594 }
595
596 return (0);
597}
598
599png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600600png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600601 png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
602 png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
603 png_fixed_point *blue_x, png_fixed_point *blue_y)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600604{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500605 png_debug1(1, "in %s retrieval function", "cHRM");
606
John Bowlerb11b31a2012-03-21 07:55:46 -0500607 if (png_ptr != NULL && info_ptr != NULL &&
608 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600609 {
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600610 if (white_x != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500611 *white_x = info_ptr->colorspace.end_points_xy.whitex;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600612 if (white_y != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500613 *white_y = info_ptr->colorspace.end_points_xy.whitey;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600614 if (red_x != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500615 *red_x = info_ptr->colorspace.end_points_xy.redx;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600616 if (red_y != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500617 *red_y = info_ptr->colorspace.end_points_xy.redy;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600618 if (green_x != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500619 *green_x = info_ptr->colorspace.end_points_xy.greenx;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600620 if (green_y != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500621 *green_y = info_ptr->colorspace.end_points_xy.greeny;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600622 if (blue_x != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500623 *blue_x = info_ptr->colorspace.end_points_xy.bluex;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600624 if (blue_y != NULL)
John Bowlerb11b31a2012-03-21 07:55:46 -0500625 *blue_y = info_ptr->colorspace.end_points_xy.bluey;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600626 return (PNG_INFO_cHRM);
627 }
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500628
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600629 return (0);
630}
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500631# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600632#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500633
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500634#ifdef PNG_gAMA_SUPPORTED
John Bowlerb11b31a2012-03-21 07:55:46 -0500635# ifdef PNG_FIXED_POINT_SUPPORTED
636png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600637png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500638 png_fixed_point *file_gamma)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500639{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500640 png_debug1(1, "in %s retrieval function", "gAMA");
641
John Bowlerb11b31a2012-03-21 07:55:46 -0500642 if (png_ptr != NULL && info_ptr != NULL &&
643 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
644 file_gamma != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500645 {
John Bowlerb11b31a2012-03-21 07:55:46 -0500646 *file_gamma = info_ptr->colorspace.gamma;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500647 return (PNG_INFO_gAMA);
648 }
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500649
Andreas Dilger47a0c421997-05-16 02:46:07 -0500650 return (0);
651}
John Bowlerb11b31a2012-03-21 07:55:46 -0500652# endif
653
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500654# ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500655png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600656png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrsonb86b4922011-01-21 23:12:51 -0600657 double *file_gamma)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600658{
John Bowlerb11b31a2012-03-21 07:55:46 -0500659 png_debug1(1, "in %s retrieval function", "gAMA(float)");
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500660
John Bowlerb11b31a2012-03-21 07:55:46 -0500661 if (png_ptr != NULL && info_ptr != NULL &&
662 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
663 file_gamma != NULL)
664 {
665 *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
666 "png_get_gAMA");
667 return (PNG_INFO_gAMA);
668 }
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500669
John Bowlerb11b31a2012-03-21 07:55:46 -0500670 return (0);
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600671}
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500672# endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500673#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500674
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500675#ifdef PNG_sRGB_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500676png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600677png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrsonb86b4922011-01-21 23:12:51 -0600678 int *file_srgb_intent)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600679{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500680 png_debug1(1, "in %s retrieval function", "sRGB");
681
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600682 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600683 && file_srgb_intent != NULL)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600684 {
John Bowlerb11b31a2012-03-21 07:55:46 -0500685 *file_srgb_intent = info_ptr->colorspace.rendering_intent;
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600686 return (PNG_INFO_sRGB);
687 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500688
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600689 return (0);
690}
691#endif
692
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500693#ifdef PNG_iCCP_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500694png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600695png_get_iCCP(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600696 png_charpp name, int *compression_type,
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500697 png_bytepp profile, png_uint_32 *proflen)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600698{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500699 png_debug1(1, "in %s retrieval function", "iCCP");
700
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600701 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
John Bowler88bcdc22011-11-04 20:11:16 -0500702 && name != NULL && compression_type != NULL && profile != NULL &&
703 proflen != NULL)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600704 {
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600705 *name = info_ptr->iccp_name;
706 *profile = info_ptr->iccp_profile;
John Bowlerb11b31a2012-03-21 07:55:46 -0500707 *proflen = png_get_uint_32(info_ptr->iccp_profile);
708 /* This is somewhat irrelevant since the profile data returned has
709 * actually been uncompressed.
Glenn Randers-Pehrson4bb4d012009-05-20 12:45:29 -0500710 */
John Bowlerb11b31a2012-03-21 07:55:46 -0500711 *compression_type = PNG_COMPRESSION_TYPE_BASE;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600712 return (PNG_INFO_iCCP);
713 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500714
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600715 return (0);
716}
717#endif
718
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500719#ifdef PNG_sPLT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500720png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600721png_get_sPLT(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600722 png_sPLT_tpp spalettes)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600723{
724 if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500725 {
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600726 *spalettes = info_ptr->splt_palettes;
727 return ((png_uint_32)info_ptr->splt_palettes_num);
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500728 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500729
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500730 return (0);
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600731}
732#endif
733
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500734#ifdef PNG_hIST_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500735png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600736png_get_hIST(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrsonb86b4922011-01-21 23:12:51 -0600737 png_uint_16p *hist)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500738{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500739 png_debug1(1, "in %s retrieval function", "hIST");
740
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600741 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600742 && hist != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500743 {
Andreas Dilger47a0c421997-05-16 02:46:07 -0500744 *hist = info_ptr->hist;
745 return (PNG_INFO_hIST);
746 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500747
Andreas Dilger47a0c421997-05-16 02:46:07 -0500748 return (0);
749}
750#endif
751
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500752png_uint_32 PNGAPI
John Bowler4f67e402011-12-28 08:43:37 -0600753png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600754 png_uint_32 *width, png_uint_32 *height, int *bit_depth,
755 int *color_type, int *interlace_type, int *compression_type,
756 int *filter_type)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500757{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500758 png_debug1(1, "in %s retrieval function", "IHDR");
759
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500760 if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
761 height == NULL || bit_depth == NULL || color_type == NULL)
762 return (0);
763
764 *width = info_ptr->width;
765 *height = info_ptr->height;
766 *bit_depth = info_ptr->bit_depth;
767 *color_type = info_ptr->color_type;
768
769 if (compression_type != NULL)
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500770 *compression_type = info_ptr->compression_type;
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500771
772 if (filter_type != NULL)
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500773 *filter_type = info_ptr->filter_type;
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500774
775 if (interlace_type != NULL)
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500776 *interlace_type = info_ptr->interlace_type;
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500777
Glenn Randers-Pehrsonb35a7452009-09-30 23:12:13 -0500778 /* This is redundant if we can be sure that the info_ptr values were all
779 * assigned in png_set_IHDR(). We do the check anyhow in case an
780 * application has ignored our advice not to mess with the members
781 * of info_ptr directly.
782 */
Glenn Randers-Pehrsonad41b882011-12-22 07:31:13 -0600783 png_check_IHDR(png_ptr, info_ptr->width, info_ptr->height,
Glenn Randers-Pehrsonb35a7452009-09-30 23:12:13 -0500784 info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
785 info_ptr->compression_type, info_ptr->filter_type);
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500786
787 return (1);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500788}
789
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500790#ifdef PNG_oFFs_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500791png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600792png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600793 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500794{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500795 png_debug1(1, "in %s retrieval function", "oFFs");
796
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600797 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600798 && offset_x != NULL && offset_y != NULL && unit_type != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500799 {
Andreas Dilger47a0c421997-05-16 02:46:07 -0500800 *offset_x = info_ptr->x_offset;
801 *offset_y = info_ptr->y_offset;
802 *unit_type = (int)info_ptr->offset_unit_type;
803 return (PNG_INFO_oFFs);
804 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500805
Andreas Dilger47a0c421997-05-16 02:46:07 -0500806 return (0);
807}
808#endif
809
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500810#ifdef PNG_pCAL_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500811png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600812png_get_pCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600813 png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
814 png_charp *units, png_charpp *params)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500815{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500816 png_debug1(1, "in %s retrieval function", "pCAL");
817
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600818 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500819 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
820 nparams != NULL && units != NULL && params != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500821 {
Andreas Dilger47a0c421997-05-16 02:46:07 -0500822 *purpose = info_ptr->pcal_purpose;
823 *X0 = info_ptr->pcal_X0;
824 *X1 = info_ptr->pcal_X1;
825 *type = (int)info_ptr->pcal_type;
826 *nparams = (int)info_ptr->pcal_nparams;
827 *units = info_ptr->pcal_units;
828 *params = info_ptr->pcal_params;
829 return (PNG_INFO_pCAL);
830 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500831
Andreas Dilger47a0c421997-05-16 02:46:07 -0500832 return (0);
833}
834#endif
835
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500836#ifdef PNG_sCAL_SUPPORTED
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500837# ifdef PNG_FIXED_POINT_SUPPORTED
John Bowler29fca0d2011-12-24 07:57:43 -0600838# if (defined PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
839 (defined PNG_FLOATING_POINT_SUPPORTED)
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500840png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600841png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500842 int *unit, png_fixed_point *width, png_fixed_point *height)
843{
844 if (png_ptr != NULL && info_ptr != NULL &&
845 (info_ptr->valid & PNG_INFO_sCAL))
846 {
847 *unit = info_ptr->scal_unit;
John Bowler29fca0d2011-12-24 07:57:43 -0600848 /*TODO: make this work without FP support; the API is currently eliminated
849 * if neither floating point APIs nor internal floating point arithmetic
850 * are enabled.
851 */
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500852 *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width");
853 *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
854 "sCAL height");
855 return (PNG_INFO_sCAL);
856 }
857
858 return(0);
859}
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500860# endif /* FLOATING_ARITHMETIC */
861# endif /* FIXED_POINT */
862# ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500863png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600864png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600865 int *unit, double *width, double *height)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600866{
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600867 if (png_ptr != NULL && info_ptr != NULL &&
868 (info_ptr->valid & PNG_INFO_sCAL))
869 {
870 *unit = info_ptr->scal_unit;
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500871 *width = atof(info_ptr->scal_s_width);
872 *height = atof(info_ptr->scal_s_height);
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600873 return (PNG_INFO_sCAL);
874 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500875
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600876 return(0);
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600877}
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500878# endif /* FLOATING POINT */
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500879png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600880png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -0500881 int *unit, png_charpp width, png_charpp height)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600882{
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600883 if (png_ptr != NULL && info_ptr != NULL &&
884 (info_ptr->valid & PNG_INFO_sCAL))
885 {
886 *unit = info_ptr->scal_unit;
887 *width = info_ptr->scal_s_width;
888 *height = info_ptr->scal_s_height;
889 return (PNG_INFO_sCAL);
890 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500891
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600892 return(0);
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600893}
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500894#endif /* sCAL */
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600895
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500896#ifdef PNG_pHYs_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500897png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600898png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600899 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500900{
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600901 png_uint_32 retval = 0;
902
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500903 png_debug1(1, "in %s retrieval function", "pHYs");
904
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600905 if (png_ptr != NULL && info_ptr != NULL &&
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600906 (info_ptr->valid & PNG_INFO_pHYs))
Andreas Dilger47a0c421997-05-16 02:46:07 -0500907 {
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600908 if (res_x != NULL)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600909 {
910 *res_x = info_ptr->x_pixels_per_unit;
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600911 retval |= PNG_INFO_pHYs;
912 }
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500913
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600914 if (res_y != NULL)
915 {
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600916 *res_y = info_ptr->y_pixels_per_unit;
917 retval |= PNG_INFO_pHYs;
918 }
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500919
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600920 if (unit_type != NULL)
921 {
922 *unit_type = (int)info_ptr->phys_unit_type;
923 retval |= PNG_INFO_pHYs;
924 }
Andreas Dilger47a0c421997-05-16 02:46:07 -0500925 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500926
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600927 return (retval);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500928}
Glenn Randers-Pehrson5c5f5932010-10-23 10:14:42 -0500929#endif /* pHYs */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500930
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500931png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600932png_get_PLTE(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrsonb86b4922011-01-21 23:12:51 -0600933 png_colorp *palette, int *num_palette)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500934{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500935 png_debug1(1, "in %s retrieval function", "PLTE");
936
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600937 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
938 && palette != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500939 {
Andreas Dilger47a0c421997-05-16 02:46:07 -0500940 *palette = info_ptr->palette;
941 *num_palette = info_ptr->num_palette;
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500942 png_debug1(3, "num_palette = %d", *num_palette);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500943 return (PNG_INFO_PLTE);
944 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500945
Andreas Dilger47a0c421997-05-16 02:46:07 -0500946 return (0);
947}
948
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500949#ifdef PNG_sBIT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500950png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600951png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,
Glenn Randers-Pehrsonb86b4922011-01-21 23:12:51 -0600952 png_color_8p *sig_bit)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500953{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500954 png_debug1(1, "in %s retrieval function", "sBIT");
955
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600956 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600957 && sig_bit != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500958 {
Andreas Dilger47a0c421997-05-16 02:46:07 -0500959 *sig_bit = &(info_ptr->sig_bit);
960 return (PNG_INFO_sBIT);
961 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500962
Andreas Dilger47a0c421997-05-16 02:46:07 -0500963 return (0);
964}
965#endif
966
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500967#ifdef PNG_TEXT_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500968png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -0600969png_get_text(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrsonb86b4922011-01-21 23:12:51 -0600970 png_textp *text_ptr, int *num_text)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500971{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600972 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500973 {
Glenn Randers-Pehrsonbb5cb142011-09-22 12:41:58 -0500974 png_debug1(1, "in 0x%lx retrieval function",
975 (unsigned long)png_ptr->chunk_name);
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500976
Andreas Dilger47a0c421997-05-16 02:46:07 -0500977 if (text_ptr != NULL)
978 *text_ptr = info_ptr->text;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500979
Andreas Dilger47a0c421997-05-16 02:46:07 -0500980 if (num_text != NULL)
981 *num_text = info_ptr->num_text;
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -0500982
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600983 return ((png_uint_32)info_ptr->num_text);
Andreas Dilger47a0c421997-05-16 02:46:07 -0500984 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500985
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600986 if (num_text != NULL)
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -0600987 *num_text = 0;
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -0500988
Andreas Dilger47a0c421997-05-16 02:46:07 -0500989 return(0);
990}
991#endif
992
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -0500993#ifdef PNG_tIME_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500994png_uint_32 PNGAPI
John Bowler4f67e402011-12-28 08:43:37 -0600995png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
996 png_timep *mod_time)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500997{
Glenn Randers-Pehrsonb3ce3652009-08-15 21:47:03 -0500998 png_debug1(1, "in %s retrieval function", "tIME");
999
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001000 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
1001 && mod_time != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001002 {
Andreas Dilger47a0c421997-05-16 02:46:07 -05001003 *mod_time = &(info_ptr->mod_time);
1004 return (PNG_INFO_tIME);
1005 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -05001006
Andreas Dilger47a0c421997-05-16 02:46:07 -05001007 return (0);
1008}
1009#endif
1010
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -05001011#ifdef PNG_tRNS_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001012png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001013png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -06001014 png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001015{
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001016 png_uint_32 retval = 0;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001017 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
Andreas Dilger47a0c421997-05-16 02:46:07 -05001018 {
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -05001019 png_debug1(1, "in %s retrieval function", "tRNS");
Glenn Randers-Pehrsonda009802009-08-15 13:25:47 -05001020
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001021 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001022 {
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -06001023 if (trans_alpha != NULL)
1024 {
1025 *trans_alpha = info_ptr->trans_alpha;
1026 retval |= PNG_INFO_tRNS;
1027 }
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -05001028
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -06001029 if (trans_color != NULL)
1030 *trans_color = &(info_ptr->trans_color);
Andreas Dilger47a0c421997-05-16 02:46:07 -05001031 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -05001032
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001033 else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001034 {
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -06001035 if (trans_color != NULL)
1036 {
1037 *trans_color = &(info_ptr->trans_color);
1038 retval |= PNG_INFO_tRNS;
1039 }
Glenn Randers-Pehrson glennrp@comcast.netb1c0d332009-05-15 20:39:34 -05001040
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -06001041 if (trans_alpha != NULL)
1042 *trans_alpha = NULL;
Andreas Dilger47a0c421997-05-16 02:46:07 -05001043 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -05001044
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05001045 if (num_trans != NULL)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001046 {
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001047 *num_trans = info_ptr->num_trans;
1048 retval |= PNG_INFO_tRNS;
Andreas Dilger47a0c421997-05-16 02:46:07 -05001049 }
Andreas Dilger47a0c421997-05-16 02:46:07 -05001050 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -05001051
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001052 return (retval);
Andreas Dilger47a0c421997-05-16 02:46:07 -05001053}
1054#endif
1055
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -05001056#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -05001057int PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001058png_get_unknown_chunks(png_const_structrp png_ptr, png_const_inforp info_ptr,
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -06001059 png_unknown_chunkpp unknowns)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001060{
1061 if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05001062 {
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -06001063 *unknowns = info_ptr->unknown_chunks;
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -05001064 return info_ptr->unknown_chunks_num;
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05001065 }
Glenn Randers-Pehrsonf24daf22010-05-06 09:44:04 -05001066
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05001067 return (0);
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001068}
1069#endif
1070
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -05001071#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001072png_byte PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001073png_get_rgb_to_gray_status (png_const_structrp png_ptr)
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001074{
Glenn Randers-Pehrsona565f0e2010-03-06 08:24:45 -06001075 return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001076}
1077#endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001078
Glenn Randers-Pehrsone26c0952009-09-23 11:22:08 -05001079#ifdef PNG_USER_CHUNKS_SUPPORTED
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001080png_voidp PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001081png_get_user_chunk_ptr(png_const_structrp png_ptr)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001082{
Glenn Randers-Pehrsona565f0e2010-03-06 08:24:45 -06001083 return (png_ptr ? png_ptr->user_chunk_ptr : NULL);
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001084}
1085#endif
1086
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001087png_size_t PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001088png_get_compression_buffer_size(png_const_structrp png_ptr)
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05001089{
John Bowlerb5d00512012-03-09 09:15:18 -06001090 if (png_ptr == NULL)
1091 return 0;
1092
1093# ifdef PNG_WRITE_SUPPORTED
1094 if (png_ptr->mode & PNG_IS_READ_STRUCT)
1095# endif
1096 {
1097# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
1098 return png_ptr->IDAT_read_size;
1099# else
1100 return PNG_IDAT_READ_SIZE;
1101# endif
1102 }
1103
1104# ifdef PNG_WRITE_SUPPORTED
1105 else
1106 return png_ptr->zbuffer_size;
1107# endif
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05001108}
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -05001109
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -05001110#ifdef PNG_SET_USER_LIMITS_SUPPORTED
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06001111/* These functions were added to libpng 1.2.6 and were enabled
1112 * by default in libpng-1.4.0 */
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -05001113png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001114png_get_user_width_max (png_const_structrp png_ptr)
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -05001115{
Glenn Randers-Pehrsona565f0e2010-03-06 08:24:45 -06001116 return (png_ptr ? png_ptr->user_width_max : 0);
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -05001117}
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -05001118
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -05001119png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001120png_get_user_height_max (png_const_structrp png_ptr)
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -05001121{
Glenn Randers-Pehrsona565f0e2010-03-06 08:24:45 -06001122 return (png_ptr ? png_ptr->user_height_max : 0);
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -05001123}
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -05001124
Glenn Randers-Pehrson17ca3402009-11-09 06:51:16 -06001125/* This function was added to libpng 1.4.0 */
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -05001126png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001127png_get_chunk_cache_max (png_const_structrp png_ptr)
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -05001128{
Glenn Randers-Pehrsona565f0e2010-03-06 08:24:45 -06001129 return (png_ptr ? png_ptr->user_chunk_cache_max : 0);
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06001130}
Glenn Randers-Pehrson4aa2cd62010-08-19 16:52:01 -05001131
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06001132/* This function was added to libpng 1.4.1 */
Glenn Randers-Pehrson7a5be532010-02-14 07:16:19 -06001133png_alloc_size_t PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001134png_get_chunk_malloc_max (png_const_structrp png_ptr)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06001135{
Glenn Randers-Pehrsona565f0e2010-03-06 08:24:45 -06001136 return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -05001137}
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -05001138#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
Glenn Randers-Pehrsond60c8862009-06-15 21:56:14 -05001139
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06001140/* These functions were added to libpng 1.4.0 */
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001141#ifdef PNG_IO_STATE_SUPPORTED
1142png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001143png_get_io_state (png_const_structrp png_ptr)
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001144{
Glenn Randers-Pehrson16908a12010-03-06 07:34:28 -06001145 return png_ptr->io_state;
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001146}
1147
Glenn Randers-Pehrsona63dbed2011-01-22 08:51:19 -06001148png_uint_32 PNGAPI
John Bowler5d567862011-12-24 09:12:00 -06001149png_get_io_chunk_type (png_const_structrp png_ptr)
Glenn Randers-Pehrsona63dbed2011-01-22 08:51:19 -06001150{
Glenn Randers-Pehrsonbb5cb142011-09-22 12:41:58 -05001151 return png_ptr->chunk_name;
Glenn Randers-Pehrsona63dbed2011-01-22 08:51:19 -06001152}
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001153#endif /* ?PNG_IO_STATE_SUPPORTED */
1154
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -06001155#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */