annotate lib/libpng/pngget.c @ 2575:a76d408c5132 tip

DrawTranslucent -> DrawTextureGrayShade Removed old texture drawing stuff
author a.parshin
date Wed, 09 Mar 2016 01:39:52 +0200
parents 6e178010fc29
children
rev   line source
2296
Ritor1
parents:
diff changeset
1
Ritor1
parents:
diff changeset
2 /* pngget.c - retrieval of values from info struct
Ritor1
parents:
diff changeset
3 *
Ritor1
parents:
diff changeset
4 * Last changed in libpng 1.6.1 [March 28, 2013]
Ritor1
parents:
diff changeset
5 * Copyright (c) 1998-2013 Glenn Randers-Pehrson
Ritor1
parents:
diff changeset
6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
Ritor1
parents:
diff changeset
7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
Ritor1
parents:
diff changeset
8 *
Ritor1
parents:
diff changeset
9 * This code is released under the libpng license.
Ritor1
parents:
diff changeset
10 * For conditions of distribution and use, see the disclaimer
Ritor1
parents:
diff changeset
11 * and license in png.h
Ritor1
parents:
diff changeset
12 *
Ritor1
parents:
diff changeset
13 */
Ritor1
parents:
diff changeset
14
Ritor1
parents:
diff changeset
15 #include "pngpriv.h"
Ritor1
parents:
diff changeset
16
Ritor1
parents:
diff changeset
17 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
Ritor1
parents:
diff changeset
18
Ritor1
parents:
diff changeset
19 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
20 png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr,
Ritor1
parents:
diff changeset
21 png_uint_32 flag)
Ritor1
parents:
diff changeset
22 {
Ritor1
parents:
diff changeset
23 if (png_ptr != NULL && info_ptr != NULL)
Ritor1
parents:
diff changeset
24 return(info_ptr->valid & flag);
Ritor1
parents:
diff changeset
25
Ritor1
parents:
diff changeset
26 return(0);
Ritor1
parents:
diff changeset
27 }
Ritor1
parents:
diff changeset
28
Ritor1
parents:
diff changeset
29 png_size_t PNGAPI
Ritor1
parents:
diff changeset
30 png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
31 {
Ritor1
parents:
diff changeset
32 if (png_ptr != NULL && info_ptr != NULL)
Ritor1
parents:
diff changeset
33 return(info_ptr->rowbytes);
Ritor1
parents:
diff changeset
34
Ritor1
parents:
diff changeset
35 return(0);
Ritor1
parents:
diff changeset
36 }
Ritor1
parents:
diff changeset
37
Ritor1
parents:
diff changeset
38 #ifdef PNG_INFO_IMAGE_SUPPORTED
Ritor1
parents:
diff changeset
39 png_bytepp PNGAPI
Ritor1
parents:
diff changeset
40 png_get_rows(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
41 {
Ritor1
parents:
diff changeset
42 if (png_ptr != NULL && info_ptr != NULL)
Ritor1
parents:
diff changeset
43 return(info_ptr->row_pointers);
Ritor1
parents:
diff changeset
44
Ritor1
parents:
diff changeset
45 return(0);
Ritor1
parents:
diff changeset
46 }
Ritor1
parents:
diff changeset
47 #endif
Ritor1
parents:
diff changeset
48
Ritor1
parents:
diff changeset
49 #ifdef PNG_EASY_ACCESS_SUPPORTED
Ritor1
parents:
diff changeset
50 /* Easy access to info, added in libpng-0.99 */
Ritor1
parents:
diff changeset
51 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
52 png_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
53 {
Ritor1
parents:
diff changeset
54 if (png_ptr != NULL && info_ptr != NULL)
Ritor1
parents:
diff changeset
55 return info_ptr->width;
Ritor1
parents:
diff changeset
56
Ritor1
parents:
diff changeset
57 return (0);
Ritor1
parents:
diff changeset
58 }
Ritor1
parents:
diff changeset
59
Ritor1
parents:
diff changeset
60 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
61 png_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
62 {
Ritor1
parents:
diff changeset
63 if (png_ptr != NULL && info_ptr != NULL)
Ritor1
parents:
diff changeset
64 return info_ptr->height;
Ritor1
parents:
diff changeset
65
Ritor1
parents:
diff changeset
66 return (0);
Ritor1
parents:
diff changeset
67 }
Ritor1
parents:
diff changeset
68
Ritor1
parents:
diff changeset
69 png_byte PNGAPI
Ritor1
parents:
diff changeset
70 png_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
71 {
Ritor1
parents:
diff changeset
72 if (png_ptr != NULL && info_ptr != NULL)
Ritor1
parents:
diff changeset
73 return info_ptr->bit_depth;
Ritor1
parents:
diff changeset
74
Ritor1
parents:
diff changeset
75 return (0);
Ritor1
parents:
diff changeset
76 }
Ritor1
parents:
diff changeset
77
Ritor1
parents:
diff changeset
78 png_byte PNGAPI
Ritor1
parents:
diff changeset
79 png_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
80 {
Ritor1
parents:
diff changeset
81 if (png_ptr != NULL && info_ptr != NULL)
Ritor1
parents:
diff changeset
82 return info_ptr->color_type;
Ritor1
parents:
diff changeset
83
Ritor1
parents:
diff changeset
84 return (0);
Ritor1
parents:
diff changeset
85 }
Ritor1
parents:
diff changeset
86
Ritor1
parents:
diff changeset
87 png_byte PNGAPI
Ritor1
parents:
diff changeset
88 png_get_filter_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
89 {
Ritor1
parents:
diff changeset
90 if (png_ptr != NULL && info_ptr != NULL)
Ritor1
parents:
diff changeset
91 return info_ptr->filter_type;
Ritor1
parents:
diff changeset
92
Ritor1
parents:
diff changeset
93 return (0);
Ritor1
parents:
diff changeset
94 }
Ritor1
parents:
diff changeset
95
Ritor1
parents:
diff changeset
96 png_byte PNGAPI
Ritor1
parents:
diff changeset
97 png_get_interlace_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
98 {
Ritor1
parents:
diff changeset
99 if (png_ptr != NULL && info_ptr != NULL)
Ritor1
parents:
diff changeset
100 return info_ptr->interlace_type;
Ritor1
parents:
diff changeset
101
Ritor1
parents:
diff changeset
102 return (0);
Ritor1
parents:
diff changeset
103 }
Ritor1
parents:
diff changeset
104
Ritor1
parents:
diff changeset
105 png_byte PNGAPI
Ritor1
parents:
diff changeset
106 png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
107 {
Ritor1
parents:
diff changeset
108 if (png_ptr != NULL && info_ptr != NULL)
Ritor1
parents:
diff changeset
109 return info_ptr->compression_type;
Ritor1
parents:
diff changeset
110
Ritor1
parents:
diff changeset
111 return (0);
Ritor1
parents:
diff changeset
112 }
Ritor1
parents:
diff changeset
113
Ritor1
parents:
diff changeset
114 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
115 png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
Ritor1
parents:
diff changeset
116 info_ptr)
Ritor1
parents:
diff changeset
117 {
Ritor1
parents:
diff changeset
118 #ifdef PNG_pHYs_SUPPORTED
Ritor1
parents:
diff changeset
119 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
Ritor1
parents:
diff changeset
120 {
Ritor1
parents:
diff changeset
121 png_debug1(1, "in %s retrieval function",
Ritor1
parents:
diff changeset
122 "png_get_x_pixels_per_meter");
Ritor1
parents:
diff changeset
123
Ritor1
parents:
diff changeset
124 if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
Ritor1
parents:
diff changeset
125 return (info_ptr->x_pixels_per_unit);
Ritor1
parents:
diff changeset
126 }
Ritor1
parents:
diff changeset
127 #endif
Ritor1
parents:
diff changeset
128
Ritor1
parents:
diff changeset
129 return (0);
Ritor1
parents:
diff changeset
130 }
Ritor1
parents:
diff changeset
131
Ritor1
parents:
diff changeset
132 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
133 png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
Ritor1
parents:
diff changeset
134 info_ptr)
Ritor1
parents:
diff changeset
135 {
Ritor1
parents:
diff changeset
136 #ifdef PNG_pHYs_SUPPORTED
Ritor1
parents:
diff changeset
137 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
Ritor1
parents:
diff changeset
138 {
Ritor1
parents:
diff changeset
139 png_debug1(1, "in %s retrieval function",
Ritor1
parents:
diff changeset
140 "png_get_y_pixels_per_meter");
Ritor1
parents:
diff changeset
141
Ritor1
parents:
diff changeset
142 if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
Ritor1
parents:
diff changeset
143 return (info_ptr->y_pixels_per_unit);
Ritor1
parents:
diff changeset
144 }
Ritor1
parents:
diff changeset
145 #endif
Ritor1
parents:
diff changeset
146
Ritor1
parents:
diff changeset
147 return (0);
Ritor1
parents:
diff changeset
148 }
Ritor1
parents:
diff changeset
149
Ritor1
parents:
diff changeset
150 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
151 png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
152 {
Ritor1
parents:
diff changeset
153 #ifdef PNG_pHYs_SUPPORTED
Ritor1
parents:
diff changeset
154 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
Ritor1
parents:
diff changeset
155 {
Ritor1
parents:
diff changeset
156 png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
Ritor1
parents:
diff changeset
157
Ritor1
parents:
diff changeset
158 if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER &&
Ritor1
parents:
diff changeset
159 info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit)
Ritor1
parents:
diff changeset
160 return (info_ptr->x_pixels_per_unit);
Ritor1
parents:
diff changeset
161 }
Ritor1
parents:
diff changeset
162 #endif
Ritor1
parents:
diff changeset
163
Ritor1
parents:
diff changeset
164 return (0);
Ritor1
parents:
diff changeset
165 }
Ritor1
parents:
diff changeset
166
Ritor1
parents:
diff changeset
167 #ifdef PNG_FLOATING_POINT_SUPPORTED
Ritor1
parents:
diff changeset
168 float PNGAPI
Ritor1
parents:
diff changeset
169 png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp
Ritor1
parents:
diff changeset
170 info_ptr)
Ritor1
parents:
diff changeset
171 {
Ritor1
parents:
diff changeset
172 #ifdef PNG_READ_pHYs_SUPPORTED
Ritor1
parents:
diff changeset
173 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
Ritor1
parents:
diff changeset
174 {
Ritor1
parents:
diff changeset
175 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
Ritor1
parents:
diff changeset
176
Ritor1
parents:
diff changeset
177 if (info_ptr->x_pixels_per_unit != 0)
Ritor1
parents:
diff changeset
178 return ((float)((float)info_ptr->y_pixels_per_unit
Ritor1
parents:
diff changeset
179 /(float)info_ptr->x_pixels_per_unit));
Ritor1
parents:
diff changeset
180 }
Ritor1
parents:
diff changeset
181 #else
Ritor1
parents:
diff changeset
182 PNG_UNUSED(png_ptr)
Ritor1
parents:
diff changeset
183 PNG_UNUSED(info_ptr)
Ritor1
parents:
diff changeset
184 #endif
Ritor1
parents:
diff changeset
185
Ritor1
parents:
diff changeset
186 return ((float)0.0);
Ritor1
parents:
diff changeset
187 }
Ritor1
parents:
diff changeset
188 #endif
Ritor1
parents:
diff changeset
189
Ritor1
parents:
diff changeset
190 #ifdef PNG_FIXED_POINT_SUPPORTED
Ritor1
parents:
diff changeset
191 png_fixed_point PNGAPI
Ritor1
parents:
diff changeset
192 png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
Ritor1
parents:
diff changeset
193 png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
194 {
Ritor1
parents:
diff changeset
195 #ifdef PNG_READ_pHYs_SUPPORTED
Ritor1
parents:
diff changeset
196 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)
Ritor1
parents:
diff changeset
197 && info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0
Ritor1
parents:
diff changeset
198 && info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX
Ritor1
parents:
diff changeset
199 && info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX)
Ritor1
parents:
diff changeset
200 {
Ritor1
parents:
diff changeset
201 png_fixed_point res;
Ritor1
parents:
diff changeset
202
Ritor1
parents:
diff changeset
203 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio_fixed");
Ritor1
parents:
diff changeset
204
Ritor1
parents:
diff changeset
205 /* The following casts work because a PNG 4 byte integer only has a valid
Ritor1
parents:
diff changeset
206 * range of 0..2^31-1; otherwise the cast might overflow.
Ritor1
parents:
diff changeset
207 */
Ritor1
parents:
diff changeset
208 if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1,
Ritor1
parents:
diff changeset
209 (png_int_32)info_ptr->x_pixels_per_unit))
Ritor1
parents:
diff changeset
210 return res;
Ritor1
parents:
diff changeset
211 }
Ritor1
parents:
diff changeset
212 #else
Ritor1
parents:
diff changeset
213 PNG_UNUSED(png_ptr)
Ritor1
parents:
diff changeset
214 PNG_UNUSED(info_ptr)
Ritor1
parents:
diff changeset
215 #endif
Ritor1
parents:
diff changeset
216
Ritor1
parents:
diff changeset
217 return 0;
Ritor1
parents:
diff changeset
218 }
Ritor1
parents:
diff changeset
219 #endif
Ritor1
parents:
diff changeset
220
Ritor1
parents:
diff changeset
221 png_int_32 PNGAPI
Ritor1
parents:
diff changeset
222 png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
223 {
Ritor1
parents:
diff changeset
224 #ifdef PNG_oFFs_SUPPORTED
Ritor1
parents:
diff changeset
225 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
Ritor1
parents:
diff changeset
226 {
Ritor1
parents:
diff changeset
227 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
Ritor1
parents:
diff changeset
228
Ritor1
parents:
diff changeset
229 if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
Ritor1
parents:
diff changeset
230 return (info_ptr->x_offset);
Ritor1
parents:
diff changeset
231 }
Ritor1
parents:
diff changeset
232 #endif
Ritor1
parents:
diff changeset
233
Ritor1
parents:
diff changeset
234 return (0);
Ritor1
parents:
diff changeset
235 }
Ritor1
parents:
diff changeset
236
Ritor1
parents:
diff changeset
237 png_int_32 PNGAPI
Ritor1
parents:
diff changeset
238 png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
239 {
Ritor1
parents:
diff changeset
240 #ifdef PNG_oFFs_SUPPORTED
Ritor1
parents:
diff changeset
241 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
Ritor1
parents:
diff changeset
242 {
Ritor1
parents:
diff changeset
243 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
Ritor1
parents:
diff changeset
244
Ritor1
parents:
diff changeset
245 if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
Ritor1
parents:
diff changeset
246 return (info_ptr->y_offset);
Ritor1
parents:
diff changeset
247 }
Ritor1
parents:
diff changeset
248 #endif
Ritor1
parents:
diff changeset
249
Ritor1
parents:
diff changeset
250 return (0);
Ritor1
parents:
diff changeset
251 }
Ritor1
parents:
diff changeset
252
Ritor1
parents:
diff changeset
253 png_int_32 PNGAPI
Ritor1
parents:
diff changeset
254 png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
255 {
Ritor1
parents:
diff changeset
256 #ifdef PNG_oFFs_SUPPORTED
Ritor1
parents:
diff changeset
257 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
Ritor1
parents:
diff changeset
258 {
Ritor1
parents:
diff changeset
259 png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels");
Ritor1
parents:
diff changeset
260
Ritor1
parents:
diff changeset
261 if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
Ritor1
parents:
diff changeset
262 return (info_ptr->x_offset);
Ritor1
parents:
diff changeset
263 }
Ritor1
parents:
diff changeset
264 #endif
Ritor1
parents:
diff changeset
265
Ritor1
parents:
diff changeset
266 return (0);
Ritor1
parents:
diff changeset
267 }
Ritor1
parents:
diff changeset
268
Ritor1
parents:
diff changeset
269 png_int_32 PNGAPI
Ritor1
parents:
diff changeset
270 png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
271 {
Ritor1
parents:
diff changeset
272 #ifdef PNG_oFFs_SUPPORTED
Ritor1
parents:
diff changeset
273 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
Ritor1
parents:
diff changeset
274 {
Ritor1
parents:
diff changeset
275 png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels");
Ritor1
parents:
diff changeset
276
Ritor1
parents:
diff changeset
277 if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
Ritor1
parents:
diff changeset
278 return (info_ptr->y_offset);
Ritor1
parents:
diff changeset
279 }
Ritor1
parents:
diff changeset
280 #endif
Ritor1
parents:
diff changeset
281
Ritor1
parents:
diff changeset
282 return (0);
Ritor1
parents:
diff changeset
283 }
Ritor1
parents:
diff changeset
284
Ritor1
parents:
diff changeset
285 #ifdef PNG_INCH_CONVERSIONS_SUPPORTED
Ritor1
parents:
diff changeset
286 static png_uint_32
Ritor1
parents:
diff changeset
287 ppi_from_ppm(png_uint_32 ppm)
Ritor1
parents:
diff changeset
288 {
Ritor1
parents:
diff changeset
289 #if 0
Ritor1
parents:
diff changeset
290 /* The conversion is *(2.54/100), in binary (32 digits):
Ritor1
parents:
diff changeset
291 * .00000110100000001001110101001001
Ritor1
parents:
diff changeset
292 */
Ritor1
parents:
diff changeset
293 png_uint_32 t1001, t1101;
Ritor1
parents:
diff changeset
294 ppm >>= 1; /* .1 */
Ritor1
parents:
diff changeset
295 t1001 = ppm + (ppm >> 3); /* .1001 */
Ritor1
parents:
diff changeset
296 t1101 = t1001 + (ppm >> 1); /* .1101 */
Ritor1
parents:
diff changeset
297 ppm >>= 20; /* .000000000000000000001 */
Ritor1
parents:
diff changeset
298 t1101 += t1101 >> 15; /* .1101000000000001101 */
Ritor1
parents:
diff changeset
299 t1001 >>= 11; /* .000000000001001 */
Ritor1
parents:
diff changeset
300 t1001 += t1001 >> 12; /* .000000000001001000000001001 */
Ritor1
parents:
diff changeset
301 ppm += t1001; /* .000000000001001000001001001 */
Ritor1
parents:
diff changeset
302 ppm += t1101; /* .110100000001001110101001001 */
Ritor1
parents:
diff changeset
303 return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */
Ritor1
parents:
diff changeset
304 #else
Ritor1
parents:
diff changeset
305 /* The argument is a PNG unsigned integer, so it is not permitted
Ritor1
parents:
diff changeset
306 * to be bigger than 2^31.
Ritor1
parents:
diff changeset
307 */
Ritor1
parents:
diff changeset
308 png_fixed_point result;
Ritor1
parents:
diff changeset
309 if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127,
Ritor1
parents:
diff changeset
310 5000))
Ritor1
parents:
diff changeset
311 return result;
Ritor1
parents:
diff changeset
312
Ritor1
parents:
diff changeset
313 /* Overflow. */
Ritor1
parents:
diff changeset
314 return 0;
Ritor1
parents:
diff changeset
315 #endif
Ritor1
parents:
diff changeset
316 }
Ritor1
parents:
diff changeset
317
Ritor1
parents:
diff changeset
318 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
319 png_get_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
320 {
Ritor1
parents:
diff changeset
321 return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr));
Ritor1
parents:
diff changeset
322 }
Ritor1
parents:
diff changeset
323
Ritor1
parents:
diff changeset
324 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
325 png_get_x_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
326 {
Ritor1
parents:
diff changeset
327 return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr));
Ritor1
parents:
diff changeset
328 }
Ritor1
parents:
diff changeset
329
Ritor1
parents:
diff changeset
330 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
331 png_get_y_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
332 {
Ritor1
parents:
diff changeset
333 return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr));
Ritor1
parents:
diff changeset
334 }
Ritor1
parents:
diff changeset
335
Ritor1
parents:
diff changeset
336 #ifdef PNG_FIXED_POINT_SUPPORTED
Ritor1
parents:
diff changeset
337 static png_fixed_point
Ritor1
parents:
diff changeset
338 png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns)
Ritor1
parents:
diff changeset
339 {
Ritor1
parents:
diff changeset
340 /* Convert from metres * 1,000,000 to inches * 100,000, meters to
Ritor1
parents:
diff changeset
341 * inches is simply *(100/2.54), so we want *(10/2.54) == 500/127.
Ritor1
parents:
diff changeset
342 * Notice that this can overflow - a warning is output and 0 is
Ritor1
parents:
diff changeset
343 * returned.
Ritor1
parents:
diff changeset
344 */
Ritor1
parents:
diff changeset
345 return png_muldiv_warn(png_ptr, microns, 500, 127);
Ritor1
parents:
diff changeset
346 }
Ritor1
parents:
diff changeset
347
Ritor1
parents:
diff changeset
348 png_fixed_point PNGAPI
Ritor1
parents:
diff changeset
349 png_get_x_offset_inches_fixed(png_const_structrp png_ptr,
Ritor1
parents:
diff changeset
350 png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
351 {
Ritor1
parents:
diff changeset
352 return png_fixed_inches_from_microns(png_ptr,
Ritor1
parents:
diff changeset
353 png_get_x_offset_microns(png_ptr, info_ptr));
Ritor1
parents:
diff changeset
354 }
Ritor1
parents:
diff changeset
355 #endif
Ritor1
parents:
diff changeset
356
Ritor1
parents:
diff changeset
357 #ifdef PNG_FIXED_POINT_SUPPORTED
Ritor1
parents:
diff changeset
358 png_fixed_point PNGAPI
Ritor1
parents:
diff changeset
359 png_get_y_offset_inches_fixed(png_const_structrp png_ptr,
Ritor1
parents:
diff changeset
360 png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
361 {
Ritor1
parents:
diff changeset
362 return png_fixed_inches_from_microns(png_ptr,
Ritor1
parents:
diff changeset
363 png_get_y_offset_microns(png_ptr, info_ptr));
Ritor1
parents:
diff changeset
364 }
Ritor1
parents:
diff changeset
365 #endif
Ritor1
parents:
diff changeset
366
Ritor1
parents:
diff changeset
367 #ifdef PNG_FLOATING_POINT_SUPPORTED
Ritor1
parents:
diff changeset
368 float PNGAPI
Ritor1
parents:
diff changeset
369 png_get_x_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
370 {
Ritor1
parents:
diff changeset
371 /* To avoid the overflow do the conversion directly in floating
Ritor1
parents:
diff changeset
372 * point.
Ritor1
parents:
diff changeset
373 */
Ritor1
parents:
diff changeset
374 return (float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937);
Ritor1
parents:
diff changeset
375 }
Ritor1
parents:
diff changeset
376 #endif
Ritor1
parents:
diff changeset
377
Ritor1
parents:
diff changeset
378 #ifdef PNG_FLOATING_POINT_SUPPORTED
Ritor1
parents:
diff changeset
379 float PNGAPI
Ritor1
parents:
diff changeset
380 png_get_y_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
381 {
Ritor1
parents:
diff changeset
382 /* To avoid the overflow do the conversion directly in floating
Ritor1
parents:
diff changeset
383 * point.
Ritor1
parents:
diff changeset
384 */
Ritor1
parents:
diff changeset
385 return (float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937);
Ritor1
parents:
diff changeset
386 }
Ritor1
parents:
diff changeset
387 #endif
Ritor1
parents:
diff changeset
388
Ritor1
parents:
diff changeset
389 #ifdef PNG_pHYs_SUPPORTED
Ritor1
parents:
diff changeset
390 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
391 png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
Ritor1
parents:
diff changeset
392 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
Ritor1
parents:
diff changeset
393 {
Ritor1
parents:
diff changeset
394 png_uint_32 retval = 0;
Ritor1
parents:
diff changeset
395
Ritor1
parents:
diff changeset
396 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
Ritor1
parents:
diff changeset
397 {
Ritor1
parents:
diff changeset
398 png_debug1(1, "in %s retrieval function", "pHYs");
Ritor1
parents:
diff changeset
399
Ritor1
parents:
diff changeset
400 if (res_x != NULL)
Ritor1
parents:
diff changeset
401 {
Ritor1
parents:
diff changeset
402 *res_x = info_ptr->x_pixels_per_unit;
Ritor1
parents:
diff changeset
403 retval |= PNG_INFO_pHYs;
Ritor1
parents:
diff changeset
404 }
Ritor1
parents:
diff changeset
405
Ritor1
parents:
diff changeset
406 if (res_y != NULL)
Ritor1
parents:
diff changeset
407 {
Ritor1
parents:
diff changeset
408 *res_y = info_ptr->y_pixels_per_unit;
Ritor1
parents:
diff changeset
409 retval |= PNG_INFO_pHYs;
Ritor1
parents:
diff changeset
410 }
Ritor1
parents:
diff changeset
411
Ritor1
parents:
diff changeset
412 if (unit_type != NULL)
Ritor1
parents:
diff changeset
413 {
Ritor1
parents:
diff changeset
414 *unit_type = (int)info_ptr->phys_unit_type;
Ritor1
parents:
diff changeset
415 retval |= PNG_INFO_pHYs;
Ritor1
parents:
diff changeset
416
Ritor1
parents:
diff changeset
417 if (*unit_type == 1)
Ritor1
parents:
diff changeset
418 {
Ritor1
parents:
diff changeset
419 if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
Ritor1
parents:
diff changeset
420 if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
Ritor1
parents:
diff changeset
421 }
Ritor1
parents:
diff changeset
422 }
Ritor1
parents:
diff changeset
423 }
Ritor1
parents:
diff changeset
424
Ritor1
parents:
diff changeset
425 return (retval);
Ritor1
parents:
diff changeset
426 }
Ritor1
parents:
diff changeset
427 #endif /* PNG_pHYs_SUPPORTED */
Ritor1
parents:
diff changeset
428 #endif /* PNG_INCH_CONVERSIONS_SUPPORTED */
Ritor1
parents:
diff changeset
429
Ritor1
parents:
diff changeset
430 /* png_get_channels really belongs in here, too, but it's been around longer */
Ritor1
parents:
diff changeset
431
Ritor1
parents:
diff changeset
432 #endif /* PNG_EASY_ACCESS_SUPPORTED */
Ritor1
parents:
diff changeset
433
Ritor1
parents:
diff changeset
434
Ritor1
parents:
diff changeset
435 png_byte PNGAPI
Ritor1
parents:
diff changeset
436 png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
437 {
Ritor1
parents:
diff changeset
438 if (png_ptr != NULL && info_ptr != NULL)
Ritor1
parents:
diff changeset
439 return(info_ptr->channels);
Ritor1
parents:
diff changeset
440
Ritor1
parents:
diff changeset
441 return (0);
Ritor1
parents:
diff changeset
442 }
Ritor1
parents:
diff changeset
443
Ritor1
parents:
diff changeset
444 #ifdef PNG_READ_SUPPORTED
Ritor1
parents:
diff changeset
445 png_const_bytep PNGAPI
Ritor1
parents:
diff changeset
446 png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr)
Ritor1
parents:
diff changeset
447 {
Ritor1
parents:
diff changeset
448 if (png_ptr != NULL && info_ptr != NULL)
Ritor1
parents:
diff changeset
449 return(info_ptr->signature);
Ritor1
parents:
diff changeset
450
Ritor1
parents:
diff changeset
451 return (NULL);
Ritor1
parents:
diff changeset
452 }
Ritor1
parents:
diff changeset
453 #endif
Ritor1
parents:
diff changeset
454
Ritor1
parents:
diff changeset
455 #ifdef PNG_bKGD_SUPPORTED
Ritor1
parents:
diff changeset
456 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
457 png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
Ritor1
parents:
diff changeset
458 png_color_16p *background)
Ritor1
parents:
diff changeset
459 {
Ritor1
parents:
diff changeset
460 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
Ritor1
parents:
diff changeset
461 && background != NULL)
Ritor1
parents:
diff changeset
462 {
Ritor1
parents:
diff changeset
463 png_debug1(1, "in %s retrieval function", "bKGD");
Ritor1
parents:
diff changeset
464
Ritor1
parents:
diff changeset
465 *background = &(info_ptr->background);
Ritor1
parents:
diff changeset
466 return (PNG_INFO_bKGD);
Ritor1
parents:
diff changeset
467 }
Ritor1
parents:
diff changeset
468
Ritor1
parents:
diff changeset
469 return (0);
Ritor1
parents:
diff changeset
470 }
Ritor1
parents:
diff changeset
471 #endif
Ritor1
parents:
diff changeset
472
Ritor1
parents:
diff changeset
473 #ifdef PNG_cHRM_SUPPORTED
Ritor1
parents:
diff changeset
474 /* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the
Ritor1
parents:
diff changeset
475 * same time to correct the rgb grayscale coefficient defaults obtained from the
Ritor1
parents:
diff changeset
476 * cHRM chunk in 1.5.4
Ritor1
parents:
diff changeset
477 */
Ritor1
parents:
diff changeset
478 # ifdef PNG_FLOATING_POINT_SUPPORTED
Ritor1
parents:
diff changeset
479 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
480 png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
Ritor1
parents:
diff changeset
481 double *white_x, double *white_y, double *red_x, double *red_y,
Ritor1
parents:
diff changeset
482 double *green_x, double *green_y, double *blue_x, double *blue_y)
Ritor1
parents:
diff changeset
483 {
Ritor1
parents:
diff changeset
484 /* Quiet API change: this code used to only return the end points if a cHRM
Ritor1
parents:
diff changeset
485 * chunk was present, but the end points can also come from iCCP or sRGB
Ritor1
parents:
diff changeset
486 * chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and
Ritor1
parents:
diff changeset
487 * the png_set_ APIs merely check that set end points are mutually
Ritor1
parents:
diff changeset
488 * consistent.
Ritor1
parents:
diff changeset
489 */
Ritor1
parents:
diff changeset
490 if (png_ptr != NULL && info_ptr != NULL &&
Ritor1
parents:
diff changeset
491 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
Ritor1
parents:
diff changeset
492 {
Ritor1
parents:
diff changeset
493 png_debug1(1, "in %s retrieval function", "cHRM");
Ritor1
parents:
diff changeset
494
Ritor1
parents:
diff changeset
495 if (white_x != NULL)
Ritor1
parents:
diff changeset
496 *white_x = png_float(png_ptr,
Ritor1
parents:
diff changeset
497 info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
Ritor1
parents:
diff changeset
498 if (white_y != NULL)
Ritor1
parents:
diff changeset
499 *white_y = png_float(png_ptr,
Ritor1
parents:
diff changeset
500 info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y");
Ritor1
parents:
diff changeset
501 if (red_x != NULL)
Ritor1
parents:
diff changeset
502 *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx,
Ritor1
parents:
diff changeset
503 "cHRM red X");
Ritor1
parents:
diff changeset
504 if (red_y != NULL)
Ritor1
parents:
diff changeset
505 *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy,
Ritor1
parents:
diff changeset
506 "cHRM red Y");
Ritor1
parents:
diff changeset
507 if (green_x != NULL)
Ritor1
parents:
diff changeset
508 *green_x = png_float(png_ptr,
Ritor1
parents:
diff changeset
509 info_ptr->colorspace.end_points_xy.greenx, "cHRM green X");
Ritor1
parents:
diff changeset
510 if (green_y != NULL)
Ritor1
parents:
diff changeset
511 *green_y = png_float(png_ptr,
Ritor1
parents:
diff changeset
512 info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y");
Ritor1
parents:
diff changeset
513 if (blue_x != NULL)
Ritor1
parents:
diff changeset
514 *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex,
Ritor1
parents:
diff changeset
515 "cHRM blue X");
Ritor1
parents:
diff changeset
516 if (blue_y != NULL)
Ritor1
parents:
diff changeset
517 *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,
Ritor1
parents:
diff changeset
518 "cHRM blue Y");
Ritor1
parents:
diff changeset
519 return (PNG_INFO_cHRM);
Ritor1
parents:
diff changeset
520 }
Ritor1
parents:
diff changeset
521
Ritor1
parents:
diff changeset
522 return (0);
Ritor1
parents:
diff changeset
523 }
Ritor1
parents:
diff changeset
524
Ritor1
parents:
diff changeset
525 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
526 png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
Ritor1
parents:
diff changeset
527 double *red_X, double *red_Y, double *red_Z, double *green_X,
Ritor1
parents:
diff changeset
528 double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
Ritor1
parents:
diff changeset
529 double *blue_Z)
Ritor1
parents:
diff changeset
530 {
Ritor1
parents:
diff changeset
531 if (png_ptr != NULL && info_ptr != NULL &&
Ritor1
parents:
diff changeset
532 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
Ritor1
parents:
diff changeset
533 {
Ritor1
parents:
diff changeset
534 png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
Ritor1
parents:
diff changeset
535
Ritor1
parents:
diff changeset
536 if (red_X != NULL)
Ritor1
parents:
diff changeset
537 *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X,
Ritor1
parents:
diff changeset
538 "cHRM red X");
Ritor1
parents:
diff changeset
539 if (red_Y != NULL)
Ritor1
parents:
diff changeset
540 *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y,
Ritor1
parents:
diff changeset
541 "cHRM red Y");
Ritor1
parents:
diff changeset
542 if (red_Z != NULL)
Ritor1
parents:
diff changeset
543 *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z,
Ritor1
parents:
diff changeset
544 "cHRM red Z");
Ritor1
parents:
diff changeset
545 if (green_X != NULL)
Ritor1
parents:
diff changeset
546 *green_X = png_float(png_ptr,
Ritor1
parents:
diff changeset
547 info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X");
Ritor1
parents:
diff changeset
548 if (green_Y != NULL)
Ritor1
parents:
diff changeset
549 *green_Y = png_float(png_ptr,
Ritor1
parents:
diff changeset
550 info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y");
Ritor1
parents:
diff changeset
551 if (green_Z != NULL)
Ritor1
parents:
diff changeset
552 *green_Z = png_float(png_ptr,
Ritor1
parents:
diff changeset
553 info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z");
Ritor1
parents:
diff changeset
554 if (blue_X != NULL)
Ritor1
parents:
diff changeset
555 *blue_X = png_float(png_ptr,
Ritor1
parents:
diff changeset
556 info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X");
Ritor1
parents:
diff changeset
557 if (blue_Y != NULL)
Ritor1
parents:
diff changeset
558 *blue_Y = png_float(png_ptr,
Ritor1
parents:
diff changeset
559 info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y");
Ritor1
parents:
diff changeset
560 if (blue_Z != NULL)
Ritor1
parents:
diff changeset
561 *blue_Z = png_float(png_ptr,
Ritor1
parents:
diff changeset
562 info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
Ritor1
parents:
diff changeset
563 return (PNG_INFO_cHRM);
Ritor1
parents:
diff changeset
564 }
Ritor1
parents:
diff changeset
565
Ritor1
parents:
diff changeset
566 return (0);
Ritor1
parents:
diff changeset
567 }
Ritor1
parents:
diff changeset
568 # endif
Ritor1
parents:
diff changeset
569
Ritor1
parents:
diff changeset
570 # ifdef PNG_FIXED_POINT_SUPPORTED
Ritor1
parents:
diff changeset
571 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
572 png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
Ritor1
parents:
diff changeset
573 png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
Ritor1
parents:
diff changeset
574 png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
Ritor1
parents:
diff changeset
575 png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
Ritor1
parents:
diff changeset
576 png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
Ritor1
parents:
diff changeset
577 png_fixed_point *int_blue_Z)
Ritor1
parents:
diff changeset
578 {
Ritor1
parents:
diff changeset
579 if (png_ptr != NULL && info_ptr != NULL &&
Ritor1
parents:
diff changeset
580 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
Ritor1
parents:
diff changeset
581 {
Ritor1
parents:
diff changeset
582 png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
Ritor1
parents:
diff changeset
583
Ritor1
parents:
diff changeset
584 if (int_red_X != NULL)
Ritor1
parents:
diff changeset
585 *int_red_X = info_ptr->colorspace.end_points_XYZ.red_X;
Ritor1
parents:
diff changeset
586 if (int_red_Y != NULL)
Ritor1
parents:
diff changeset
587 *int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y;
Ritor1
parents:
diff changeset
588 if (int_red_Z != NULL)
Ritor1
parents:
diff changeset
589 *int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z;
Ritor1
parents:
diff changeset
590 if (int_green_X != NULL)
Ritor1
parents:
diff changeset
591 *int_green_X = info_ptr->colorspace.end_points_XYZ.green_X;
Ritor1
parents:
diff changeset
592 if (int_green_Y != NULL)
Ritor1
parents:
diff changeset
593 *int_green_Y = info_ptr->colorspace.end_points_XYZ.green_Y;
Ritor1
parents:
diff changeset
594 if (int_green_Z != NULL)
Ritor1
parents:
diff changeset
595 *int_green_Z = info_ptr->colorspace.end_points_XYZ.green_Z;
Ritor1
parents:
diff changeset
596 if (int_blue_X != NULL)
Ritor1
parents:
diff changeset
597 *int_blue_X = info_ptr->colorspace.end_points_XYZ.blue_X;
Ritor1
parents:
diff changeset
598 if (int_blue_Y != NULL)
Ritor1
parents:
diff changeset
599 *int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y;
Ritor1
parents:
diff changeset
600 if (int_blue_Z != NULL)
Ritor1
parents:
diff changeset
601 *int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z;
Ritor1
parents:
diff changeset
602 return (PNG_INFO_cHRM);
Ritor1
parents:
diff changeset
603 }
Ritor1
parents:
diff changeset
604
Ritor1
parents:
diff changeset
605 return (0);
Ritor1
parents:
diff changeset
606 }
Ritor1
parents:
diff changeset
607
Ritor1
parents:
diff changeset
608 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
609 png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
Ritor1
parents:
diff changeset
610 png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
Ritor1
parents:
diff changeset
611 png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
Ritor1
parents:
diff changeset
612 png_fixed_point *blue_x, png_fixed_point *blue_y)
Ritor1
parents:
diff changeset
613 {
Ritor1
parents:
diff changeset
614 png_debug1(1, "in %s retrieval function", "cHRM");
Ritor1
parents:
diff changeset
615
Ritor1
parents:
diff changeset
616 if (png_ptr != NULL && info_ptr != NULL &&
Ritor1
parents:
diff changeset
617 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
Ritor1
parents:
diff changeset
618 {
Ritor1
parents:
diff changeset
619 if (white_x != NULL)
Ritor1
parents:
diff changeset
620 *white_x = info_ptr->colorspace.end_points_xy.whitex;
Ritor1
parents:
diff changeset
621 if (white_y != NULL)
Ritor1
parents:
diff changeset
622 *white_y = info_ptr->colorspace.end_points_xy.whitey;
Ritor1
parents:
diff changeset
623 if (red_x != NULL)
Ritor1
parents:
diff changeset
624 *red_x = info_ptr->colorspace.end_points_xy.redx;
Ritor1
parents:
diff changeset
625 if (red_y != NULL)
Ritor1
parents:
diff changeset
626 *red_y = info_ptr->colorspace.end_points_xy.redy;
Ritor1
parents:
diff changeset
627 if (green_x != NULL)
Ritor1
parents:
diff changeset
628 *green_x = info_ptr->colorspace.end_points_xy.greenx;
Ritor1
parents:
diff changeset
629 if (green_y != NULL)
Ritor1
parents:
diff changeset
630 *green_y = info_ptr->colorspace.end_points_xy.greeny;
Ritor1
parents:
diff changeset
631 if (blue_x != NULL)
Ritor1
parents:
diff changeset
632 *blue_x = info_ptr->colorspace.end_points_xy.bluex;
Ritor1
parents:
diff changeset
633 if (blue_y != NULL)
Ritor1
parents:
diff changeset
634 *blue_y = info_ptr->colorspace.end_points_xy.bluey;
Ritor1
parents:
diff changeset
635 return (PNG_INFO_cHRM);
Ritor1
parents:
diff changeset
636 }
Ritor1
parents:
diff changeset
637
Ritor1
parents:
diff changeset
638 return (0);
Ritor1
parents:
diff changeset
639 }
Ritor1
parents:
diff changeset
640 # endif
Ritor1
parents:
diff changeset
641 #endif
Ritor1
parents:
diff changeset
642
Ritor1
parents:
diff changeset
643 #ifdef PNG_gAMA_SUPPORTED
Ritor1
parents:
diff changeset
644 # ifdef PNG_FIXED_POINT_SUPPORTED
Ritor1
parents:
diff changeset
645 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
646 png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
Ritor1
parents:
diff changeset
647 png_fixed_point *file_gamma)
Ritor1
parents:
diff changeset
648 {
Ritor1
parents:
diff changeset
649 png_debug1(1, "in %s retrieval function", "gAMA");
Ritor1
parents:
diff changeset
650
Ritor1
parents:
diff changeset
651 if (png_ptr != NULL && info_ptr != NULL &&
Ritor1
parents:
diff changeset
652 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
Ritor1
parents:
diff changeset
653 file_gamma != NULL)
Ritor1
parents:
diff changeset
654 {
Ritor1
parents:
diff changeset
655 *file_gamma = info_ptr->colorspace.gamma;
Ritor1
parents:
diff changeset
656 return (PNG_INFO_gAMA);
Ritor1
parents:
diff changeset
657 }
Ritor1
parents:
diff changeset
658
Ritor1
parents:
diff changeset
659 return (0);
Ritor1
parents:
diff changeset
660 }
Ritor1
parents:
diff changeset
661 # endif
Ritor1
parents:
diff changeset
662
Ritor1
parents:
diff changeset
663 # ifdef PNG_FLOATING_POINT_SUPPORTED
Ritor1
parents:
diff changeset
664 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
665 png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
Ritor1
parents:
diff changeset
666 double *file_gamma)
Ritor1
parents:
diff changeset
667 {
Ritor1
parents:
diff changeset
668 png_debug1(1, "in %s retrieval function", "gAMA(float)");
Ritor1
parents:
diff changeset
669
Ritor1
parents:
diff changeset
670 if (png_ptr != NULL && info_ptr != NULL &&
Ritor1
parents:
diff changeset
671 (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
Ritor1
parents:
diff changeset
672 file_gamma != NULL)
Ritor1
parents:
diff changeset
673 {
Ritor1
parents:
diff changeset
674 *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
Ritor1
parents:
diff changeset
675 "png_get_gAMA");
Ritor1
parents:
diff changeset
676 return (PNG_INFO_gAMA);
Ritor1
parents:
diff changeset
677 }
Ritor1
parents:
diff changeset
678
Ritor1
parents:
diff changeset
679 return (0);
Ritor1
parents:
diff changeset
680 }
Ritor1
parents:
diff changeset
681 # endif
Ritor1
parents:
diff changeset
682 #endif
Ritor1
parents:
diff changeset
683
Ritor1
parents:
diff changeset
684 #ifdef PNG_sRGB_SUPPORTED
Ritor1
parents:
diff changeset
685 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
686 png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
Ritor1
parents:
diff changeset
687 int *file_srgb_intent)
Ritor1
parents:
diff changeset
688 {
Ritor1
parents:
diff changeset
689 png_debug1(1, "in %s retrieval function", "sRGB");
Ritor1
parents:
diff changeset
690
Ritor1
parents:
diff changeset
691 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
Ritor1
parents:
diff changeset
692 && file_srgb_intent != NULL)
Ritor1
parents:
diff changeset
693 {
Ritor1
parents:
diff changeset
694 *file_srgb_intent = info_ptr->colorspace.rendering_intent;
Ritor1
parents:
diff changeset
695 return (PNG_INFO_sRGB);
Ritor1
parents:
diff changeset
696 }
Ritor1
parents:
diff changeset
697
Ritor1
parents:
diff changeset
698 return (0);
Ritor1
parents:
diff changeset
699 }
Ritor1
parents:
diff changeset
700 #endif
Ritor1
parents:
diff changeset
701
Ritor1
parents:
diff changeset
702 #ifdef PNG_iCCP_SUPPORTED
Ritor1
parents:
diff changeset
703 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
704 png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
Ritor1
parents:
diff changeset
705 png_charpp name, int *compression_type,
Ritor1
parents:
diff changeset
706 png_bytepp profile, png_uint_32 *proflen)
Ritor1
parents:
diff changeset
707 {
Ritor1
parents:
diff changeset
708 png_debug1(1, "in %s retrieval function", "iCCP");
Ritor1
parents:
diff changeset
709
Ritor1
parents:
diff changeset
710 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
Ritor1
parents:
diff changeset
711 && name != NULL && compression_type != NULL && profile != NULL &&
Ritor1
parents:
diff changeset
712 proflen != NULL)
Ritor1
parents:
diff changeset
713 {
Ritor1
parents:
diff changeset
714 *name = info_ptr->iccp_name;
Ritor1
parents:
diff changeset
715 *profile = info_ptr->iccp_profile;
Ritor1
parents:
diff changeset
716 *proflen = png_get_uint_32(info_ptr->iccp_profile);
Ritor1
parents:
diff changeset
717 /* This is somewhat irrelevant since the profile data returned has
Ritor1
parents:
diff changeset
718 * actually been uncompressed.
Ritor1
parents:
diff changeset
719 */
Ritor1
parents:
diff changeset
720 *compression_type = PNG_COMPRESSION_TYPE_BASE;
Ritor1
parents:
diff changeset
721 return (PNG_INFO_iCCP);
Ritor1
parents:
diff changeset
722 }
Ritor1
parents:
diff changeset
723
Ritor1
parents:
diff changeset
724 return (0);
Ritor1
parents:
diff changeset
725 }
Ritor1
parents:
diff changeset
726 #endif
Ritor1
parents:
diff changeset
727
Ritor1
parents:
diff changeset
728 #ifdef PNG_sPLT_SUPPORTED
Ritor1
parents:
diff changeset
729 int PNGAPI
Ritor1
parents:
diff changeset
730 png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,
Ritor1
parents:
diff changeset
731 png_sPLT_tpp spalettes)
Ritor1
parents:
diff changeset
732 {
Ritor1
parents:
diff changeset
733 if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
Ritor1
parents:
diff changeset
734 {
Ritor1
parents:
diff changeset
735 *spalettes = info_ptr->splt_palettes;
Ritor1
parents:
diff changeset
736 return info_ptr->splt_palettes_num;
Ritor1
parents:
diff changeset
737 }
Ritor1
parents:
diff changeset
738
Ritor1
parents:
diff changeset
739 return (0);
Ritor1
parents:
diff changeset
740 }
Ritor1
parents:
diff changeset
741 #endif
Ritor1
parents:
diff changeset
742
Ritor1
parents:
diff changeset
743 #ifdef PNG_hIST_SUPPORTED
Ritor1
parents:
diff changeset
744 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
745 png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
Ritor1
parents:
diff changeset
746 png_uint_16p *hist)
Ritor1
parents:
diff changeset
747 {
Ritor1
parents:
diff changeset
748 png_debug1(1, "in %s retrieval function", "hIST");
Ritor1
parents:
diff changeset
749
Ritor1
parents:
diff changeset
750 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
Ritor1
parents:
diff changeset
751 && hist != NULL)
Ritor1
parents:
diff changeset
752 {
Ritor1
parents:
diff changeset
753 *hist = info_ptr->hist;
Ritor1
parents:
diff changeset
754 return (PNG_INFO_hIST);
Ritor1
parents:
diff changeset
755 }
Ritor1
parents:
diff changeset
756
Ritor1
parents:
diff changeset
757 return (0);
Ritor1
parents:
diff changeset
758 }
Ritor1
parents:
diff changeset
759 #endif
Ritor1
parents:
diff changeset
760
Ritor1
parents:
diff changeset
761 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
762 png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
Ritor1
parents:
diff changeset
763 png_uint_32 *width, png_uint_32 *height, int *bit_depth,
Ritor1
parents:
diff changeset
764 int *color_type, int *interlace_type, int *compression_type,
Ritor1
parents:
diff changeset
765 int *filter_type)
Ritor1
parents:
diff changeset
766 {
Ritor1
parents:
diff changeset
767 png_debug1(1, "in %s retrieval function", "IHDR");
Ritor1
parents:
diff changeset
768
Ritor1
parents:
diff changeset
769 if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
Ritor1
parents:
diff changeset
770 height == NULL || bit_depth == NULL || color_type == NULL)
Ritor1
parents:
diff changeset
771 return (0);
Ritor1
parents:
diff changeset
772
Ritor1
parents:
diff changeset
773 *width = info_ptr->width;
Ritor1
parents:
diff changeset
774 *height = info_ptr->height;
Ritor1
parents:
diff changeset
775 *bit_depth = info_ptr->bit_depth;
Ritor1
parents:
diff changeset
776 *color_type = info_ptr->color_type;
Ritor1
parents:
diff changeset
777
Ritor1
parents:
diff changeset
778 if (compression_type != NULL)
Ritor1
parents:
diff changeset
779 *compression_type = info_ptr->compression_type;
Ritor1
parents:
diff changeset
780
Ritor1
parents:
diff changeset
781 if (filter_type != NULL)
Ritor1
parents:
diff changeset
782 *filter_type = info_ptr->filter_type;
Ritor1
parents:
diff changeset
783
Ritor1
parents:
diff changeset
784 if (interlace_type != NULL)
Ritor1
parents:
diff changeset
785 *interlace_type = info_ptr->interlace_type;
Ritor1
parents:
diff changeset
786
Ritor1
parents:
diff changeset
787 /* This is redundant if we can be sure that the info_ptr values were all
Ritor1
parents:
diff changeset
788 * assigned in png_set_IHDR(). We do the check anyhow in case an
Ritor1
parents:
diff changeset
789 * application has ignored our advice not to mess with the members
Ritor1
parents:
diff changeset
790 * of info_ptr directly.
Ritor1
parents:
diff changeset
791 */
Ritor1
parents:
diff changeset
792 png_check_IHDR(png_ptr, info_ptr->width, info_ptr->height,
Ritor1
parents:
diff changeset
793 info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
Ritor1
parents:
diff changeset
794 info_ptr->compression_type, info_ptr->filter_type);
Ritor1
parents:
diff changeset
795
Ritor1
parents:
diff changeset
796 return (1);
Ritor1
parents:
diff changeset
797 }
Ritor1
parents:
diff changeset
798
Ritor1
parents:
diff changeset
799 #ifdef PNG_oFFs_SUPPORTED
Ritor1
parents:
diff changeset
800 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
801 png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr,
Ritor1
parents:
diff changeset
802 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
Ritor1
parents:
diff changeset
803 {
Ritor1
parents:
diff changeset
804 png_debug1(1, "in %s retrieval function", "oFFs");
Ritor1
parents:
diff changeset
805
Ritor1
parents:
diff changeset
806 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
Ritor1
parents:
diff changeset
807 && offset_x != NULL && offset_y != NULL && unit_type != NULL)
Ritor1
parents:
diff changeset
808 {
Ritor1
parents:
diff changeset
809 *offset_x = info_ptr->x_offset;
Ritor1
parents:
diff changeset
810 *offset_y = info_ptr->y_offset;
Ritor1
parents:
diff changeset
811 *unit_type = (int)info_ptr->offset_unit_type;
Ritor1
parents:
diff changeset
812 return (PNG_INFO_oFFs);
Ritor1
parents:
diff changeset
813 }
Ritor1
parents:
diff changeset
814
Ritor1
parents:
diff changeset
815 return (0);
Ritor1
parents:
diff changeset
816 }
Ritor1
parents:
diff changeset
817 #endif
Ritor1
parents:
diff changeset
818
Ritor1
parents:
diff changeset
819 #ifdef PNG_pCAL_SUPPORTED
Ritor1
parents:
diff changeset
820 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
821 png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
Ritor1
parents:
diff changeset
822 png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
Ritor1
parents:
diff changeset
823 png_charp *units, png_charpp *params)
Ritor1
parents:
diff changeset
824 {
Ritor1
parents:
diff changeset
825 png_debug1(1, "in %s retrieval function", "pCAL");
Ritor1
parents:
diff changeset
826
Ritor1
parents:
diff changeset
827 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
Ritor1
parents:
diff changeset
828 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
Ritor1
parents:
diff changeset
829 nparams != NULL && units != NULL && params != NULL)
Ritor1
parents:
diff changeset
830 {
Ritor1
parents:
diff changeset
831 *purpose = info_ptr->pcal_purpose;
Ritor1
parents:
diff changeset
832 *X0 = info_ptr->pcal_X0;
Ritor1
parents:
diff changeset
833 *X1 = info_ptr->pcal_X1;
Ritor1
parents:
diff changeset
834 *type = (int)info_ptr->pcal_type;
Ritor1
parents:
diff changeset
835 *nparams = (int)info_ptr->pcal_nparams;
Ritor1
parents:
diff changeset
836 *units = info_ptr->pcal_units;
Ritor1
parents:
diff changeset
837 *params = info_ptr->pcal_params;
Ritor1
parents:
diff changeset
838 return (PNG_INFO_pCAL);
Ritor1
parents:
diff changeset
839 }
Ritor1
parents:
diff changeset
840
Ritor1
parents:
diff changeset
841 return (0);
Ritor1
parents:
diff changeset
842 }
Ritor1
parents:
diff changeset
843 #endif
Ritor1
parents:
diff changeset
844
Ritor1
parents:
diff changeset
845 #ifdef PNG_sCAL_SUPPORTED
Ritor1
parents:
diff changeset
846 # ifdef PNG_FIXED_POINT_SUPPORTED
Ritor1
parents:
diff changeset
847 # if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
Ritor1
parents:
diff changeset
848 defined(PNG_FLOATING_POINT_SUPPORTED)
Ritor1
parents:
diff changeset
849 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
850 png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
Ritor1
parents:
diff changeset
851 int *unit, png_fixed_point *width, png_fixed_point *height)
Ritor1
parents:
diff changeset
852 {
Ritor1
parents:
diff changeset
853 if (png_ptr != NULL && info_ptr != NULL &&
Ritor1
parents:
diff changeset
854 (info_ptr->valid & PNG_INFO_sCAL))
Ritor1
parents:
diff changeset
855 {
Ritor1
parents:
diff changeset
856 *unit = info_ptr->scal_unit;
Ritor1
parents:
diff changeset
857 /*TODO: make this work without FP support; the API is currently eliminated
Ritor1
parents:
diff changeset
858 * if neither floating point APIs nor internal floating point arithmetic
Ritor1
parents:
diff changeset
859 * are enabled.
Ritor1
parents:
diff changeset
860 */
Ritor1
parents:
diff changeset
861 *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width");
Ritor1
parents:
diff changeset
862 *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
Ritor1
parents:
diff changeset
863 "sCAL height");
Ritor1
parents:
diff changeset
864 return (PNG_INFO_sCAL);
Ritor1
parents:
diff changeset
865 }
Ritor1
parents:
diff changeset
866
Ritor1
parents:
diff changeset
867 return(0);
Ritor1
parents:
diff changeset
868 }
Ritor1
parents:
diff changeset
869 # endif /* FLOATING_ARITHMETIC */
Ritor1
parents:
diff changeset
870 # endif /* FIXED_POINT */
Ritor1
parents:
diff changeset
871 # ifdef PNG_FLOATING_POINT_SUPPORTED
Ritor1
parents:
diff changeset
872 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
873 png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
Ritor1
parents:
diff changeset
874 int *unit, double *width, double *height)
Ritor1
parents:
diff changeset
875 {
Ritor1
parents:
diff changeset
876 if (png_ptr != NULL && info_ptr != NULL &&
Ritor1
parents:
diff changeset
877 (info_ptr->valid & PNG_INFO_sCAL))
Ritor1
parents:
diff changeset
878 {
Ritor1
parents:
diff changeset
879 *unit = info_ptr->scal_unit;
Ritor1
parents:
diff changeset
880 *width = atof(info_ptr->scal_s_width);
Ritor1
parents:
diff changeset
881 *height = atof(info_ptr->scal_s_height);
Ritor1
parents:
diff changeset
882 return (PNG_INFO_sCAL);
Ritor1
parents:
diff changeset
883 }
Ritor1
parents:
diff changeset
884
Ritor1
parents:
diff changeset
885 return(0);
Ritor1
parents:
diff changeset
886 }
Ritor1
parents:
diff changeset
887 # endif /* FLOATING POINT */
Ritor1
parents:
diff changeset
888 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
889 png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr,
Ritor1
parents:
diff changeset
890 int *unit, png_charpp width, png_charpp height)
Ritor1
parents:
diff changeset
891 {
Ritor1
parents:
diff changeset
892 if (png_ptr != NULL && info_ptr != NULL &&
Ritor1
parents:
diff changeset
893 (info_ptr->valid & PNG_INFO_sCAL))
Ritor1
parents:
diff changeset
894 {
Ritor1
parents:
diff changeset
895 *unit = info_ptr->scal_unit;
Ritor1
parents:
diff changeset
896 *width = info_ptr->scal_s_width;
Ritor1
parents:
diff changeset
897 *height = info_ptr->scal_s_height;
Ritor1
parents:
diff changeset
898 return (PNG_INFO_sCAL);
Ritor1
parents:
diff changeset
899 }
Ritor1
parents:
diff changeset
900
Ritor1
parents:
diff changeset
901 return(0);
Ritor1
parents:
diff changeset
902 }
Ritor1
parents:
diff changeset
903 #endif /* sCAL */
Ritor1
parents:
diff changeset
904
Ritor1
parents:
diff changeset
905 #ifdef PNG_pHYs_SUPPORTED
Ritor1
parents:
diff changeset
906 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
907 png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr,
Ritor1
parents:
diff changeset
908 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
Ritor1
parents:
diff changeset
909 {
Ritor1
parents:
diff changeset
910 png_uint_32 retval = 0;
Ritor1
parents:
diff changeset
911
Ritor1
parents:
diff changeset
912 png_debug1(1, "in %s retrieval function", "pHYs");
Ritor1
parents:
diff changeset
913
Ritor1
parents:
diff changeset
914 if (png_ptr != NULL && info_ptr != NULL &&
Ritor1
parents:
diff changeset
915 (info_ptr->valid & PNG_INFO_pHYs))
Ritor1
parents:
diff changeset
916 {
Ritor1
parents:
diff changeset
917 if (res_x != NULL)
Ritor1
parents:
diff changeset
918 {
Ritor1
parents:
diff changeset
919 *res_x = info_ptr->x_pixels_per_unit;
Ritor1
parents:
diff changeset
920 retval |= PNG_INFO_pHYs;
Ritor1
parents:
diff changeset
921 }
Ritor1
parents:
diff changeset
922
Ritor1
parents:
diff changeset
923 if (res_y != NULL)
Ritor1
parents:
diff changeset
924 {
Ritor1
parents:
diff changeset
925 *res_y = info_ptr->y_pixels_per_unit;
Ritor1
parents:
diff changeset
926 retval |= PNG_INFO_pHYs;
Ritor1
parents:
diff changeset
927 }
Ritor1
parents:
diff changeset
928
Ritor1
parents:
diff changeset
929 if (unit_type != NULL)
Ritor1
parents:
diff changeset
930 {
Ritor1
parents:
diff changeset
931 *unit_type = (int)info_ptr->phys_unit_type;
Ritor1
parents:
diff changeset
932 retval |= PNG_INFO_pHYs;
Ritor1
parents:
diff changeset
933 }
Ritor1
parents:
diff changeset
934 }
Ritor1
parents:
diff changeset
935
Ritor1
parents:
diff changeset
936 return (retval);
Ritor1
parents:
diff changeset
937 }
Ritor1
parents:
diff changeset
938 #endif /* pHYs */
Ritor1
parents:
diff changeset
939
Ritor1
parents:
diff changeset
940 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
941 png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr,
Ritor1
parents:
diff changeset
942 png_colorp *palette, int *num_palette)
Ritor1
parents:
diff changeset
943 {
Ritor1
parents:
diff changeset
944 png_debug1(1, "in %s retrieval function", "PLTE");
Ritor1
parents:
diff changeset
945
Ritor1
parents:
diff changeset
946 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
Ritor1
parents:
diff changeset
947 && palette != NULL)
Ritor1
parents:
diff changeset
948 {
Ritor1
parents:
diff changeset
949 *palette = info_ptr->palette;
Ritor1
parents:
diff changeset
950 *num_palette = info_ptr->num_palette;
Ritor1
parents:
diff changeset
951 png_debug1(3, "num_palette = %d", *num_palette);
Ritor1
parents:
diff changeset
952 return (PNG_INFO_PLTE);
Ritor1
parents:
diff changeset
953 }
Ritor1
parents:
diff changeset
954
Ritor1
parents:
diff changeset
955 return (0);
Ritor1
parents:
diff changeset
956 }
Ritor1
parents:
diff changeset
957
Ritor1
parents:
diff changeset
958 #ifdef PNG_sBIT_SUPPORTED
Ritor1
parents:
diff changeset
959 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
960 png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,
Ritor1
parents:
diff changeset
961 png_color_8p *sig_bit)
Ritor1
parents:
diff changeset
962 {
Ritor1
parents:
diff changeset
963 png_debug1(1, "in %s retrieval function", "sBIT");
Ritor1
parents:
diff changeset
964
Ritor1
parents:
diff changeset
965 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
Ritor1
parents:
diff changeset
966 && sig_bit != NULL)
Ritor1
parents:
diff changeset
967 {
Ritor1
parents:
diff changeset
968 *sig_bit = &(info_ptr->sig_bit);
Ritor1
parents:
diff changeset
969 return (PNG_INFO_sBIT);
Ritor1
parents:
diff changeset
970 }
Ritor1
parents:
diff changeset
971
Ritor1
parents:
diff changeset
972 return (0);
Ritor1
parents:
diff changeset
973 }
Ritor1
parents:
diff changeset
974 #endif
Ritor1
parents:
diff changeset
975
Ritor1
parents:
diff changeset
976 #ifdef PNG_TEXT_SUPPORTED
Ritor1
parents:
diff changeset
977 int PNGAPI
Ritor1
parents:
diff changeset
978 png_get_text(png_const_structrp png_ptr, png_inforp info_ptr,
Ritor1
parents:
diff changeset
979 png_textp *text_ptr, int *num_text)
Ritor1
parents:
diff changeset
980 {
Ritor1
parents:
diff changeset
981 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
Ritor1
parents:
diff changeset
982 {
Ritor1
parents:
diff changeset
983 png_debug1(1, "in 0x%lx retrieval function",
Ritor1
parents:
diff changeset
984 (unsigned long)png_ptr->chunk_name);
Ritor1
parents:
diff changeset
985
Ritor1
parents:
diff changeset
986 if (text_ptr != NULL)
Ritor1
parents:
diff changeset
987 *text_ptr = info_ptr->text;
Ritor1
parents:
diff changeset
988
Ritor1
parents:
diff changeset
989 if (num_text != NULL)
Ritor1
parents:
diff changeset
990 *num_text = info_ptr->num_text;
Ritor1
parents:
diff changeset
991
Ritor1
parents:
diff changeset
992 return info_ptr->num_text;
Ritor1
parents:
diff changeset
993 }
Ritor1
parents:
diff changeset
994
Ritor1
parents:
diff changeset
995 if (num_text != NULL)
Ritor1
parents:
diff changeset
996 *num_text = 0;
Ritor1
parents:
diff changeset
997
Ritor1
parents:
diff changeset
998 return(0);
Ritor1
parents:
diff changeset
999 }
Ritor1
parents:
diff changeset
1000 #endif
Ritor1
parents:
diff changeset
1001
Ritor1
parents:
diff changeset
1002 #ifdef PNG_tIME_SUPPORTED
Ritor1
parents:
diff changeset
1003 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
1004 png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
Ritor1
parents:
diff changeset
1005 png_timep *mod_time)
Ritor1
parents:
diff changeset
1006 {
Ritor1
parents:
diff changeset
1007 png_debug1(1, "in %s retrieval function", "tIME");
Ritor1
parents:
diff changeset
1008
Ritor1
parents:
diff changeset
1009 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
Ritor1
parents:
diff changeset
1010 && mod_time != NULL)
Ritor1
parents:
diff changeset
1011 {
Ritor1
parents:
diff changeset
1012 *mod_time = &(info_ptr->mod_time);
Ritor1
parents:
diff changeset
1013 return (PNG_INFO_tIME);
Ritor1
parents:
diff changeset
1014 }
Ritor1
parents:
diff changeset
1015
Ritor1
parents:
diff changeset
1016 return (0);
Ritor1
parents:
diff changeset
1017 }
Ritor1
parents:
diff changeset
1018 #endif
Ritor1
parents:
diff changeset
1019
Ritor1
parents:
diff changeset
1020 #ifdef PNG_tRNS_SUPPORTED
Ritor1
parents:
diff changeset
1021 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
1022 png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
Ritor1
parents:
diff changeset
1023 png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
Ritor1
parents:
diff changeset
1024 {
Ritor1
parents:
diff changeset
1025 png_uint_32 retval = 0;
Ritor1
parents:
diff changeset
1026 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
Ritor1
parents:
diff changeset
1027 {
Ritor1
parents:
diff changeset
1028 png_debug1(1, "in %s retrieval function", "tRNS");
Ritor1
parents:
diff changeset
1029
Ritor1
parents:
diff changeset
1030 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
Ritor1
parents:
diff changeset
1031 {
Ritor1
parents:
diff changeset
1032 if (trans_alpha != NULL)
Ritor1
parents:
diff changeset
1033 {
Ritor1
parents:
diff changeset
1034 *trans_alpha = info_ptr->trans_alpha;
Ritor1
parents:
diff changeset
1035 retval |= PNG_INFO_tRNS;
Ritor1
parents:
diff changeset
1036 }
Ritor1
parents:
diff changeset
1037
Ritor1
parents:
diff changeset
1038 if (trans_color != NULL)
Ritor1
parents:
diff changeset
1039 *trans_color = &(info_ptr->trans_color);
Ritor1
parents:
diff changeset
1040 }
Ritor1
parents:
diff changeset
1041
Ritor1
parents:
diff changeset
1042 else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
Ritor1
parents:
diff changeset
1043 {
Ritor1
parents:
diff changeset
1044 if (trans_color != NULL)
Ritor1
parents:
diff changeset
1045 {
Ritor1
parents:
diff changeset
1046 *trans_color = &(info_ptr->trans_color);
Ritor1
parents:
diff changeset
1047 retval |= PNG_INFO_tRNS;
Ritor1
parents:
diff changeset
1048 }
Ritor1
parents:
diff changeset
1049
Ritor1
parents:
diff changeset
1050 if (trans_alpha != NULL)
Ritor1
parents:
diff changeset
1051 *trans_alpha = NULL;
Ritor1
parents:
diff changeset
1052 }
Ritor1
parents:
diff changeset
1053
Ritor1
parents:
diff changeset
1054 if (num_trans != NULL)
Ritor1
parents:
diff changeset
1055 {
Ritor1
parents:
diff changeset
1056 *num_trans = info_ptr->num_trans;
Ritor1
parents:
diff changeset
1057 retval |= PNG_INFO_tRNS;
Ritor1
parents:
diff changeset
1058 }
Ritor1
parents:
diff changeset
1059 }
Ritor1
parents:
diff changeset
1060
Ritor1
parents:
diff changeset
1061 return (retval);
Ritor1
parents:
diff changeset
1062 }
Ritor1
parents:
diff changeset
1063 #endif
Ritor1
parents:
diff changeset
1064
Ritor1
parents:
diff changeset
1065 #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
Ritor1
parents:
diff changeset
1066 int PNGAPI
Ritor1
parents:
diff changeset
1067 png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr,
Ritor1
parents:
diff changeset
1068 png_unknown_chunkpp unknowns)
Ritor1
parents:
diff changeset
1069 {
Ritor1
parents:
diff changeset
1070 if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
Ritor1
parents:
diff changeset
1071 {
Ritor1
parents:
diff changeset
1072 *unknowns = info_ptr->unknown_chunks;
Ritor1
parents:
diff changeset
1073 return info_ptr->unknown_chunks_num;
Ritor1
parents:
diff changeset
1074 }
Ritor1
parents:
diff changeset
1075
Ritor1
parents:
diff changeset
1076 return (0);
Ritor1
parents:
diff changeset
1077 }
Ritor1
parents:
diff changeset
1078 #endif
Ritor1
parents:
diff changeset
1079
Ritor1
parents:
diff changeset
1080 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
Ritor1
parents:
diff changeset
1081 png_byte PNGAPI
Ritor1
parents:
diff changeset
1082 png_get_rgb_to_gray_status (png_const_structrp png_ptr)
Ritor1
parents:
diff changeset
1083 {
Ritor1
parents:
diff changeset
1084 return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
Ritor1
parents:
diff changeset
1085 }
Ritor1
parents:
diff changeset
1086 #endif
Ritor1
parents:
diff changeset
1087
Ritor1
parents:
diff changeset
1088 #ifdef PNG_USER_CHUNKS_SUPPORTED
Ritor1
parents:
diff changeset
1089 png_voidp PNGAPI
Ritor1
parents:
diff changeset
1090 png_get_user_chunk_ptr(png_const_structrp png_ptr)
Ritor1
parents:
diff changeset
1091 {
Ritor1
parents:
diff changeset
1092 return (png_ptr ? png_ptr->user_chunk_ptr : NULL);
Ritor1
parents:
diff changeset
1093 }
Ritor1
parents:
diff changeset
1094 #endif
Ritor1
parents:
diff changeset
1095
Ritor1
parents:
diff changeset
1096 png_size_t PNGAPI
Ritor1
parents:
diff changeset
1097 png_get_compression_buffer_size(png_const_structrp png_ptr)
Ritor1
parents:
diff changeset
1098 {
Ritor1
parents:
diff changeset
1099 if (png_ptr == NULL)
Ritor1
parents:
diff changeset
1100 return 0;
Ritor1
parents:
diff changeset
1101
Ritor1
parents:
diff changeset
1102 # ifdef PNG_WRITE_SUPPORTED
Ritor1
parents:
diff changeset
1103 if (png_ptr->mode & PNG_IS_READ_STRUCT)
Ritor1
parents:
diff changeset
1104 # endif
Ritor1
parents:
diff changeset
1105 {
Ritor1
parents:
diff changeset
1106 # ifdef PNG_SEQUENTIAL_READ_SUPPORTED
Ritor1
parents:
diff changeset
1107 return png_ptr->IDAT_read_size;
Ritor1
parents:
diff changeset
1108 # else
Ritor1
parents:
diff changeset
1109 return PNG_IDAT_READ_SIZE;
Ritor1
parents:
diff changeset
1110 # endif
Ritor1
parents:
diff changeset
1111 }
Ritor1
parents:
diff changeset
1112
Ritor1
parents:
diff changeset
1113 # ifdef PNG_WRITE_SUPPORTED
Ritor1
parents:
diff changeset
1114 else
Ritor1
parents:
diff changeset
1115 return png_ptr->zbuffer_size;
Ritor1
parents:
diff changeset
1116 # endif
Ritor1
parents:
diff changeset
1117 }
Ritor1
parents:
diff changeset
1118
Ritor1
parents:
diff changeset
1119 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
Ritor1
parents:
diff changeset
1120 /* These functions were added to libpng 1.2.6 and were enabled
Ritor1
parents:
diff changeset
1121 * by default in libpng-1.4.0 */
Ritor1
parents:
diff changeset
1122 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
1123 png_get_user_width_max (png_const_structrp png_ptr)
Ritor1
parents:
diff changeset
1124 {
Ritor1
parents:
diff changeset
1125 return (png_ptr ? png_ptr->user_width_max : 0);
Ritor1
parents:
diff changeset
1126 }
Ritor1
parents:
diff changeset
1127
Ritor1
parents:
diff changeset
1128 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
1129 png_get_user_height_max (png_const_structrp png_ptr)
Ritor1
parents:
diff changeset
1130 {
Ritor1
parents:
diff changeset
1131 return (png_ptr ? png_ptr->user_height_max : 0);
Ritor1
parents:
diff changeset
1132 }
Ritor1
parents:
diff changeset
1133
Ritor1
parents:
diff changeset
1134 /* This function was added to libpng 1.4.0 */
Ritor1
parents:
diff changeset
1135 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
1136 png_get_chunk_cache_max (png_const_structrp png_ptr)
Ritor1
parents:
diff changeset
1137 {
Ritor1
parents:
diff changeset
1138 return (png_ptr ? png_ptr->user_chunk_cache_max : 0);
Ritor1
parents:
diff changeset
1139 }
Ritor1
parents:
diff changeset
1140
Ritor1
parents:
diff changeset
1141 /* This function was added to libpng 1.4.1 */
Ritor1
parents:
diff changeset
1142 png_alloc_size_t PNGAPI
Ritor1
parents:
diff changeset
1143 png_get_chunk_malloc_max (png_const_structrp png_ptr)
Ritor1
parents:
diff changeset
1144 {
Ritor1
parents:
diff changeset
1145 return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
Ritor1
parents:
diff changeset
1146 }
Ritor1
parents:
diff changeset
1147 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
Ritor1
parents:
diff changeset
1148
Ritor1
parents:
diff changeset
1149 /* These functions were added to libpng 1.4.0 */
Ritor1
parents:
diff changeset
1150 #ifdef PNG_IO_STATE_SUPPORTED
Ritor1
parents:
diff changeset
1151 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
1152 png_get_io_state (png_const_structrp png_ptr)
Ritor1
parents:
diff changeset
1153 {
Ritor1
parents:
diff changeset
1154 return png_ptr->io_state;
Ritor1
parents:
diff changeset
1155 }
Ritor1
parents:
diff changeset
1156
Ritor1
parents:
diff changeset
1157 png_uint_32 PNGAPI
Ritor1
parents:
diff changeset
1158 png_get_io_chunk_type (png_const_structrp png_ptr)
Ritor1
parents:
diff changeset
1159 {
Ritor1
parents:
diff changeset
1160 return png_ptr->chunk_name;
Ritor1
parents:
diff changeset
1161 }
Ritor1
parents:
diff changeset
1162 #endif /* ?PNG_IO_STATE_SUPPORTED */
Ritor1
parents:
diff changeset
1163
Ritor1
parents:
diff changeset
1164 #ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
Ritor1
parents:
diff changeset
1165 # ifdef PNG_GET_PALETTE_MAX_SUPPORTED
Ritor1
parents:
diff changeset
1166 int PNGAPI
Ritor1
parents:
diff changeset
1167 png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr)
Ritor1
parents:
diff changeset
1168 {
Ritor1
parents:
diff changeset
1169 if (png_ptr != NULL && info_ptr != NULL)
Ritor1
parents:
diff changeset
1170 return png_ptr->num_palette_max;
Ritor1
parents:
diff changeset
1171
Ritor1
parents:
diff changeset
1172 return (-1);
Ritor1
parents:
diff changeset
1173 }
Ritor1
parents:
diff changeset
1174 # endif
Ritor1
parents:
diff changeset
1175 #endif
Ritor1
parents:
diff changeset
1176
Ritor1
parents:
diff changeset
1177 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */