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