pngget.c 30.0 KB
Newer Older
A
Andreas Dilger 已提交
1 2

/* pngget.c - retrieval of values from info struct
3
 *
4
 * Last changed in libpng 1.5.5 [(PENDING RELEASE)]
5
 * Copyright (c) 1998-2011 Glenn Randers-Pehrson
6 7
 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
 * (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
 *
13
 */
A
Andreas Dilger 已提交
14

15
#include "pngpriv.h"
16

17 18
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)

19
png_uint_32 PNGAPI
20
png_get_valid(png_const_structp png_ptr, png_const_infop info_ptr,
21
    png_uint_32 flag)
A
Andreas Dilger 已提交
22
{
23
   if (png_ptr != NULL && info_ptr != NULL)
A
Andreas Dilger 已提交
24
      return(info_ptr->valid & flag);
25

26
   return(0);
A
Andreas Dilger 已提交
27 28
}

29
png_size_t PNGAPI
30
png_get_rowbytes(png_const_structp png_ptr, png_const_infop info_ptr)
A
Andreas Dilger 已提交
31
{
32
   if (png_ptr != NULL && info_ptr != NULL)
A
Andreas Dilger 已提交
33
      return(info_ptr->rowbytes);
34

35
   return(0);
A
Andreas Dilger 已提交
36 37
}

38
#ifdef PNG_INFO_IMAGE_SUPPORTED
39
png_bytepp PNGAPI
40
png_get_rows(png_const_structp png_ptr, png_const_infop info_ptr)
41 42 43
{
   if (png_ptr != NULL && info_ptr != NULL)
      return(info_ptr->row_pointers);
44

45
   return(0);
46 47 48
}
#endif

49
#ifdef PNG_EASY_ACCESS_SUPPORTED
50
/* Easy access to info, added in libpng-0.99 */
51
png_uint_32 PNGAPI
52
png_get_image_width(png_const_structp png_ptr, png_const_infop info_ptr)
53
{
54
   if (png_ptr != NULL && info_ptr != NULL)
55
      return info_ptr->width;
56

57 58 59
   return (0);
}

60
png_uint_32 PNGAPI
61
png_get_image_height(png_const_structp png_ptr, png_const_infop info_ptr)
62
{
63
   if (png_ptr != NULL && info_ptr != NULL)
64
      return info_ptr->height;
65

66 67 68
   return (0);
}

69
png_byte PNGAPI
70
png_get_bit_depth(png_const_structp png_ptr, png_const_infop info_ptr)
71
{
72
   if (png_ptr != NULL && info_ptr != NULL)
73
      return info_ptr->bit_depth;
74

75 76 77
   return (0);
}

78
png_byte PNGAPI
79
png_get_color_type(png_const_structp png_ptr, png_const_infop info_ptr)
80
{
81
   if (png_ptr != NULL && info_ptr != NULL)
82
      return info_ptr->color_type;
83

84 85 86
   return (0);
}

87
png_byte PNGAPI
88
png_get_filter_type(png_const_structp png_ptr, png_const_infop info_ptr)
89
{
90
   if (png_ptr != NULL && info_ptr != NULL)
91
      return info_ptr->filter_type;
92

93 94 95
   return (0);
}

96
png_byte PNGAPI
97
png_get_interlace_type(png_const_structp png_ptr, png_const_infop info_ptr)
98
{
99
   if (png_ptr != NULL && info_ptr != NULL)
100
      return info_ptr->interlace_type;
101

102 103 104
   return (0);
}

105
png_byte PNGAPI
106
png_get_compression_type(png_const_structp png_ptr, png_const_infop info_ptr)
107
{
108
   if (png_ptr != NULL && info_ptr != NULL)
109
      return info_ptr->compression_type;
110

111 112 113
   return (0);
}

114
png_uint_32 PNGAPI
115
png_get_x_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
116
{
117
#ifdef PNG_pHYs_SUPPORTED
118 119 120 121
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
      {
         png_debug1(1, "in %s retrieval function",
             "png_get_x_pixels_per_meter");
122

123 124 125
         if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
            return (info_ptr->x_pixels_per_unit);
      }
126
#endif
127

128 129 130
   return (0);
}

131
png_uint_32 PNGAPI
132
png_get_y_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
133
{
134
#ifdef PNG_pHYs_SUPPORTED
135
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
136
   {
137 138
      png_debug1(1, "in %s retrieval function",
          "png_get_y_pixels_per_meter");
139

140
      if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
141
         return (info_ptr->y_pixels_per_unit);
142 143
   }
#endif
144

145 146 147
   return (0);
}

148
png_uint_32 PNGAPI
149
png_get_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
150
{
151
#ifdef PNG_pHYs_SUPPORTED
152
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
153
   {
154
      png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
155

156 157
      if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER &&
          info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit)
158
         return (info_ptr->x_pixels_per_unit);
159 160
   }
#endif
161

162 163 164
   return (0);
}

165
#ifdef PNG_FLOATING_POINT_SUPPORTED
166
float PNGAPI
167
png_get_pixel_aspect_ratio(png_const_structp png_ptr, png_const_infop info_ptr)
168
{
169
#ifdef PNG_READ_pHYs_SUPPORTED
170
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
171
   {
172
      png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
173

174
      if (info_ptr->x_pixels_per_unit != 0)
175
         return ((float)((float)info_ptr->y_pixels_per_unit
176
             /(float)info_ptr->x_pixels_per_unit));
177 178
   }
#endif
179

180
   return ((float)0.0);
181
}
182
#endif
183

184 185
#ifdef PNG_FIXED_POINT_SUPPORTED
png_fixed_point PNGAPI
186 187
png_get_pixel_aspect_ratio_fixed(png_const_structp png_ptr,
    png_const_infop info_ptr)
188 189 190
{
#ifdef PNG_READ_pHYs_SUPPORTED
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)
191 192 193
       && info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0
       && info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX
       && info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX)
194 195 196 197 198
   {
      png_fixed_point res;

      png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio_fixed");

199 200 201 202 203
      /* The following casts work because a PNG 4 byte integer only has a valid
       * range of 0..2^31-1; otherwise the cast might overflow.
       */
      if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1,
          (png_int_32)info_ptr->x_pixels_per_unit))
204
         return res;
205 206
   }
#endif
207

208 209 210 211
   return 0;
}
#endif

212
png_int_32 PNGAPI
213
png_get_x_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
214
{
215
#ifdef PNG_oFFs_SUPPORTED
216
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
217
   {
218
      png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
219

220
      if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
221
         return (info_ptr->x_offset);
222 223
   }
#endif
224

225 226 227
   return (0);
}

228
png_int_32 PNGAPI
229
png_get_y_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
230
{
231
#ifdef PNG_oFFs_SUPPORTED
232
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
233
   {
234
      png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
235

236
      if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
237
         return (info_ptr->y_offset);
238 239
   }
#endif
240

241 242 243
   return (0);
}

244
png_int_32 PNGAPI
245
png_get_x_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)
246
{
247
#ifdef PNG_oFFs_SUPPORTED
248
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
249
   {
G
[devel]  
Glenn Randers-Pehrson 已提交
250
      png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels");
251

252
      if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
253
         return (info_ptr->x_offset);
254 255
   }
#endif
256

257 258 259
   return (0);
}

260
png_int_32 PNGAPI
261
png_get_y_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)
262
{
263
#ifdef PNG_oFFs_SUPPORTED
264
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
265
   {
G
[devel]  
Glenn Randers-Pehrson 已提交
266
      png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels");
267

268
      if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
269
         return (info_ptr->y_offset);
270 271
   }
#endif
272

273 274 275
   return (0);
}

G
[devel]  
Glenn Randers-Pehrson 已提交
276 277 278 279 280
#ifdef PNG_INCH_CONVERSIONS_SUPPORTED
static png_uint_32
ppi_from_ppm(png_uint_32 ppm)
{
#if 0
281
   /* The conversion is *(2.54/100), in binary (32 digits):
G
[devel]  
Glenn Randers-Pehrson 已提交
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
    * .00000110100000001001110101001001
    */
   png_uint_32 t1001, t1101;
   ppm >>= 1;                  /* .1 */
   t1001 = ppm + (ppm >> 3);   /* .1001 */
   t1101 = t1001 + (ppm >> 1); /* .1101 */
   ppm >>= 20;                 /* .000000000000000000001 */
   t1101 += t1101 >> 15;       /* .1101000000000001101 */
   t1001 >>= 11;               /* .000000000001001 */
   t1001 += t1001 >> 12;       /* .000000000001001000000001001 */
   ppm += t1001;               /* .000000000001001000001001001 */
   ppm += t1101;               /* .110100000001001110101001001 */
   return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */
#else
   /* The argument is a PNG unsigned integer, so it is not permitted
    * to be bigger than 2^31.
    */
   png_fixed_point result;
300 301
   if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127,
       5000))
G
[devel]  
Glenn Randers-Pehrson 已提交
302 303 304 305 306 307 308
      return result;

   /* Overflow. */
   return 0;
#endif
}

309
png_uint_32 PNGAPI
310
png_get_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
311
{
G
[devel]  
Glenn Randers-Pehrson 已提交
312
   return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr));
313 314
}

315
png_uint_32 PNGAPI
316
png_get_x_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
317
{
G
[devel]  
Glenn Randers-Pehrson 已提交
318
   return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr));
319 320
}

321
png_uint_32 PNGAPI
322
png_get_y_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
323
{
G
[devel]  
Glenn Randers-Pehrson 已提交
324 325 326 327 328 329 330 331
   return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr));
}

#ifdef PNG_FIXED_POINT_SUPPORTED
static png_fixed_point
png_fixed_inches_from_microns(png_structp png_ptr, png_int_32 microns)
{
   /* 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.
G
[devel]  
Glenn Randers-Pehrson 已提交
333 334 335 336 337 338 339
    * Notice that this can overflow - a warning is output and 0 is
    * returned.
    */
   return png_muldiv_warn(png_ptr, microns, 500, 127);
}

png_fixed_point PNGAPI
340
png_get_x_offset_inches_fixed(png_structp png_ptr,
341
    png_const_infop info_ptr)
G
[devel]  
Glenn Randers-Pehrson 已提交
342 343
{
   return png_fixed_inches_from_microns(png_ptr,
344
       png_get_x_offset_microns(png_ptr, info_ptr));
G
[devel]  
Glenn Randers-Pehrson 已提交
345 346 347 348 349
}
#endif

#ifdef PNG_FIXED_POINT_SUPPORTED
png_fixed_point PNGAPI
350
png_get_y_offset_inches_fixed(png_structp png_ptr,
351
    png_const_infop info_ptr)
G
[devel]  
Glenn Randers-Pehrson 已提交
352 353
{
   return png_fixed_inches_from_microns(png_ptr,
354
       png_get_y_offset_microns(png_ptr, info_ptr));
355
}
G
[devel]  
Glenn Randers-Pehrson 已提交
356
#endif
357

G
[devel]  
Glenn Randers-Pehrson 已提交
358
#ifdef PNG_FLOATING_POINT_SUPPORTED
359
float PNGAPI
360
png_get_x_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
361
{
G
[devel]  
Glenn Randers-Pehrson 已提交
362 363 364
   /* To avoid the overflow do the conversion directly in floating
    * point.
    */
365
   return (float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937);
366
}
G
[devel]  
Glenn Randers-Pehrson 已提交
367
#endif
368

G
[devel]  
Glenn Randers-Pehrson 已提交
369
#ifdef PNG_FLOATING_POINT_SUPPORTED
370
float PNGAPI
371
png_get_y_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
372
{
G
[devel]  
Glenn Randers-Pehrson 已提交
373 374 375
   /* To avoid the overflow do the conversion directly in floating
    * point.
    */
376
   return (float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937);
377
}
G
[devel]  
Glenn Randers-Pehrson 已提交
378
#endif
379

380
#ifdef PNG_pHYs_SUPPORTED
381
png_uint_32 PNGAPI
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)
384 385 386
{
   png_uint_32 retval = 0;

387
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
388
   {
389
      png_debug1(1, "in %s retrieval function", "pHYs");
390

391 392 393 394 395
      if (res_x != NULL)
      {
         *res_x = info_ptr->x_pixels_per_unit;
         retval |= PNG_INFO_pHYs;
      }
396

397 398 399 400 401
      if (res_y != NULL)
      {
         *res_y = info_ptr->y_pixels_per_unit;
         retval |= PNG_INFO_pHYs;
      }
402

403 404 405 406
      if (unit_type != NULL)
      {
         *unit_type = (int)info_ptr->phys_unit_type;
         retval |= PNG_INFO_pHYs;
407

408
         if (*unit_type == 1)
409
         {
410 411
            if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
            if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
412 413 414
         }
      }
   }
415

416 417
   return (retval);
}
418
#endif /* PNG_pHYs_SUPPORTED */
G
[devel]  
Glenn Randers-Pehrson 已提交
419
#endif  /* PNG_INCH_CONVERSIONS_SUPPORTED */
420 421

/* png_get_channels really belongs in here, too, but it's been around longer */
422

423 424
#endif  /* PNG_EASY_ACCESS_SUPPORTED */

425
png_byte PNGAPI
426
png_get_channels(png_const_structp png_ptr, png_const_infop info_ptr)
A
Andreas Dilger 已提交
427
{
428
   if (png_ptr != NULL && info_ptr != NULL)
A
Andreas Dilger 已提交
429
      return(info_ptr->channels);
430

431
   return (0);
A
Andreas Dilger 已提交
432 433
}

434
png_const_bytep PNGAPI
435
png_get_signature(png_const_structp png_ptr, png_infop info_ptr)
A
Andreas Dilger 已提交
436
{
437
   if (png_ptr != NULL && info_ptr != NULL)
A
Andreas Dilger 已提交
438
      return(info_ptr->signature);
439

440
   return (NULL);
A
Andreas Dilger 已提交
441 442
}

443
#ifdef PNG_bKGD_SUPPORTED
444
png_uint_32 PNGAPI
445
png_get_bKGD(png_const_structp png_ptr, png_infop info_ptr,
A
Andreas Dilger 已提交
446 447
   png_color_16p *background)
{
448
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
449
       && background != NULL)
A
Andreas Dilger 已提交
450
   {
451
      png_debug1(1, "in %s retrieval function", "bKGD");
452

A
Andreas Dilger 已提交
453 454 455
      *background = &(info_ptr->background);
      return (PNG_INFO_bKGD);
   }
456

A
Andreas Dilger 已提交
457 458 459 460
   return (0);
}
#endif

461
#ifdef PNG_cHRM_SUPPORTED
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520
/* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the
 * same time to correct the rgb grayscale coefficient defaults obtained from the
 * cHRM chunk in 1.5.4
 */
png_uint_32 PNGFAPI
png_get_cHRM_XYZ_fixed(png_structp png_ptr, png_const_infop info_ptr,
    png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
    png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
    png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
    png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
    png_fixed_point *int_blue_Z)
{
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
   {
      png_xy xy;
      png_XYZ XYZ;

      png_debug1(1, "in %s retrieval function", "cHRM_XYZ");

      xy.whitex = info_ptr->x_white;
      xy.whitey = info_ptr->y_white;
      xy.redx = info_ptr->x_red;
      xy.redy = info_ptr->y_red;
      xy.greenx = info_ptr->x_green;
      xy.greeny = info_ptr->y_green;
      xy.bluex = info_ptr->x_blue;
      xy.bluey = info_ptr->y_blue;

      /* The *_checked function handles error reporting, so just return 0 if
       * there is a failure here.
       */
      if (png_XYZ_from_xy_checked(png_ptr, &XYZ, xy))
      {
         if (int_red_X != NULL)
            *int_red_X = XYZ.redX;
         if (int_red_Y != NULL)
            *int_red_Y = XYZ.redY;
         if (int_red_Z != NULL)
            *int_red_Z = XYZ.redZ;
         if (int_green_X != NULL)
            *int_green_X = XYZ.greenX;
         if (int_green_Y != NULL)
            *int_green_Y = XYZ.greenY;
         if (int_green_Z != NULL)
            *int_green_Z = XYZ.greenZ;
         if (int_blue_X != NULL)
            *int_blue_X = XYZ.blueX;
         if (int_blue_Y != NULL)
            *int_blue_Y = XYZ.blueY;
         if (int_blue_Z != NULL)
            *int_blue_Z = XYZ.blueZ;

         return (PNG_INFO_cHRM);
      }
   }

   return (0);
}

521
#  ifdef PNG_FLOATING_POINT_SUPPORTED
522
png_uint_32 PNGAPI
523
png_get_cHRM(png_const_structp png_ptr, png_const_infop info_ptr,
524 525
    double *white_x, double *white_y, double *red_x, double *red_y,
    double *green_x, double *green_y, double *blue_x, double *blue_y)
A
Andreas Dilger 已提交
526
{
527
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
A
Andreas Dilger 已提交
528
   {
529
      png_debug1(1, "in %s retrieval function", "cHRM");
530

A
Andreas Dilger 已提交
531
      if (white_x != NULL)
G
[devel]  
Glenn Randers-Pehrson 已提交
532
         *white_x = png_float(png_ptr, info_ptr->x_white, "cHRM white X");
A
Andreas Dilger 已提交
533
      if (white_y != NULL)
G
[devel]  
Glenn Randers-Pehrson 已提交
534
         *white_y = png_float(png_ptr, info_ptr->y_white, "cHRM white Y");
A
Andreas Dilger 已提交
535
      if (red_x != NULL)
G
[devel]  
Glenn Randers-Pehrson 已提交
536
         *red_x = png_float(png_ptr, info_ptr->x_red, "cHRM red X");
A
Andreas Dilger 已提交
537
      if (red_y != NULL)
G
[devel]  
Glenn Randers-Pehrson 已提交
538
         *red_y = png_float(png_ptr, info_ptr->y_red, "cHRM red Y");
A
Andreas Dilger 已提交
539
      if (green_x != NULL)
G
[devel]  
Glenn Randers-Pehrson 已提交
540
         *green_x = png_float(png_ptr, info_ptr->x_green, "cHRM green X");
A
Andreas Dilger 已提交
541
      if (green_y != NULL)
G
[devel]  
Glenn Randers-Pehrson 已提交
542
         *green_y = png_float(png_ptr, info_ptr->y_green, "cHRM green Y");
A
Andreas Dilger 已提交
543
      if (blue_x != NULL)
G
[devel]  
Glenn Randers-Pehrson 已提交
544
         *blue_x = png_float(png_ptr, info_ptr->x_blue, "cHRM blue X");
A
Andreas Dilger 已提交
545
      if (blue_y != NULL)
G
[devel]  
Glenn Randers-Pehrson 已提交
546
         *blue_y = png_float(png_ptr, info_ptr->y_blue, "cHRM blue Y");
A
Andreas Dilger 已提交
547 548
      return (PNG_INFO_cHRM);
   }
549

A
Andreas Dilger 已提交
550 551
   return (0);
}
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587

png_uint_32 PNGAPI
png_get_cHRM_XYZ(png_structp png_ptr, png_const_infop info_ptr,
   double *red_X, double *red_Y, double *red_Z, double *green_X,
   double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
   double *blue_Z)
{
   png_XYZ XYZ;

   if (png_get_cHRM_XYZ_fixed(png_ptr, info_ptr,
      &XYZ.redX, &XYZ.redY, &XYZ.redZ, &XYZ.greenX, &XYZ.greenY, &XYZ.greenZ,
      &XYZ.blueX, &XYZ.blueY, &XYZ.blueZ) & PNG_INFO_cHRM)
   {
      if (red_X != NULL)
         *red_X = png_float(png_ptr, XYZ.redX, "cHRM red X");
      if (red_Y != NULL)
         *red_Y = png_float(png_ptr, XYZ.redY, "cHRM red Y");
      if (red_Z != NULL)
         *red_Z = png_float(png_ptr, XYZ.redZ, "cHRM red Z");
      if (green_X != NULL)
         *green_X = png_float(png_ptr, XYZ.greenX, "cHRM green X");
      if (green_Y != NULL)
         *green_Y = png_float(png_ptr, XYZ.greenY, "cHRM green Y");
      if (green_Z != NULL)
         *green_Z = png_float(png_ptr, XYZ.greenZ, "cHRM green Z");
      if (blue_X != NULL)
         *blue_X = png_float(png_ptr, XYZ.blueX, "cHRM blue X");
      if (blue_Y != NULL)
         *blue_Y = png_float(png_ptr, XYZ.blueY, "cHRM blue Y");
      if (blue_Z != NULL)
         *blue_Z = png_float(png_ptr, XYZ.blueZ, "cHRM blue Z");
      return (PNG_INFO_cHRM);
   }

   return (0);
}
588
#  endif
G
[devel]  
Glenn Randers-Pehrson 已提交
589

590
#  ifdef PNG_FIXED_POINT_SUPPORTED
591
png_uint_32 PNGAPI
592
png_get_cHRM_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
593 594 595
    png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
    png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
    png_fixed_point *blue_x, png_fixed_point *blue_y)
596
{
597 598
   png_debug1(1, "in %s retrieval function", "cHRM");

599 600 601
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
   {
      if (white_x != NULL)
G
[devel]  
Glenn Randers-Pehrson 已提交
602
         *white_x = info_ptr->x_white;
603
      if (white_y != NULL)
G
[devel]  
Glenn Randers-Pehrson 已提交
604
         *white_y = info_ptr->y_white;
605
      if (red_x != NULL)
G
[devel]  
Glenn Randers-Pehrson 已提交
606
         *red_x = info_ptr->x_red;
607
      if (red_y != NULL)
G
[devel]  
Glenn Randers-Pehrson 已提交
608
         *red_y = info_ptr->y_red;
609
      if (green_x != NULL)
G
[devel]  
Glenn Randers-Pehrson 已提交
610
         *green_x = info_ptr->x_green;
611
      if (green_y != NULL)
G
[devel]  
Glenn Randers-Pehrson 已提交
612
         *green_y = info_ptr->y_green;
613
      if (blue_x != NULL)
G
[devel]  
Glenn Randers-Pehrson 已提交
614
         *blue_x = info_ptr->x_blue;
615
      if (blue_y != NULL)
G
[devel]  
Glenn Randers-Pehrson 已提交
616
         *blue_y = info_ptr->y_blue;
617 618
      return (PNG_INFO_cHRM);
   }
619

620 621
   return (0);
}
622
#  endif
623
#endif
A
Andreas Dilger 已提交
624

625
#ifdef PNG_gAMA_SUPPORTED
G
[devel]  
Glenn Randers-Pehrson 已提交
626
png_uint_32 PNGFAPI
627
png_get_gAMA_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
G
[devel]  
Glenn Randers-Pehrson 已提交
628
    png_fixed_point *file_gamma)
A
Andreas Dilger 已提交
629
{
630 631
   png_debug1(1, "in %s retrieval function", "gAMA");

632
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
633
       && file_gamma != NULL)
A
Andreas Dilger 已提交
634
   {
G
[devel]  
Glenn Randers-Pehrson 已提交
635
      *file_gamma = info_ptr->gamma;
A
Andreas Dilger 已提交
636 637
      return (PNG_INFO_gAMA);
   }
G
[devel]  
Glenn Randers-Pehrson 已提交
638

A
Andreas Dilger 已提交
639 640
   return (0);
}
641
#  ifdef PNG_FLOATING_POINT_SUPPORTED
642
png_uint_32 PNGAPI
643
png_get_gAMA(png_const_structp png_ptr, png_const_infop info_ptr,
644
    double *file_gamma)
645
{
G
[devel]  
Glenn Randers-Pehrson 已提交
646 647
   png_fixed_point igamma;
   png_uint_32 ok = png_get_gAMA_fixed(png_ptr, info_ptr, &igamma);
648

G
[devel]  
Glenn Randers-Pehrson 已提交
649 650
   if (ok)
      *file_gamma = png_float(png_ptr, igamma, "png_get_gAMA");
651

G
[devel]  
Glenn Randers-Pehrson 已提交
652
   return ok;
653
}
654 655

#  endif
656
#endif
A
Andreas Dilger 已提交
657

658
#ifdef PNG_sRGB_SUPPORTED
659
png_uint_32 PNGAPI
660
png_get_sRGB(png_const_structp png_ptr, png_const_infop info_ptr,
661
    int *file_srgb_intent)
662
{
663 664
   png_debug1(1, "in %s retrieval function", "sRGB");

665
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
666
       && file_srgb_intent != NULL)
667
   {
668
      *file_srgb_intent = (int)info_ptr->srgb_intent;
669 670
      return (PNG_INFO_sRGB);
   }
671

672 673 674 675
   return (0);
}
#endif

676
#ifdef PNG_iCCP_SUPPORTED
677
png_uint_32 PNGAPI
678
png_get_iCCP(png_const_structp png_ptr, png_const_infop info_ptr,
679
    png_charpp name, int *compression_type,
G
[devel]  
Glenn Randers-Pehrson 已提交
680
    png_bytepp profile, png_uint_32 *proflen)
681
{
682 683
   png_debug1(1, "in %s retrieval function", "iCCP");

684
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
685
       && name != NULL && profile != NULL && proflen != NULL)
686 687 688
   {
      *name = info_ptr->iccp_name;
      *profile = info_ptr->iccp_profile;
689 690 691
      /* Compression_type is a dummy so the API won't have to change
       * if we introduce multiple compression types later.
       */
692 693 694 695
      *proflen = (int)info_ptr->iccp_proflen;
      *compression_type = (int)info_ptr->iccp_compression;
      return (PNG_INFO_iCCP);
   }
696

697 698 699 700
   return (0);
}
#endif

701
#ifdef PNG_sPLT_SUPPORTED
702
png_uint_32 PNGAPI
703
png_get_sPLT(png_const_structp png_ptr, png_const_infop info_ptr,
704
    png_sPLT_tpp spalettes)
705 706
{
   if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
707
   {
708 709
      *spalettes = info_ptr->splt_palettes;
      return ((png_uint_32)info_ptr->splt_palettes_num);
710
   }
711

712
   return (0);
713 714 715
}
#endif

716
#ifdef PNG_hIST_SUPPORTED
717
png_uint_32 PNGAPI
718
png_get_hIST(png_const_structp png_ptr, png_const_infop info_ptr,
719
    png_uint_16p *hist)
A
Andreas Dilger 已提交
720
{
721 722
   png_debug1(1, "in %s retrieval function", "hIST");

723
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
724
       && hist != NULL)
A
Andreas Dilger 已提交
725 726 727 728
   {
      *hist = info_ptr->hist;
      return (PNG_INFO_hIST);
   }
729

A
Andreas Dilger 已提交
730 731 732 733
   return (0);
}
#endif

734
png_uint_32 PNGAPI
A
Andreas Dilger 已提交
735
png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
736 737 738
    png_uint_32 *width, png_uint_32 *height, int *bit_depth,
    int *color_type, int *interlace_type, int *compression_type,
    int *filter_type)
739

A
Andreas Dilger 已提交
740
{
741
   png_debug1(1, "in %s retrieval function", "IHDR");
742

743 744 745
   if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
       height == NULL || bit_depth == NULL || color_type == NULL)
      return (0);
746

747 748 749 750
   *width = info_ptr->width;
   *height = info_ptr->height;
   *bit_depth = info_ptr->bit_depth;
   *color_type = info_ptr->color_type;
751

752 753
   if (compression_type != NULL)
      *compression_type = info_ptr->compression_type;
754

755 756
   if (filter_type != NULL)
      *filter_type = info_ptr->filter_type;
757

758 759
   if (interlace_type != NULL)
      *interlace_type = info_ptr->interlace_type;
760

761 762 763 764 765 766 767 768
   /* This is redundant if we can be sure that the info_ptr values were all
    * assigned in png_set_IHDR().  We do the check anyhow in case an
    * application has ignored our advice not to mess with the members
    * of info_ptr directly.
    */
   png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height,
       info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
       info_ptr->compression_type, info_ptr->filter_type);
769

770
   return (1);
A
Andreas Dilger 已提交
771 772
}

773
#ifdef PNG_oFFs_SUPPORTED
774
png_uint_32 PNGAPI
775
png_get_oFFs(png_const_structp png_ptr, png_const_infop info_ptr,
776
    png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
A
Andreas Dilger 已提交
777
{
778 779
   png_debug1(1, "in %s retrieval function", "oFFs");

780
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
781
       && offset_x != NULL && offset_y != NULL && unit_type != NULL)
A
Andreas Dilger 已提交
782 783 784 785 786 787
   {
      *offset_x = info_ptr->x_offset;
      *offset_y = info_ptr->y_offset;
      *unit_type = (int)info_ptr->offset_unit_type;
      return (PNG_INFO_oFFs);
   }
788

A
Andreas Dilger 已提交
789 790 791 792
   return (0);
}
#endif

793
#ifdef PNG_pCAL_SUPPORTED
794
png_uint_32 PNGAPI
795
png_get_pCAL(png_const_structp png_ptr, png_const_infop info_ptr,
796 797
    png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
    png_charp *units, png_charpp *params)
A
Andreas Dilger 已提交
798
{
799 800
   png_debug1(1, "in %s retrieval function", "pCAL");

801
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
802 803
       && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
       nparams != NULL && units != NULL && params != NULL)
A
Andreas Dilger 已提交
804 805 806 807 808 809 810 811 812 813
   {
      *purpose = info_ptr->pcal_purpose;
      *X0 = info_ptr->pcal_X0;
      *X1 = info_ptr->pcal_X1;
      *type = (int)info_ptr->pcal_type;
      *nparams = (int)info_ptr->pcal_nparams;
      *units = info_ptr->pcal_units;
      *params = info_ptr->pcal_params;
      return (PNG_INFO_pCAL);
   }
814

A
Andreas Dilger 已提交
815 816 817 818
   return (0);
}
#endif

819
#ifdef PNG_sCAL_SUPPORTED
820 821
#  ifdef PNG_FIXED_POINT_SUPPORTED
#    ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
G
[devel]  
Glenn Randers-Pehrson 已提交
822
png_uint_32 PNGAPI
823
png_get_sCAL_fixed(png_structp png_ptr, png_const_infop info_ptr,
G
[devel]  
Glenn Randers-Pehrson 已提交
824 825 826 827 828 829
    int *unit, png_fixed_point *width, png_fixed_point *height)
{
   if (png_ptr != NULL && info_ptr != NULL &&
       (info_ptr->valid & PNG_INFO_sCAL))
   {
      *unit = info_ptr->scal_unit;
830
      /*TODO: make this work without FP support */
G
[devel]  
Glenn Randers-Pehrson 已提交
831 832 833 834 835 836 837 838
      *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width");
      *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
         "sCAL height");
      return (PNG_INFO_sCAL);
   }

   return(0);
}
839 840 841
#    endif /* FLOATING_ARITHMETIC */
#  endif /* FIXED_POINT */
#  ifdef PNG_FLOATING_POINT_SUPPORTED
842
png_uint_32 PNGAPI
843
png_get_sCAL(png_const_structp png_ptr, png_const_infop info_ptr,
844 845 846 847 848 849
    int *unit, double *width, double *height)
{
   if (png_ptr != NULL && info_ptr != NULL &&
       (info_ptr->valid & PNG_INFO_sCAL))
   {
      *unit = info_ptr->scal_unit;
G
[devel]  
Glenn Randers-Pehrson 已提交
850 851
      *width = atof(info_ptr->scal_s_width);
      *height = atof(info_ptr->scal_s_height);
852 853
      return (PNG_INFO_sCAL);
   }
854

855
   return(0);
856
}
857
#  endif /* FLOATING POINT */
858
png_uint_32 PNGAPI
859
png_get_sCAL_s(png_const_structp png_ptr, png_const_infop info_ptr,
860
    int *unit, png_charpp width, png_charpp height)
861
{
862 863 864 865 866 867 868 869
   if (png_ptr != NULL && info_ptr != NULL &&
       (info_ptr->valid & PNG_INFO_sCAL))
   {
      *unit = info_ptr->scal_unit;
      *width = info_ptr->scal_s_width;
      *height = info_ptr->scal_s_height;
      return (PNG_INFO_sCAL);
   }
870

871
   return(0);
872
}
873
#endif /* sCAL */
874

875
#ifdef PNG_pHYs_SUPPORTED
876
png_uint_32 PNGAPI
877
png_get_pHYs(png_const_structp png_ptr, png_const_infop info_ptr,
878
    png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
A
Andreas Dilger 已提交
879
{
880 881
   png_uint_32 retval = 0;

882 883
   png_debug1(1, "in %s retrieval function", "pHYs");

884
   if (png_ptr != NULL && info_ptr != NULL &&
885
       (info_ptr->valid & PNG_INFO_pHYs))
A
Andreas Dilger 已提交
886
   {
887
      if (res_x != NULL)
888 889
      {
         *res_x = info_ptr->x_pixels_per_unit;
890 891
         retval |= PNG_INFO_pHYs;
      }
892

893 894
      if (res_y != NULL)
      {
895 896 897
         *res_y = info_ptr->y_pixels_per_unit;
         retval |= PNG_INFO_pHYs;
      }
898

899 900 901 902 903
      if (unit_type != NULL)
      {
         *unit_type = (int)info_ptr->phys_unit_type;
         retval |= PNG_INFO_pHYs;
      }
A
Andreas Dilger 已提交
904
   }
905

906
   return (retval);
A
Andreas Dilger 已提交
907
}
908
#endif /* pHYs */
A
Andreas Dilger 已提交
909

910
png_uint_32 PNGAPI
911
png_get_PLTE(png_const_structp png_ptr, png_const_infop info_ptr,
912
    png_colorp *palette, int *num_palette)
A
Andreas Dilger 已提交
913
{
914 915
   png_debug1(1, "in %s retrieval function", "PLTE");

916 917
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
       && palette != NULL)
A
Andreas Dilger 已提交
918 919 920
   {
      *palette = info_ptr->palette;
      *num_palette = info_ptr->num_palette;
921
      png_debug1(3, "num_palette = %d", *num_palette);
A
Andreas Dilger 已提交
922 923
      return (PNG_INFO_PLTE);
   }
924

A
Andreas Dilger 已提交
925 926 927
   return (0);
}

928
#ifdef PNG_sBIT_SUPPORTED
929
png_uint_32 PNGAPI
930
png_get_sBIT(png_const_structp png_ptr, png_infop info_ptr,
931
    png_color_8p *sig_bit)
A
Andreas Dilger 已提交
932
{
933 934
   png_debug1(1, "in %s retrieval function", "sBIT");

935
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
936
       && sig_bit != NULL)
A
Andreas Dilger 已提交
937 938 939 940
   {
      *sig_bit = &(info_ptr->sig_bit);
      return (PNG_INFO_sBIT);
   }
941

A
Andreas Dilger 已提交
942 943 944 945
   return (0);
}
#endif

946
#ifdef PNG_TEXT_SUPPORTED
947
png_uint_32 PNGAPI
948
png_get_text(png_const_structp png_ptr, png_const_infop info_ptr,
949
    png_textp *text_ptr, int *num_text)
A
Andreas Dilger 已提交
950
{
951
   if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
A
Andreas Dilger 已提交
952
   {
953
      png_debug1(1, "in %s retrieval function",
954 955
          (png_ptr->chunk_name[0] == '\0' ? "text" :
          (png_const_charp)png_ptr->chunk_name));
956

A
Andreas Dilger 已提交
957 958
      if (text_ptr != NULL)
         *text_ptr = info_ptr->text;
959

A
Andreas Dilger 已提交
960 961
      if (num_text != NULL)
         *num_text = info_ptr->num_text;
962

963
      return ((png_uint_32)info_ptr->num_text);
A
Andreas Dilger 已提交
964
   }
965

966
   if (num_text != NULL)
967
      *num_text = 0;
968

A
Andreas Dilger 已提交
969 970 971 972
   return(0);
}
#endif

973
#ifdef PNG_tIME_SUPPORTED
974
png_uint_32 PNGAPI
975
png_get_tIME(png_const_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
A
Andreas Dilger 已提交
976
{
977 978
   png_debug1(1, "in %s retrieval function", "tIME");

979 980
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
       && mod_time != NULL)
A
Andreas Dilger 已提交
981 982 983 984
   {
      *mod_time = &(info_ptr->mod_time);
      return (PNG_INFO_tIME);
   }
985

A
Andreas Dilger 已提交
986 987 988 989
   return (0);
}
#endif

990
#ifdef PNG_tRNS_SUPPORTED
991
png_uint_32 PNGAPI
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)
A
Andreas Dilger 已提交
994
{
995
   png_uint_32 retval = 0;
996
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
A
Andreas Dilger 已提交
997
   {
998
      png_debug1(1, "in %s retrieval function", "tRNS");
999

1000
      if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
A
Andreas Dilger 已提交
1001
      {
1002 1003 1004 1005 1006 1007 1008 1009
         if (trans_alpha != NULL)
         {
            *trans_alpha = info_ptr->trans_alpha;
            retval |= PNG_INFO_tRNS;
         }

         if (trans_color != NULL)
            *trans_color = &(info_ptr->trans_color);
A
Andreas Dilger 已提交
1010
      }
1011

1012
      else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
A
Andreas Dilger 已提交
1013
      {
1014 1015 1016 1017 1018 1019 1020 1021
         if (trans_color != NULL)
         {
            *trans_color = &(info_ptr->trans_color);
            retval |= PNG_INFO_tRNS;
         }

         if (trans_alpha != NULL)
            *trans_alpha = NULL;
A
Andreas Dilger 已提交
1022
      }
1023

1024
      if (num_trans != NULL)
A
Andreas Dilger 已提交
1025
      {
1026 1027
         *num_trans = info_ptr->num_trans;
         retval |= PNG_INFO_tRNS;
A
Andreas Dilger 已提交
1028 1029
      }
   }
1030

1031
   return (retval);
A
Andreas Dilger 已提交
1032 1033 1034
}
#endif

1035
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
1036
int PNGAPI
1037
png_get_unknown_chunks(png_const_structp png_ptr, png_const_infop info_ptr,
1038
    png_unknown_chunkpp unknowns)
1039 1040
{
   if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
1041
   {
1042
      *unknowns = info_ptr->unknown_chunks;
1043
      return info_ptr->unknown_chunks_num;
1044
   }
1045

1046
   return (0);
1047 1048 1049
}
#endif

1050
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
1051
png_byte PNGAPI
1052
png_get_rgb_to_gray_status (png_const_structp png_ptr)
1053
{
1054
   return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
1055 1056
}
#endif
1057

1058
#ifdef PNG_USER_CHUNKS_SUPPORTED
1059
png_voidp PNGAPI
1060
png_get_user_chunk_ptr(png_const_structp png_ptr)
1061
{
1062
   return (png_ptr ? png_ptr->user_chunk_ptr : NULL);
1063 1064 1065
}
#endif

1066
png_size_t PNGAPI
1067
png_get_compression_buffer_size(png_const_structp png_ptr)
1068
{
1069
   return (png_ptr ? png_ptr->zbuf_size : 0);
1070 1071
}

1072 1073

#ifdef PNG_SET_USER_LIMITS_SUPPORTED
1074 1075
/* These functions were added to libpng 1.2.6 and were enabled
 * by default in libpng-1.4.0 */
1076
png_uint_32 PNGAPI
1077
png_get_user_width_max (png_const_structp png_ptr)
1078
{
1079
   return (png_ptr ? png_ptr->user_width_max : 0);
1080
}
1081

1082
png_uint_32 PNGAPI
1083
png_get_user_height_max (png_const_structp png_ptr)
1084
{
1085
   return (png_ptr ? png_ptr->user_height_max : 0);
1086
}
1087

1088
/* This function was added to libpng 1.4.0 */
1089
png_uint_32 PNGAPI
1090
png_get_chunk_cache_max (png_const_structp png_ptr)
1091
{
1092
   return (png_ptr ? png_ptr->user_chunk_cache_max : 0);
1093
}
1094

1095
/* This function was added to libpng 1.4.1 */
1096
png_alloc_size_t PNGAPI
1097
png_get_chunk_malloc_max (png_const_structp png_ptr)
1098
{
1099
   return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
1100
}
1101
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
1102

1103
/* These functions were added to libpng 1.4.0 */
1104 1105 1106 1107
#ifdef PNG_IO_STATE_SUPPORTED
png_uint_32 PNGAPI
png_get_io_state (png_structp png_ptr)
{
1108
   return png_ptr->io_state;
1109 1110
}

1111
png_uint_32 PNGAPI
1112
png_get_io_chunk_type (png_const_structp png_ptr)
1113 1114 1115 1116 1117 1118 1119
{
   return ((png_ptr->chunk_name[0] << 24) +
           (png_ptr->chunk_name[1] << 16) +
           (png_ptr->chunk_name[2] <<  8) +
           (png_ptr->chunk_name[3]));
}

1120
png_const_bytep PNGAPI
1121 1122 1123 1124 1125 1126
png_get_io_chunk_name (png_structp png_ptr)
{
   return png_ptr->chunk_name;
}
#endif /* ?PNG_IO_STATE_SUPPORTED */

1127
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */