Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: third_party/libpng/pngget.c

Issue 1118002: libpng: update to 1.2.43 (Closed)
Patch Set: Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.2.37 [June 4, 2009] 4 * Last changed in libpng 1.2.43 [February 25, 2010]
5 * For conditions of distribution and use, see copyright notice in png.h 5 * Copyright (c) 1998-2010 Glenn Randers-Pehrson
6 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
8 * (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 *
9 * This code is released under the libpng license.
10 * For conditions of distribution and use, see the disclaimer
11 * and license in png.h
12 *
9 */ 13 */
10 14
11 #define PNG_INTERNAL 15 #define PNG_INTERNAL
16 #define PNG_NO_PEDANTIC_WARNINGS
12 #include "png.h" 17 #include "png.h"
13 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 18 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
14 19
15 png_uint_32 PNGAPI 20 png_uint_32 PNGAPI
16 png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) 21 png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
17 { 22 {
18 if (png_ptr != NULL && info_ptr != NULL) 23 if (png_ptr != NULL && info_ptr != NULL)
19 return(info_ptr->valid & flag); 24 return(info_ptr->valid & flag);
20 25
21 else 26 else
22 return(0); 27 return(0);
23 } 28 }
24 29
25 png_uint_32 PNGAPI 30 png_uint_32 PNGAPI
26 png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) 31 png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
27 { 32 {
28 if (png_ptr != NULL && info_ptr != NULL) 33 if (png_ptr != NULL && info_ptr != NULL)
29 return(info_ptr->rowbytes); 34 return(info_ptr->rowbytes);
30 35
31 else 36 else
32 return(0); 37 return(0);
33 } 38 }
34 39
35 #if defined(PNG_INFO_IMAGE_SUPPORTED) 40 #ifdef PNG_INFO_IMAGE_SUPPORTED
36 png_bytepp PNGAPI 41 png_bytepp PNGAPI
37 png_get_rows(png_structp png_ptr, png_infop info_ptr) 42 png_get_rows(png_structp png_ptr, png_infop info_ptr)
38 { 43 {
39 if (png_ptr != NULL && info_ptr != NULL) 44 if (png_ptr != NULL && info_ptr != NULL)
40 return(info_ptr->row_pointers); 45 return(info_ptr->row_pointers);
41 46
42 else 47 else
43 return(0); 48 return(0);
44 } 49 }
45 #endif 50 #endif
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 if (png_ptr != NULL && info_ptr != NULL) 111 if (png_ptr != NULL && info_ptr != NULL)
107 return info_ptr->compression_type; 112 return info_ptr->compression_type;
108 113
109 return (0); 114 return (0);
110 } 115 }
111 116
112 png_uint_32 PNGAPI 117 png_uint_32 PNGAPI
113 png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) 118 png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
114 { 119 {
115 if (png_ptr != NULL && info_ptr != NULL) 120 if (png_ptr != NULL && info_ptr != NULL)
116 #if defined(PNG_pHYs_SUPPORTED) 121 #ifdef PNG_pHYs_SUPPORTED
117 if (info_ptr->valid & PNG_INFO_pHYs) 122 if (info_ptr->valid & PNG_INFO_pHYs)
118 { 123 {
119 png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter"); 124 png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter");
120 125
121 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER) 126 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
122 return (0); 127 return (0);
123 128
124 else 129 else
125 return (info_ptr->x_pixels_per_unit); 130 return (info_ptr->x_pixels_per_unit);
126 } 131 }
127 #else 132 #else
128 return (0); 133 return (0);
129 #endif 134 #endif
130 return (0); 135 return (0);
131 } 136 }
132 137
133 png_uint_32 PNGAPI 138 png_uint_32 PNGAPI
134 png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) 139 png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
135 { 140 {
136 if (png_ptr != NULL && info_ptr != NULL) 141 if (png_ptr != NULL && info_ptr != NULL)
137 #if defined(PNG_pHYs_SUPPORTED) 142 #ifdef PNG_pHYs_SUPPORTED
138 if (info_ptr->valid & PNG_INFO_pHYs) 143 if (info_ptr->valid & PNG_INFO_pHYs)
139 { 144 {
140 png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter"); 145 png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter");
141 146
142 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER) 147 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
143 return (0); 148 return (0);
144 149
145 else 150 else
146 return (info_ptr->y_pixels_per_unit); 151 return (info_ptr->y_pixels_per_unit);
147 } 152 }
148 #else 153 #else
149 return (0); 154 return (0);
150 #endif 155 #endif
151 return (0); 156 return (0);
152 } 157 }
153 158
154 png_uint_32 PNGAPI 159 png_uint_32 PNGAPI
155 png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) 160 png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
156 { 161 {
157 if (png_ptr != NULL && info_ptr != NULL) 162 if (png_ptr != NULL && info_ptr != NULL)
158 #if defined(PNG_pHYs_SUPPORTED) 163 #ifdef PNG_pHYs_SUPPORTED
159 if (info_ptr->valid & PNG_INFO_pHYs) 164 if (info_ptr->valid & PNG_INFO_pHYs)
160 { 165 {
161 png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter"); 166 png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
162 167
163 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER || 168 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
164 info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) 169 info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
165 return (0); 170 return (0);
166 171
167 else 172 else
168 return (info_ptr->x_pixels_per_unit); 173 return (info_ptr->x_pixels_per_unit);
169 } 174 }
170 #else 175 #else
171 return (0); 176 return (0);
172 #endif 177 #endif
173 return (0); 178 return (0);
174 } 179 }
175 180
176 #ifdef PNG_FLOATING_POINT_SUPPORTED 181 #ifdef PNG_FLOATING_POINT_SUPPORTED
177 float PNGAPI 182 float PNGAPI
178 png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) 183 png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
179 { 184 {
180 if (png_ptr != NULL && info_ptr != NULL) 185 if (png_ptr != NULL && info_ptr != NULL)
181 #if defined(PNG_pHYs_SUPPORTED) 186 #ifdef PNG_pHYs_SUPPORTED
182 187
183 if (info_ptr->valid & PNG_INFO_pHYs) 188 if (info_ptr->valid & PNG_INFO_pHYs)
184 { 189 {
185 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); 190 png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
191
186 if (info_ptr->x_pixels_per_unit == 0) 192 if (info_ptr->x_pixels_per_unit == 0)
187 return ((float)0.0); 193 return ((float)0.0);
194
188 else 195 else
189 return ((float)((float)info_ptr->y_pixels_per_unit 196 return ((float)((float)info_ptr->y_pixels_per_unit
190 /(float)info_ptr->x_pixels_per_unit)); 197 /(float)info_ptr->x_pixels_per_unit));
191 } 198 }
192 #else 199 #else
193 return (0.0); 200 return (0.0);
194 #endif 201 #endif
195 return ((float)0.0); 202 return ((float)0.0);
196 } 203 }
197 #endif 204 #endif
198 205
199 png_int_32 PNGAPI 206 png_int_32 PNGAPI
200 png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) 207 png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
201 { 208 {
202 if (png_ptr != NULL && info_ptr != NULL) 209 if (png_ptr != NULL && info_ptr != NULL)
203 #if defined(PNG_oFFs_SUPPORTED) 210 #ifdef PNG_oFFs_SUPPORTED
204 211
205 if (info_ptr->valid & PNG_INFO_oFFs) 212 if (info_ptr->valid & PNG_INFO_oFFs)
206 { 213 {
207 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); 214 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
208 215
209 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) 216 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
210 return (0); 217 return (0);
211 218
212 else 219 else
213 return (info_ptr->x_offset); 220 return (info_ptr->x_offset);
214 } 221 }
215 #else 222 #else
216 return (0); 223 return (0);
217 #endif 224 #endif
218 return (0); 225 return (0);
219 } 226 }
220 227
221 png_int_32 PNGAPI 228 png_int_32 PNGAPI
222 png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr) 229 png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
223 { 230 {
224 if (png_ptr != NULL && info_ptr != NULL) 231 if (png_ptr != NULL && info_ptr != NULL)
225 232
226 #if defined(PNG_oFFs_SUPPORTED) 233 #ifdef PNG_oFFs_SUPPORTED
227 if (info_ptr->valid & PNG_INFO_oFFs) 234 if (info_ptr->valid & PNG_INFO_oFFs)
228 { 235 {
229 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); 236 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
230 237
231 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) 238 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
232 return (0); 239 return (0);
233 240
234 else 241 else
235 return (info_ptr->y_offset); 242 return (info_ptr->y_offset);
236 } 243 }
237 #else 244 #else
238 return (0); 245 return (0);
239 #endif 246 #endif
240 return (0); 247 return (0);
241 } 248 }
242 249
243 png_int_32 PNGAPI 250 png_int_32 PNGAPI
244 png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr) 251 png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
245 { 252 {
246 if (png_ptr != NULL && info_ptr != NULL) 253 if (png_ptr != NULL && info_ptr != NULL)
247 254
248 #if defined(PNG_oFFs_SUPPORTED) 255 #ifdef PNG_oFFs_SUPPORTED
249 if (info_ptr->valid & PNG_INFO_oFFs) 256 if (info_ptr->valid & PNG_INFO_oFFs)
250 { 257 {
251 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); 258 png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
252 259
253 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) 260 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
254 return (0); 261 return (0);
255 262
256 else 263 else
257 return (info_ptr->x_offset); 264 return (info_ptr->x_offset);
258 } 265 }
259 #else 266 #else
260 return (0); 267 return (0);
261 #endif 268 #endif
262 return (0); 269 return (0);
263 } 270 }
264 271
265 png_int_32 PNGAPI 272 png_int_32 PNGAPI
266 png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr) 273 png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
267 { 274 {
268 if (png_ptr != NULL && info_ptr != NULL) 275 if (png_ptr != NULL && info_ptr != NULL)
269 276
270 #if defined(PNG_oFFs_SUPPORTED) 277 #ifdef PNG_oFFs_SUPPORTED
271 if (info_ptr->valid & PNG_INFO_oFFs) 278 if (info_ptr->valid & PNG_INFO_oFFs)
272 { 279 {
273 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); 280 png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
274 281
275 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) 282 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
276 return (0); 283 return (0);
277 284
278 else 285 else
279 return (info_ptr->y_offset); 286 return (info_ptr->y_offset);
280 } 287 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 *.00003937); 320 *.00003937);
314 } 321 }
315 322
316 float PNGAPI 323 float PNGAPI
317 png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr) 324 png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
318 { 325 {
319 return ((float)png_get_y_offset_microns(png_ptr, info_ptr) 326 return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
320 *.00003937); 327 *.00003937);
321 } 328 }
322 329
323 #if defined(PNG_pHYs_SUPPORTED) 330 #ifdef PNG_pHYs_SUPPORTED
324 png_uint_32 PNGAPI 331 png_uint_32 PNGAPI
325 png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, 332 png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
326 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) 333 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
327 { 334 {
328 png_uint_32 retval = 0; 335 png_uint_32 retval = 0;
329 336
330 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) 337 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
331 { 338 {
332 png_debug1(1, "in %s retrieval function", "pHYs"); 339 png_debug1(1, "in %s retrieval function", "pHYs");
340
333 if (res_x != NULL) 341 if (res_x != NULL)
334 { 342 {
335 *res_x = info_ptr->x_pixels_per_unit; 343 *res_x = info_ptr->x_pixels_per_unit;
336 retval |= PNG_INFO_pHYs; 344 retval |= PNG_INFO_pHYs;
337 } 345 }
338 if (res_y != NULL) 346 if (res_y != NULL)
339 { 347 {
340 *res_y = info_ptr->y_pixels_per_unit; 348 *res_y = info_ptr->y_pixels_per_unit;
341 retval |= PNG_INFO_pHYs; 349 retval |= PNG_INFO_pHYs;
342 } 350 }
(...skipping 28 matching lines...) Expand all
371 379
372 png_bytep PNGAPI 380 png_bytep PNGAPI
373 png_get_signature(png_structp png_ptr, png_infop info_ptr) 381 png_get_signature(png_structp png_ptr, png_infop info_ptr)
374 { 382 {
375 if (png_ptr != NULL && info_ptr != NULL) 383 if (png_ptr != NULL && info_ptr != NULL)
376 return(info_ptr->signature); 384 return(info_ptr->signature);
377 else 385 else
378 return (NULL); 386 return (NULL);
379 } 387 }
380 388
381 #if defined(PNG_bKGD_SUPPORTED) 389 #ifdef PNG_bKGD_SUPPORTED
382 png_uint_32 PNGAPI 390 png_uint_32 PNGAPI
383 png_get_bKGD(png_structp png_ptr, png_infop info_ptr, 391 png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
384 png_color_16p *background) 392 png_color_16p *background)
385 { 393 {
386 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) 394 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
387 && background != NULL) 395 && background != NULL)
388 { 396 {
389 png_debug1(1, "in %s retrieval function", "bKGD"); 397 png_debug1(1, "in %s retrieval function", "bKGD");
398
390 *background = &(info_ptr->background); 399 *background = &(info_ptr->background);
391 return (PNG_INFO_bKGD); 400 return (PNG_INFO_bKGD);
392 } 401 }
393 return (0); 402 return (0);
394 } 403 }
395 #endif 404 #endif
396 405
397 #if defined(PNG_cHRM_SUPPORTED) 406 #ifdef PNG_cHRM_SUPPORTED
398 #ifdef PNG_FLOATING_POINT_SUPPORTED 407 #ifdef PNG_FLOATING_POINT_SUPPORTED
399 png_uint_32 PNGAPI 408 png_uint_32 PNGAPI
400 png_get_cHRM(png_structp png_ptr, png_infop info_ptr, 409 png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
401 double *white_x, double *white_y, double *red_x, double *red_y, 410 double *white_x, double *white_y, double *red_x, double *red_y,
402 double *green_x, double *green_y, double *blue_x, double *blue_y) 411 double *green_x, double *green_y, double *blue_x, double *blue_y)
403 { 412 {
404 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) 413 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
405 { 414 {
406 png_debug1(1, "in %s retrieval function", "cHRM"); 415 png_debug1(1, "in %s retrieval function", "cHRM");
416
407 if (white_x != NULL) 417 if (white_x != NULL)
408 *white_x = (double)info_ptr->x_white; 418 *white_x = (double)info_ptr->x_white;
409 if (white_y != NULL) 419 if (white_y != NULL)
410 *white_y = (double)info_ptr->y_white; 420 *white_y = (double)info_ptr->y_white;
411 if (red_x != NULL) 421 if (red_x != NULL)
412 *red_x = (double)info_ptr->x_red; 422 *red_x = (double)info_ptr->x_red;
413 if (red_y != NULL) 423 if (red_y != NULL)
414 *red_y = (double)info_ptr->y_red; 424 *red_y = (double)info_ptr->y_red;
415 if (green_x != NULL) 425 if (green_x != NULL)
416 *green_x = (double)info_ptr->x_green; 426 *green_x = (double)info_ptr->x_green;
417 if (green_y != NULL) 427 if (green_y != NULL)
418 *green_y = (double)info_ptr->y_green; 428 *green_y = (double)info_ptr->y_green;
419 if (blue_x != NULL) 429 if (blue_x != NULL)
420 *blue_x = (double)info_ptr->x_blue; 430 *blue_x = (double)info_ptr->x_blue;
421 if (blue_y != NULL) 431 if (blue_y != NULL)
422 *blue_y = (double)info_ptr->y_blue; 432 *blue_y = (double)info_ptr->y_blue;
423 return (PNG_INFO_cHRM); 433 return (PNG_INFO_cHRM);
424 } 434 }
425 return (0); 435 return (0);
426 } 436 }
427 #endif 437 #endif
428 #ifdef PNG_FIXED_POINT_SUPPORTED 438 #ifdef PNG_FIXED_POINT_SUPPORTED
429 png_uint_32 PNGAPI 439 png_uint_32 PNGAPI
430 png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, 440 png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
431 png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, 441 png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
432 png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, 442 png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
433 png_fixed_point *blue_x, png_fixed_point *blue_y) 443 png_fixed_point *blue_x, png_fixed_point *blue_y)
434 { 444 {
445 png_debug1(1, "in %s retrieval function", "cHRM");
446
435 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) 447 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
436 { 448 {
437 png_debug1(1, "in %s retrieval function", "cHRM");
438 if (white_x != NULL) 449 if (white_x != NULL)
439 *white_x = info_ptr->int_x_white; 450 *white_x = info_ptr->int_x_white;
440 if (white_y != NULL) 451 if (white_y != NULL)
441 *white_y = info_ptr->int_y_white; 452 *white_y = info_ptr->int_y_white;
442 if (red_x != NULL) 453 if (red_x != NULL)
443 *red_x = info_ptr->int_x_red; 454 *red_x = info_ptr->int_x_red;
444 if (red_y != NULL) 455 if (red_y != NULL)
445 *red_y = info_ptr->int_y_red; 456 *red_y = info_ptr->int_y_red;
446 if (green_x != NULL) 457 if (green_x != NULL)
447 *green_x = info_ptr->int_x_green; 458 *green_x = info_ptr->int_x_green;
448 if (green_y != NULL) 459 if (green_y != NULL)
449 *green_y = info_ptr->int_y_green; 460 *green_y = info_ptr->int_y_green;
450 if (blue_x != NULL) 461 if (blue_x != NULL)
451 *blue_x = info_ptr->int_x_blue; 462 *blue_x = info_ptr->int_x_blue;
452 if (blue_y != NULL) 463 if (blue_y != NULL)
453 *blue_y = info_ptr->int_y_blue; 464 *blue_y = info_ptr->int_y_blue;
454 return (PNG_INFO_cHRM); 465 return (PNG_INFO_cHRM);
455 } 466 }
456 return (0); 467 return (0);
457 } 468 }
458 #endif 469 #endif
459 #endif 470 #endif
460 471
461 #if defined(PNG_gAMA_SUPPORTED) 472 #ifdef PNG_gAMA_SUPPORTED
462 #ifdef PNG_FLOATING_POINT_SUPPORTED 473 #ifdef PNG_FLOATING_POINT_SUPPORTED
463 png_uint_32 PNGAPI 474 png_uint_32 PNGAPI
464 png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) 475 png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
465 { 476 {
477 png_debug1(1, "in %s retrieval function", "gAMA");
478
466 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) 479 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
467 && file_gamma != NULL) 480 && file_gamma != NULL)
468 { 481 {
469 png_debug1(1, "in %s retrieval function", "gAMA");
470 *file_gamma = (double)info_ptr->gamma; 482 *file_gamma = (double)info_ptr->gamma;
471 return (PNG_INFO_gAMA); 483 return (PNG_INFO_gAMA);
472 } 484 }
473 return (0); 485 return (0);
474 } 486 }
475 #endif 487 #endif
476 #ifdef PNG_FIXED_POINT_SUPPORTED 488 #ifdef PNG_FIXED_POINT_SUPPORTED
477 png_uint_32 PNGAPI 489 png_uint_32 PNGAPI
478 png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, 490 png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
479 png_fixed_point *int_file_gamma) 491 png_fixed_point *int_file_gamma)
480 { 492 {
493 png_debug1(1, "in %s retrieval function", "gAMA");
494
481 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) 495 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
482 && int_file_gamma != NULL) 496 && int_file_gamma != NULL)
483 { 497 {
484 png_debug1(1, "in %s retrieval function", "gAMA");
485 *int_file_gamma = info_ptr->int_gamma; 498 *int_file_gamma = info_ptr->int_gamma;
486 return (PNG_INFO_gAMA); 499 return (PNG_INFO_gAMA);
487 } 500 }
488 return (0); 501 return (0);
489 } 502 }
490 #endif 503 #endif
491 #endif 504 #endif
492 505
493 #if defined(PNG_sRGB_SUPPORTED) 506 #ifdef PNG_sRGB_SUPPORTED
494 png_uint_32 PNGAPI 507 png_uint_32 PNGAPI
495 png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) 508 png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
496 { 509 {
510 png_debug1(1, "in %s retrieval function", "sRGB");
511
497 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) 512 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
498 && file_srgb_intent != NULL) 513 && file_srgb_intent != NULL)
499 { 514 {
500 png_debug1(1, "in %s retrieval function", "sRGB");
501 *file_srgb_intent = (int)info_ptr->srgb_intent; 515 *file_srgb_intent = (int)info_ptr->srgb_intent;
502 return (PNG_INFO_sRGB); 516 return (PNG_INFO_sRGB);
503 } 517 }
504 return (0); 518 return (0);
505 } 519 }
506 #endif 520 #endif
507 521
508 #if defined(PNG_iCCP_SUPPORTED) 522 #ifdef PNG_iCCP_SUPPORTED
509 png_uint_32 PNGAPI 523 png_uint_32 PNGAPI
510 png_get_iCCP(png_structp png_ptr, png_infop info_ptr, 524 png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
511 png_charpp name, int *compression_type, 525 png_charpp name, int *compression_type,
512 png_charpp profile, png_uint_32 *proflen) 526 png_charpp profile, png_uint_32 *proflen)
513 { 527 {
528 png_debug1(1, "in %s retrieval function", "iCCP");
529
514 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) 530 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
515 && name != NULL && profile != NULL && proflen != NULL) 531 && name != NULL && profile != NULL && proflen != NULL)
516 { 532 {
517 png_debug1(1, "in %s retrieval function", "iCCP");
518 *name = info_ptr->iccp_name; 533 *name = info_ptr->iccp_name;
519 *profile = info_ptr->iccp_profile; 534 *profile = info_ptr->iccp_profile;
520 /* Compression_type is a dummy so the API won't have to change 535 /* Compression_type is a dummy so the API won't have to change
521 * if we introduce multiple compression types later. 536 * if we introduce multiple compression types later.
522 */ 537 */
523 *proflen = (int)info_ptr->iccp_proflen; 538 *proflen = (int)info_ptr->iccp_proflen;
524 *compression_type = (int)info_ptr->iccp_compression; 539 *compression_type = (int)info_ptr->iccp_compression;
525 return (PNG_INFO_iCCP); 540 return (PNG_INFO_iCCP);
526 } 541 }
527 return (0); 542 return (0);
528 } 543 }
529 #endif 544 #endif
530 545
531 #if defined(PNG_sPLT_SUPPORTED) 546 #ifdef PNG_sPLT_SUPPORTED
532 png_uint_32 PNGAPI 547 png_uint_32 PNGAPI
533 png_get_sPLT(png_structp png_ptr, png_infop info_ptr, 548 png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
534 png_sPLT_tpp spalettes) 549 png_sPLT_tpp spalettes)
535 { 550 {
536 if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) 551 if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
537 { 552 {
538 *spalettes = info_ptr->splt_palettes; 553 *spalettes = info_ptr->splt_palettes;
539 return ((png_uint_32)info_ptr->splt_palettes_num); 554 return ((png_uint_32)info_ptr->splt_palettes_num);
540 } 555 }
541 return (0); 556 return (0);
542 } 557 }
543 #endif 558 #endif
544 559
545 #if defined(PNG_hIST_SUPPORTED) 560 #ifdef PNG_hIST_SUPPORTED
546 png_uint_32 PNGAPI 561 png_uint_32 PNGAPI
547 png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) 562 png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
548 { 563 {
564 png_debug1(1, "in %s retrieval function", "hIST");
565
549 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) 566 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
550 && hist != NULL) 567 && hist != NULL)
551 { 568 {
552 png_debug1(1, "in %s retrieval function", "hIST");
553 *hist = info_ptr->hist; 569 *hist = info_ptr->hist;
554 return (PNG_INFO_hIST); 570 return (PNG_INFO_hIST);
555 } 571 }
556 return (0); 572 return (0);
557 } 573 }
558 #endif 574 #endif
559 575
560 png_uint_32 PNGAPI 576 png_uint_32 PNGAPI
561 png_get_IHDR(png_structp png_ptr, png_infop info_ptr, 577 png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
562 png_uint_32 *width, png_uint_32 *height, int *bit_depth, 578 png_uint_32 *width, png_uint_32 *height, int *bit_depth,
563 int *color_type, int *interlace_type, int *compression_type, 579 int *color_type, int *interlace_type, int *compression_type,
564 int *filter_type) 580 int *filter_type)
565 581
566 { 582 {
567 if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && 583 png_debug1(1, "in %s retrieval function", "IHDR");
568 bit_depth != NULL && color_type != NULL)
569 {
570 png_debug1(1, "in %s retrieval function", "IHDR");
571 *width = info_ptr->width;
572 *height = info_ptr->height;
573 *bit_depth = info_ptr->bit_depth;
574 if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16)
575 png_error(png_ptr, "Invalid bit depth");
576 584
577 *color_type = info_ptr->color_type; 585 if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
586 height == NULL || bit_depth == NULL || color_type == NULL)
587 return (0);
578 588
579 if (info_ptr->color_type > 6) 589 *width = info_ptr->width;
580 png_error(png_ptr, "Invalid color type"); 590 *height = info_ptr->height;
591 *bit_depth = info_ptr->bit_depth;
592 *color_type = info_ptr->color_type;
581 593
582 if (compression_type != NULL) 594 if (compression_type != NULL)
583 *compression_type = info_ptr->compression_type; 595 *compression_type = info_ptr->compression_type;
584 596
585 if (filter_type != NULL) 597 if (filter_type != NULL)
586 *filter_type = info_ptr->filter_type; 598 *filter_type = info_ptr->filter_type;
587 599
588 if (interlace_type != NULL) 600 if (interlace_type != NULL)
589 *interlace_type = info_ptr->interlace_type; 601 *interlace_type = info_ptr->interlace_type;
590 602
591 /* Check for potential overflow of rowbytes */ 603 /* This is redundant if we can be sure that the info_ptr values were all
592 if (*width == 0 || *width > PNG_UINT_31_MAX) 604 * assigned in png_set_IHDR(). We do the check anyhow in case an
593 png_error(png_ptr, "Invalid image width"); 605 * application has ignored our advice not to mess with the members
606 * of info_ptr directly.
607 */
608 png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height,
609 info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
610 info_ptr->compression_type, info_ptr->filter_type);
594 611
595 if (*height == 0 || *height > PNG_UINT_31_MAX) 612 return (1);
596 png_error(png_ptr, "Invalid image height");
597
598 if (info_ptr->width > (PNG_UINT_32_MAX
599 >> 3) /* 8-byte RGBA pixels */
600 - 64 /* bigrowbuf hack */
601 - 1 /* filter byte */
602 - 7*8 /* rounding of width to multiple of 8 pixels */
603 - 8) /* extra max_pixel_depth pad */
604 {
605 png_warning(png_ptr,
606 "Width too large for libpng to process image data.");
607 }
608
609 return (1);
610 }
611 return (0);
612 } 613 }
613 614
614 #if defined(PNG_oFFs_SUPPORTED) 615 #ifdef PNG_oFFs_SUPPORTED
615 png_uint_32 PNGAPI 616 png_uint_32 PNGAPI
616 png_get_oFFs(png_structp png_ptr, png_infop info_ptr, 617 png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
617 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) 618 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
618 { 619 {
620 png_debug1(1, "in %s retrieval function", "oFFs");
621
619 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) 622 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
620 && offset_x != NULL && offset_y != NULL && unit_type != NULL) 623 && offset_x != NULL && offset_y != NULL && unit_type != NULL)
621 { 624 {
622 png_debug1(1, "in %s retrieval function", "oFFs");
623 *offset_x = info_ptr->x_offset; 625 *offset_x = info_ptr->x_offset;
624 *offset_y = info_ptr->y_offset; 626 *offset_y = info_ptr->y_offset;
625 *unit_type = (int)info_ptr->offset_unit_type; 627 *unit_type = (int)info_ptr->offset_unit_type;
626 return (PNG_INFO_oFFs); 628 return (PNG_INFO_oFFs);
627 } 629 }
628 return (0); 630 return (0);
629 } 631 }
630 #endif 632 #endif
631 633
632 #if defined(PNG_pCAL_SUPPORTED) 634 #ifdef PNG_pCAL_SUPPORTED
633 png_uint_32 PNGAPI 635 png_uint_32 PNGAPI
634 png_get_pCAL(png_structp png_ptr, png_infop info_ptr, 636 png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
635 png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, 637 png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
636 png_charp *units, png_charpp *params) 638 png_charp *units, png_charpp *params)
637 { 639 {
640 png_debug1(1, "in %s retrieval function", "pCAL");
641
638 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) 642 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
639 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && 643 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
640 nparams != NULL && units != NULL && params != NULL) 644 nparams != NULL && units != NULL && params != NULL)
641 { 645 {
642 png_debug1(1, "in %s retrieval function", "pCAL");
643 *purpose = info_ptr->pcal_purpose; 646 *purpose = info_ptr->pcal_purpose;
644 *X0 = info_ptr->pcal_X0; 647 *X0 = info_ptr->pcal_X0;
645 *X1 = info_ptr->pcal_X1; 648 *X1 = info_ptr->pcal_X1;
646 *type = (int)info_ptr->pcal_type; 649 *type = (int)info_ptr->pcal_type;
647 *nparams = (int)info_ptr->pcal_nparams; 650 *nparams = (int)info_ptr->pcal_nparams;
648 *units = info_ptr->pcal_units; 651 *units = info_ptr->pcal_units;
649 *params = info_ptr->pcal_params; 652 *params = info_ptr->pcal_params;
650 return (PNG_INFO_pCAL); 653 return (PNG_INFO_pCAL);
651 } 654 }
652 return (0); 655 return (0);
653 } 656 }
654 #endif 657 #endif
655 658
656 #if defined(PNG_sCAL_SUPPORTED) 659 #ifdef PNG_sCAL_SUPPORTED
657 #ifdef PNG_FLOATING_POINT_SUPPORTED 660 #ifdef PNG_FLOATING_POINT_SUPPORTED
658 png_uint_32 PNGAPI 661 png_uint_32 PNGAPI
659 png_get_sCAL(png_structp png_ptr, png_infop info_ptr, 662 png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
660 int *unit, double *width, double *height) 663 int *unit, double *width, double *height)
661 { 664 {
662 if (png_ptr != NULL && info_ptr != NULL && 665 if (png_ptr != NULL && info_ptr != NULL &&
663 (info_ptr->valid & PNG_INFO_sCAL)) 666 (info_ptr->valid & PNG_INFO_sCAL))
664 { 667 {
665 *unit = info_ptr->scal_unit; 668 *unit = info_ptr->scal_unit;
666 *width = info_ptr->scal_pixel_width; 669 *width = info_ptr->scal_pixel_width;
(...skipping 15 matching lines...) Expand all
682 *width = info_ptr->scal_s_width; 685 *width = info_ptr->scal_s_width;
683 *height = info_ptr->scal_s_height; 686 *height = info_ptr->scal_s_height;
684 return (PNG_INFO_sCAL); 687 return (PNG_INFO_sCAL);
685 } 688 }
686 return(0); 689 return(0);
687 } 690 }
688 #endif 691 #endif
689 #endif 692 #endif
690 #endif 693 #endif
691 694
692 #if defined(PNG_pHYs_SUPPORTED) 695 #ifdef PNG_pHYs_SUPPORTED
693 png_uint_32 PNGAPI 696 png_uint_32 PNGAPI
694 png_get_pHYs(png_structp png_ptr, png_infop info_ptr, 697 png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
695 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) 698 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
696 { 699 {
697 png_uint_32 retval = 0; 700 png_uint_32 retval = 0;
698 701
702 png_debug1(1, "in %s retrieval function", "pHYs");
703
699 if (png_ptr != NULL && info_ptr != NULL && 704 if (png_ptr != NULL && info_ptr != NULL &&
700 (info_ptr->valid & PNG_INFO_pHYs)) 705 (info_ptr->valid & PNG_INFO_pHYs))
701 { 706 {
702 png_debug1(1, "in %s retrieval function", "pHYs");
703
704 if (res_x != NULL) 707 if (res_x != NULL)
705 { 708 {
706 *res_x = info_ptr->x_pixels_per_unit; 709 *res_x = info_ptr->x_pixels_per_unit;
707 retval |= PNG_INFO_pHYs; 710 retval |= PNG_INFO_pHYs;
708 } 711 }
709 712
710 if (res_y != NULL) 713 if (res_y != NULL)
711 { 714 {
712 *res_y = info_ptr->y_pixels_per_unit; 715 *res_y = info_ptr->y_pixels_per_unit;
713 retval |= PNG_INFO_pHYs; 716 retval |= PNG_INFO_pHYs;
714 } 717 }
715 718
716 if (unit_type != NULL) 719 if (unit_type != NULL)
717 { 720 {
718 *unit_type = (int)info_ptr->phys_unit_type; 721 *unit_type = (int)info_ptr->phys_unit_type;
719 retval |= PNG_INFO_pHYs; 722 retval |= PNG_INFO_pHYs;
720 } 723 }
721 } 724 }
722 return (retval); 725 return (retval);
723 } 726 }
724 #endif 727 #endif
725 728
726 png_uint_32 PNGAPI 729 png_uint_32 PNGAPI
727 png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, 730 png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
728 int *num_palette) 731 int *num_palette)
729 { 732 {
733 png_debug1(1, "in %s retrieval function", "PLTE");
734
730 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) 735 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
731 && palette != NULL) 736 && palette != NULL)
732 { 737 {
733 png_debug1(1, "in %s retrieval function", "PLTE");
734 *palette = info_ptr->palette; 738 *palette = info_ptr->palette;
735 *num_palette = info_ptr->num_palette; 739 *num_palette = info_ptr->num_palette;
736 png_debug1(3, "num_palette = %d", *num_palette); 740 png_debug1(3, "num_palette = %d", *num_palette);
737 return (PNG_INFO_PLTE); 741 return (PNG_INFO_PLTE);
738 } 742 }
739 return (0); 743 return (0);
740 } 744 }
741 745
742 #if defined(PNG_sBIT_SUPPORTED) 746 #ifdef PNG_sBIT_SUPPORTED
743 png_uint_32 PNGAPI 747 png_uint_32 PNGAPI
744 png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) 748 png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
745 { 749 {
750 png_debug1(1, "in %s retrieval function", "sBIT");
751
746 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) 752 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
747 && sig_bit != NULL) 753 && sig_bit != NULL)
748 { 754 {
749 png_debug1(1, "in %s retrieval function", "sBIT");
750 *sig_bit = &(info_ptr->sig_bit); 755 *sig_bit = &(info_ptr->sig_bit);
751 return (PNG_INFO_sBIT); 756 return (PNG_INFO_sBIT);
752 } 757 }
753 return (0); 758 return (0);
754 } 759 }
755 #endif 760 #endif
756 761
757 #if defined(PNG_TEXT_SUPPORTED) 762 #ifdef PNG_TEXT_SUPPORTED
758 png_uint_32 PNGAPI 763 png_uint_32 PNGAPI
759 png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, 764 png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
760 int *num_text) 765 int *num_text)
761 { 766 {
762 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) 767 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
763 { 768 {
764 png_debug1(1, "in %s retrieval function", 769 png_debug1(1, "in %s retrieval function",
765 (png_ptr->chunk_name[0] == '\0' ? "text" 770 (png_ptr->chunk_name[0] == '\0' ? "text"
766 : (png_const_charp)png_ptr->chunk_name)); 771 : (png_const_charp)png_ptr->chunk_name));
767 772
768 if (text_ptr != NULL) 773 if (text_ptr != NULL)
769 *text_ptr = info_ptr->text; 774 *text_ptr = info_ptr->text;
770 775
771 if (num_text != NULL) 776 if (num_text != NULL)
772 *num_text = info_ptr->num_text; 777 *num_text = info_ptr->num_text;
773 778
774 return ((png_uint_32)info_ptr->num_text); 779 return ((png_uint_32)info_ptr->num_text);
775 } 780 }
776 if (num_text != NULL) 781 if (num_text != NULL)
777 *num_text = 0; 782 *num_text = 0;
778 return(0); 783 return(0);
779 } 784 }
780 #endif 785 #endif
781 786
782 #if defined(PNG_tIME_SUPPORTED) 787 #ifdef PNG_tIME_SUPPORTED
783 png_uint_32 PNGAPI 788 png_uint_32 PNGAPI
784 png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) 789 png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
785 { 790 {
791 png_debug1(1, "in %s retrieval function", "tIME");
792
786 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) 793 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
787 && mod_time != NULL) 794 && mod_time != NULL)
788 { 795 {
789 png_debug1(1, "in %s retrieval function", "tIME");
790 *mod_time = &(info_ptr->mod_time); 796 *mod_time = &(info_ptr->mod_time);
791 return (PNG_INFO_tIME); 797 return (PNG_INFO_tIME);
792 } 798 }
793 return (0); 799 return (0);
794 } 800 }
795 #endif 801 #endif
796 802
797 #if defined(PNG_tRNS_SUPPORTED) 803 #ifdef PNG_tRNS_SUPPORTED
798 png_uint_32 PNGAPI 804 png_uint_32 PNGAPI
799 png_get_tRNS(png_structp png_ptr, png_infop info_ptr, 805 png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
800 png_bytep *trans, int *num_trans, png_color_16p *trans_values) 806 png_bytep *trans, int *num_trans, png_color_16p *trans_values)
801 { 807 {
802 png_uint_32 retval = 0; 808 png_uint_32 retval = 0;
803 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) 809 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
804 { 810 {
805 png_debug1(1, "in %s retrieval function", "tRNS"); 811 png_debug1(1, "in %s retrieval function", "tRNS");
812
806 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) 813 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
807 { 814 {
808 if (trans != NULL) 815 if (trans != NULL)
809 { 816 {
810 *trans = info_ptr->trans; 817 *trans = info_ptr->trans;
811 retval |= PNG_INFO_tRNS; 818 retval |= PNG_INFO_tRNS;
812 } 819 }
813 820
814 if (trans_values != NULL) 821 if (trans_values != NULL)
815 *trans_values = &(info_ptr->trans_values); 822 *trans_values = &(info_ptr->trans_values);
(...skipping 12 matching lines...) Expand all
828 if (num_trans != NULL) 835 if (num_trans != NULL)
829 { 836 {
830 *num_trans = info_ptr->num_trans; 837 *num_trans = info_ptr->num_trans;
831 retval |= PNG_INFO_tRNS; 838 retval |= PNG_INFO_tRNS;
832 } 839 }
833 } 840 }
834 return (retval); 841 return (retval);
835 } 842 }
836 #endif 843 #endif
837 844
838 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) 845 #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
839 png_uint_32 PNGAPI 846 png_uint_32 PNGAPI
840 png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, 847 png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
841 png_unknown_chunkpp unknowns) 848 png_unknown_chunkpp unknowns)
842 { 849 {
843 if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL) 850 if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
844 { 851 {
845 *unknowns = info_ptr->unknown_chunks; 852 *unknowns = info_ptr->unknown_chunks;
846 return ((png_uint_32)info_ptr->unknown_chunks_num); 853 return ((png_uint_32)info_ptr->unknown_chunks_num);
847 } 854 }
848 return (0); 855 return (0);
849 } 856 }
850 #endif 857 #endif
851 858
852 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) 859 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
853 png_byte PNGAPI 860 png_byte PNGAPI
854 png_get_rgb_to_gray_status (png_structp png_ptr) 861 png_get_rgb_to_gray_status (png_structp png_ptr)
855 { 862 {
856 return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0); 863 return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0);
857 } 864 }
858 #endif 865 #endif
859 866
860 #if defined(PNG_USER_CHUNKS_SUPPORTED) 867 #ifdef PNG_USER_CHUNKS_SUPPORTED
861 png_voidp PNGAPI 868 png_voidp PNGAPI
862 png_get_user_chunk_ptr(png_structp png_ptr) 869 png_get_user_chunk_ptr(png_structp png_ptr)
863 { 870 {
864 return (png_ptr? png_ptr->user_chunk_ptr : NULL); 871 return (png_ptr? png_ptr->user_chunk_ptr : NULL);
865 } 872 }
866 #endif 873 #endif
867 874
868 #ifdef PNG_WRITE_SUPPORTED
869 png_uint_32 PNGAPI 875 png_uint_32 PNGAPI
870 png_get_compression_buffer_size(png_structp png_ptr) 876 png_get_compression_buffer_size(png_structp png_ptr)
871 { 877 {
872 return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L); 878 return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L);
873 } 879 }
874 #endif
875 880
876 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED 881 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
877 #ifndef PNG_1_0_X 882 #ifndef PNG_1_0_X
878 /* This function was added to libpng 1.2.0 and should exist by default */ 883 /* This function was added to libpng 1.2.0 and should exist by default */
879 png_uint_32 PNGAPI 884 png_uint_32 PNGAPI
880 png_get_asm_flags (png_structp png_ptr) 885 png_get_asm_flags (png_structp png_ptr)
881 { 886 {
882 /* Obsolete, to be removed from libpng-1.4.0 */ 887 /* Obsolete, to be removed from libpng-1.4.0 */
883 return (png_ptr? 0L: 0L); 888 return (png_ptr? 0L: 0L);
884 } 889 }
(...skipping 30 matching lines...) Expand all
915 png_uint_32 PNGAPI 920 png_uint_32 PNGAPI
916 png_get_mmx_rowbytes_threshold (png_structp png_ptr) 921 png_get_mmx_rowbytes_threshold (png_structp png_ptr)
917 { 922 {
918 /* Obsolete, to be removed from libpng-1.4.0 */ 923 /* Obsolete, to be removed from libpng-1.4.0 */
919 return (png_ptr? 0L: 0L); 924 return (png_ptr? 0L: 0L);
920 } 925 }
921 #endif /* ?PNG_1_0_X */ 926 #endif /* ?PNG_1_0_X */
922 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ 927 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
923 928
924 #ifdef PNG_SET_USER_LIMITS_SUPPORTED 929 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
925 /* These functions were added to libpng 1.2.6 */ 930 /* These functions were added to libpng 1.2.6 but not enabled
931 * by default. They will be enabled in libpng-1.4.0 */
926 png_uint_32 PNGAPI 932 png_uint_32 PNGAPI
927 png_get_user_width_max (png_structp png_ptr) 933 png_get_user_width_max (png_structp png_ptr)
928 { 934 {
929 return (png_ptr? png_ptr->user_width_max : 0); 935 return (png_ptr? png_ptr->user_width_max : 0);
930 } 936 }
931 png_uint_32 PNGAPI 937 png_uint_32 PNGAPI
932 png_get_user_height_max (png_structp png_ptr) 938 png_get_user_height_max (png_structp png_ptr)
933 { 939 {
934 return (png_ptr? png_ptr->user_height_max : 0); 940 return (png_ptr? png_ptr->user_height_max : 0);
935 } 941 }
936 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ 942 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
937
938 943
939 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ 944 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698