Subversion Repositories Kolibri OS

Rev

Rev 1897 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1897 Rev 3928
Line 1... Line 1...
1
/* pngget.c - retrieval of values from info struct
1
/* pngget.c - retrieval of values from info struct
2
 *
2
 *
3
 * Last changed in libpng 1.5.1 [February 3, 2011]
3
 * Last changed in libpng 1.6.1 [March 28, 2013]
4
 * Copyright (c) 1998-2011 Glenn Randers-Pehrson
4
 * Copyright (c) 1998-2013 Glenn Randers-Pehrson
5
 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
5
 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
6
 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
6
 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
7
 *
7
 *
8
 * This code is released under the libpng license.
8
 * This code is released under the libpng license.
9
 * For conditions of distribution and use, see the disclaimer
9
 * For conditions of distribution and use, see the disclaimer
Line 15... Line 15...
15
 
15
 
Line 16... Line 16...
16
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
16
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
Line 17... Line 17...
17
 
17
 
18
png_uint_32 PNGAPI
18
png_uint_32 PNGAPI
19
png_get_valid(png_const_structp png_ptr, png_const_infop info_ptr,
19
png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr,
20
    png_uint_32 flag)
20
    png_uint_32 flag)
21
{
21
{
22
   if (png_ptr != NULL && info_ptr != NULL)
22
   if (png_ptr != NULL && info_ptr != NULL)
Line 23... Line 23...
23
      return(info_ptr->valid & flag);
23
      return(info_ptr->valid & flag);
24
 
24
 
Line 25... Line 25...
25
   return(0);
25
   return(0);
26
}
26
}
27
 
27
 
28
png_size_t PNGAPI
28
png_size_t PNGAPI
29
png_get_rowbytes(png_const_structp png_ptr, png_const_infop info_ptr)
29
png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr)
Line 30... Line 30...
30
{
30
{
31
   if (png_ptr != NULL && info_ptr != NULL)
31
   if (png_ptr != NULL && info_ptr != NULL)
Line 32... Line 32...
32
      return(info_ptr->rowbytes);
32
      return(info_ptr->rowbytes);
33
 
33
 
34
   return(0);
34
   return(0);
35
}
35
}
36
 
36
 
37
#ifdef PNG_INFO_IMAGE_SUPPORTED
37
#ifdef PNG_INFO_IMAGE_SUPPORTED
Line 38... Line 38...
38
png_bytepp PNGAPI
38
png_bytepp PNGAPI
Line 47... Line 47...
47
 
47
 
Line 48... Line 48...
48
#ifdef PNG_EASY_ACCESS_SUPPORTED
48
#ifdef PNG_EASY_ACCESS_SUPPORTED
49
/* Easy access to info, added in libpng-0.99 */
49
/* Easy access to info, added in libpng-0.99 */
50
png_uint_32 PNGAPI
50
png_uint_32 PNGAPI
51
png_get_image_width(png_const_structp png_ptr, png_const_infop info_ptr)
51
png_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr)
52
{
52
{
53
   if (png_ptr != NULL && info_ptr != NULL)
53
   if (png_ptr != NULL && info_ptr != NULL)
54
      return info_ptr->width;
54
      return info_ptr->width;
Line 55... Line 55...
55
 
55
 
56
   return (0);
56
   return (0);
Line 57... Line 57...
57
}
57
}
58
 
58
 
59
png_uint_32 PNGAPI
59
png_uint_32 PNGAPI
60
png_get_image_height(png_const_structp png_ptr, png_const_infop info_ptr)
60
png_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr)
61
{
61
{
Line 62... Line 62...
62
   if (png_ptr != NULL && info_ptr != NULL)
62
   if (png_ptr != NULL && info_ptr != NULL)
63
      return info_ptr->height;
63
      return info_ptr->height;
Line 64... Line 64...
64
 
64
 
65
   return (0);
65
   return (0);
66
}
66
}
67
 
67
 
68
png_byte PNGAPI
68
png_byte PNGAPI
Line 69... Line 69...
69
png_get_bit_depth(png_const_structp png_ptr, png_const_infop info_ptr)
69
png_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr)
70
{
70
{
Line 71... Line 71...
71
   if (png_ptr != NULL && info_ptr != NULL)
71
   if (png_ptr != NULL && info_ptr != NULL)
72
      return info_ptr->bit_depth;
72
      return info_ptr->bit_depth;
73
 
73
 
74
   return (0);
74
   return (0);
75
}
75
}
Line 76... Line 76...
76
 
76
 
77
png_byte PNGAPI
77
png_byte PNGAPI
Line 78... Line 78...
78
png_get_color_type(png_const_structp png_ptr, png_const_infop info_ptr)
78
png_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
79
{
79
{
80
   if (png_ptr != NULL && info_ptr != NULL)
80
   if (png_ptr != NULL && info_ptr != NULL)
81
      return info_ptr->color_type;
81
      return info_ptr->color_type;
82
 
82
 
Line 83... Line 83...
83
   return (0);
83
   return (0);
84
}
84
}
Line 85... Line 85...
85
 
85
 
86
png_byte PNGAPI
86
png_byte PNGAPI
87
png_get_filter_type(png_const_structp png_ptr, png_const_infop info_ptr)
87
png_get_filter_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
88
{
88
{
89
   if (png_ptr != NULL && info_ptr != NULL)
89
   if (png_ptr != NULL && info_ptr != NULL)
Line 90... Line 90...
90
      return info_ptr->filter_type;
90
      return info_ptr->filter_type;
91
 
91
 
Line 92... Line 92...
92
   return (0);
92
   return (0);
93
}
93
}
94
 
94
 
95
png_byte PNGAPI
95
png_byte PNGAPI
96
png_get_interlace_type(png_const_structp png_ptr, png_const_infop info_ptr)
96
png_get_interlace_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
Line 97... Line 97...
97
{
97
{
98
   if (png_ptr != NULL && info_ptr != NULL)
98
   if (png_ptr != NULL && info_ptr != NULL)
Line 99... Line 99...
99
      return info_ptr->interlace_type;
99
      return info_ptr->interlace_type;
100
 
100
 
-
 
101
   return (0);
101
   return (0);
102
}
102
}
103
 
103
 
104
png_byte PNGAPI
104
png_byte PNGAPI
105
png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
105
png_get_compression_type(png_const_structp png_ptr, png_const_infop info_ptr)
106
{
Line 127... Line 128...
127
   return (0);
128
   return (0);
128
}
129
}
Line 129... Line 130...
129
 
130
 
130
png_uint_32 PNGAPI
131
png_uint_32 PNGAPI
-
 
132
png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
131
png_get_y_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
133
    info_ptr)
132
{
134
{
133
#ifdef PNG_pHYs_SUPPORTED
135
#ifdef PNG_pHYs_SUPPORTED
134
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
136
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
135
   {
137
   {
Line 144... Line 146...
144
   return (0);
146
   return (0);
145
}
147
}
Line 146... Line 148...
146
 
148
 
147
png_uint_32 PNGAPI
149
png_uint_32 PNGAPI
148
png_get_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
150
png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
149
{
151
{
150
#ifdef PNG_pHYs_SUPPORTED
152
#ifdef PNG_pHYs_SUPPORTED
151
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
153
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
152
   {
154
   {
Line 162... Line 164...
162
}
164
}
163
 
165
 
Line 164... Line 166...
164
#ifdef PNG_FLOATING_POINT_SUPPORTED
166
#ifdef PNG_FLOATING_POINT_SUPPORTED
165
float PNGAPI
167
float PNGAPI
166
png_get_pixel_aspect_ratio(png_const_structp png_ptr, png_const_infop info_ptr)
168
png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp
-
 
169
   info_ptr)
167
{
170
{
168
#ifdef PNG_READ_pHYs_SUPPORTED
171
#ifdef PNG_READ_pHYs_SUPPORTED
169
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
172
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
170
   {
173
   {
171
      png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
174
      png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
Line 172... Line 175...
172
 
175
 
173
      if (info_ptr->x_pixels_per_unit != 0)
176
      if (info_ptr->x_pixels_per_unit != 0)
174
         return ((float)((float)info_ptr->y_pixels_per_unit
177
         return ((float)((float)info_ptr->y_pixels_per_unit
175
             /(float)info_ptr->x_pixels_per_unit));
178
             /(float)info_ptr->x_pixels_per_unit));
-
 
179
   }
-
 
180
#else
-
 
181
   PNG_UNUSED(png_ptr)
176
   }
182
   PNG_UNUSED(info_ptr)
Line 177... Line 183...
177
#endif
183
#endif
178
 
184
 
179
   return ((float)0.0);
185
   return ((float)0.0);
Line 180... Line 186...
180
}
186
}
181
#endif
187
#endif
182
 
188
 
183
#ifdef PNG_FIXED_POINT_SUPPORTED
189
#ifdef PNG_FIXED_POINT_SUPPORTED
184
png_fixed_point PNGAPI
190
png_fixed_point PNGAPI
185
png_get_pixel_aspect_ratio_fixed(png_const_structp png_ptr,
191
png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
186
    png_const_infop info_ptr)
192
    png_const_inforp info_ptr)
187
{
193
{
188
#ifdef PNG_READ_pHYs_SUPPORTED
194
#ifdef PNG_READ_pHYs_SUPPORTED
Line 201... Line 207...
201
      if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1,
207
      if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1,
202
          (png_int_32)info_ptr->x_pixels_per_unit))
208
          (png_int_32)info_ptr->x_pixels_per_unit))
203
         return res;
209
         return res;
204
   }
210
   }
205
#endif
211
#else
-
 
212
   PNG_UNUSED(png_ptr)
-
 
213
   PNG_UNUSED(info_ptr)
-
 
214
#endif
206
 
215
 
Line 207... Line 216...
207
   return 0;
216
   return 0;
208
}
217
}
209
#endif
218
#endif
Line 210... Line 219...
210
 
219
 
211
png_int_32 PNGAPI
220
png_int_32 PNGAPI
212
png_get_x_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
221
png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
213
{
222
{
214
#ifdef PNG_oFFs_SUPPORTED
223
#ifdef PNG_oFFs_SUPPORTED
215
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
224
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
216
   {
225
   {
Line 224... Line 233...
224
   return (0);
233
   return (0);
225
}
234
}
Line 226... Line 235...
226
 
235
 
227
png_int_32 PNGAPI
236
png_int_32 PNGAPI
228
png_get_y_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
237
png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
229
{
238
{
230
#ifdef PNG_oFFs_SUPPORTED
239
#ifdef PNG_oFFs_SUPPORTED
231
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
240
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
232
   {
241
   {
Line 240... Line 249...
240
   return (0);
249
   return (0);
241
}
250
}
Line 242... Line 251...
242
 
251
 
243
png_int_32 PNGAPI
252
png_int_32 PNGAPI
244
png_get_x_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)
253
png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
245
{
254
{
246
#ifdef PNG_oFFs_SUPPORTED
255
#ifdef PNG_oFFs_SUPPORTED
247
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
256
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
248
   {
257
   {
Line 256... Line 265...
256
   return (0);
265
   return (0);
257
}
266
}
Line 258... Line 267...
258
 
267
 
259
png_int_32 PNGAPI
268
png_int_32 PNGAPI
260
png_get_y_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)
269
png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
261
{
270
{
262
#ifdef PNG_oFFs_SUPPORTED
271
#ifdef PNG_oFFs_SUPPORTED
263
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
272
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
264
   {
273
   {
Line 305... Line 314...
305
#endif
314
#endif
306
}
315
}
307
 
316
 
Line 308... Line 317...
308
png_uint_32 PNGAPI
317
png_uint_32 PNGAPI
309
png_get_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
318
png_get_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
310
{
319
{
311
   return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr));
320
   return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr));
312
}
321
}
Line 313... Line 322...
313
 
322
 
314
png_uint_32 PNGAPI
323
png_uint_32 PNGAPI
315
png_get_x_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
324
png_get_x_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
316
{
325
{
317
   return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr));
326
   return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr));
Line 318... Line 327...
318
}
327
}
319
 
328
 
320
png_uint_32 PNGAPI
329
png_uint_32 PNGAPI
321
png_get_y_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
330
png_get_y_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
322
{
331
{
Line 323... Line 332...
323
   return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr));
332
   return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr));
324
}
333
}
325
 
334
 
326
#ifdef PNG_FIXED_POINT_SUPPORTED
335
#ifdef PNG_FIXED_POINT_SUPPORTED
327
static png_fixed_point
336
static png_fixed_point
328
png_fixed_inches_from_microns(png_structp png_ptr, png_int_32 microns)
337
png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns)
329
{
338
{
330
   /* Convert from metres * 1,000,000 to inches * 100,000, meters to
339
   /* Convert from metres * 1,000,000 to inches * 100,000, meters to
331
    * inches is simply *(100/2.54), so we want *(10/2.54) == 500/127.
340
    * inches is simply *(100/2.54), so we want *(10/2.54) == 500/127.
332
    * Notice that this can overflow - a warning is output and 0 is
341
    * Notice that this can overflow - a warning is output and 0 is
333
    * returned.
342
    * returned.
Line 334... Line 343...
334
    */
343
    */
335
   return png_muldiv_warn(png_ptr, microns, 500, 127);
344
   return png_muldiv_warn(png_ptr, microns, 500, 127);
336
}
345
}
337
 
346
 
338
png_fixed_point PNGAPI
347
png_fixed_point PNGAPI
339
png_get_x_offset_inches_fixed(png_structp png_ptr,
348
png_get_x_offset_inches_fixed(png_const_structrp png_ptr,
340
    png_const_infop info_ptr)
349
    png_const_inforp info_ptr)
341
{
350
{
Line 342... Line 351...
342
   return png_fixed_inches_from_microns(png_ptr,
351
   return png_fixed_inches_from_microns(png_ptr,
343
       png_get_x_offset_microns(png_ptr, info_ptr));
352
       png_get_x_offset_microns(png_ptr, info_ptr));
344
}
353
}
345
#endif
354
#endif
346
 
355
 
347
#ifdef PNG_FIXED_POINT_SUPPORTED
356
#ifdef PNG_FIXED_POINT_SUPPORTED
348
png_fixed_point PNGAPI
357
png_fixed_point PNGAPI
349
png_get_y_offset_inches_fixed(png_structp png_ptr,
358
png_get_y_offset_inches_fixed(png_const_structrp png_ptr,
350
    png_const_infop info_ptr)
359
    png_const_inforp info_ptr)
Line 351... Line 360...
351
{
360
{
352
   return png_fixed_inches_from_microns(png_ptr,
361
   return png_fixed_inches_from_microns(png_ptr,
353
       png_get_y_offset_microns(png_ptr, info_ptr));
362
       png_get_y_offset_microns(png_ptr, info_ptr));
354
}
363
}
355
#endif
364
#endif
356
 
365
 
357
#ifdef PNG_FLOATING_POINT_SUPPORTED
366
#ifdef PNG_FLOATING_POINT_SUPPORTED
358
float PNGAPI
367
float PNGAPI
359
png_get_x_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
368
png_get_x_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)
360
{
369
{
Line 361... Line 370...
361
   /* To avoid the overflow do the conversion directly in floating
370
   /* To avoid the overflow do the conversion directly in floating
362
    * point.
371
    * point.
363
    */
372
    */
364
   return (float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937);
373
   return (float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937);
365
}
374
}
366
#endif
375
#endif
367
 
376
 
368
#ifdef PNG_FLOATING_POINT_SUPPORTED
377
#ifdef PNG_FLOATING_POINT_SUPPORTED
369
float PNGAPI
378
float PNGAPI
370
png_get_y_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
379
png_get_y_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)
Line 371... Line 380...
371
{
380
{
372
   /* To avoid the overflow do the conversion directly in floating
381
   /* To avoid the overflow do the conversion directly in floating
373
    * point.
382
    * point.
374
    */
383
    */
375
   return (float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937);
384
   return (float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937);
376
}
385
}
Line 377... Line 386...
377
#endif
386
#endif
Line 420... Line 429...
420
/* png_get_channels really belongs in here, too, but it's been around longer */
429
/* png_get_channels really belongs in here, too, but it's been around longer */
Line 421... Line 430...
421
 
430
 
Line -... Line 431...
-
 
431
#endif  /* PNG_EASY_ACCESS_SUPPORTED */
422
#endif  /* PNG_EASY_ACCESS_SUPPORTED */
432
 
423
 
433
 
424
png_byte PNGAPI
434
png_byte PNGAPI
425
png_get_channels(png_const_structp png_ptr, png_const_infop info_ptr)
435
png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr)
426
{
436
{
Line 427... Line 437...
427
   if (png_ptr != NULL && info_ptr != NULL)
437
   if (png_ptr != NULL && info_ptr != NULL)
428
      return(info_ptr->channels);
438
      return(info_ptr->channels);
Line -... Line 439...
-
 
439
 
429
 
440
   return (0);
430
   return (0);
441
}
431
}
442
 
432
 
443
#ifdef PNG_READ_SUPPORTED
433
png_const_bytep PNGAPI
444
png_const_bytep PNGAPI
Line 434... Line 445...
434
png_get_signature(png_const_structp png_ptr, png_infop info_ptr)
445
png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr)
435
{
446
{
-
 
447
   if (png_ptr != NULL && info_ptr != NULL)
Line 436... Line 448...
436
   if (png_ptr != NULL && info_ptr != NULL)
448
      return(info_ptr->signature);
437
      return(info_ptr->signature);
449
 
438
 
450
   return (NULL);
439
   return (NULL);
451
}
440
}
452
#endif
441
 
453
 
442
#ifdef PNG_bKGD_SUPPORTED
454
#ifdef PNG_bKGD_SUPPORTED
443
png_uint_32 PNGAPI
455
png_uint_32 PNGAPI
Line 457... Line 469...
457
}
469
}
458
#endif
470
#endif
459
 
471
 
Line 460... Line 472...
460
#ifdef PNG_cHRM_SUPPORTED
472
#ifdef PNG_cHRM_SUPPORTED
-
 
473
/* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the
-
 
474
 * same time to correct the rgb grayscale coefficient defaults obtained from the
-
 
475
 * cHRM chunk in 1.5.4
-
 
476
 */
461
#  ifdef PNG_FLOATING_POINT_SUPPORTED
477
#  ifdef PNG_FLOATING_POINT_SUPPORTED
462
png_uint_32 PNGAPI
478
png_uint_32 PNGAPI
463
png_get_cHRM(png_const_structp png_ptr, png_const_infop info_ptr,
479
png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
464
    double *white_x, double *white_y, double *red_x, double *red_y,
480
    double *white_x, double *white_y, double *red_x, double *red_y,
465
    double *green_x, double *green_y, double *blue_x, double *blue_y)
481
    double *green_x, double *green_y, double *blue_x, double *blue_y)
466
{
482
{
-
 
483
   /* Quiet API change: this code used to only return the end points if a cHRM
-
 
484
    * chunk was present, but the end points can also come from iCCP or sRGB
-
 
485
    * chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and
-
 
486
    * the png_set_ APIs merely check that set end points are mutually
-
 
487
    * consistent.
-
 
488
    */
467
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
489
   if (png_ptr != NULL && info_ptr != NULL &&
-
 
490
      (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
468
   {
491
   {
469
      png_debug1(1, "in %s retrieval function", "cHRM");
492
      png_debug1(1, "in %s retrieval function", "cHRM");
Line 470... Line 493...
470
 
493
 
-
 
494
      if (white_x != NULL)
471
      if (white_x != NULL)
495
         *white_x = png_float(png_ptr,
472
         *white_x = png_float(png_ptr, info_ptr->x_white, "cHRM white X");
496
            info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
-
 
497
      if (white_y != NULL)
473
      if (white_y != NULL)
498
         *white_y = png_float(png_ptr,
474
         *white_y = png_float(png_ptr, info_ptr->y_white, "cHRM white Y");
499
            info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y");
475
      if (red_x != NULL)
500
      if (red_x != NULL)
-
 
501
         *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx,
476
         *red_x = png_float(png_ptr, info_ptr->x_red, "cHRM red X");
502
            "cHRM red X");
477
      if (red_y != NULL)
503
      if (red_y != NULL)
-
 
504
         *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy,
478
         *red_y = png_float(png_ptr, info_ptr->y_red, "cHRM red Y");
505
            "cHRM red Y");
-
 
506
      if (green_x != NULL)
479
      if (green_x != NULL)
507
         *green_x = png_float(png_ptr,
480
         *green_x = png_float(png_ptr, info_ptr->x_green, "cHRM green X");
508
            info_ptr->colorspace.end_points_xy.greenx, "cHRM green X");
-
 
509
      if (green_y != NULL)
481
      if (green_y != NULL)
510
         *green_y = png_float(png_ptr,
482
         *green_y = png_float(png_ptr, info_ptr->y_green, "cHRM green Y");
511
            info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y");
483
      if (blue_x != NULL)
512
      if (blue_x != NULL)
-
 
513
         *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex,
484
         *blue_x = png_float(png_ptr, info_ptr->x_blue, "cHRM blue X");
514
            "cHRM blue X");
485
      if (blue_y != NULL)
515
      if (blue_y != NULL)
-
 
516
         *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,
-
 
517
            "cHRM blue Y");
-
 
518
      return (PNG_INFO_cHRM);
-
 
519
   }
-
 
520
 
-
 
521
   return (0);
-
 
522
}
-
 
523
 
-
 
524
png_uint_32 PNGAPI
-
 
525
png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
-
 
526
   double *red_X, double *red_Y, double *red_Z, double *green_X,
-
 
527
   double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
-
 
528
   double *blue_Z)
-
 
529
{
-
 
530
   if (png_ptr != NULL && info_ptr != NULL &&
-
 
531
      (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
-
 
532
   {
-
 
533
      png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
-
 
534
 
-
 
535
      if (red_X != NULL)
-
 
536
         *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X,
-
 
537
            "cHRM red X");
-
 
538
      if (red_Y != NULL)
-
 
539
         *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y,
-
 
540
            "cHRM red Y");
-
 
541
      if (red_Z != NULL)
-
 
542
         *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z,
-
 
543
            "cHRM red Z");
-
 
544
      if (green_X != NULL)
-
 
545
         *green_X = png_float(png_ptr,
-
 
546
            info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X");
-
 
547
      if (green_Y != NULL)
-
 
548
         *green_Y = png_float(png_ptr,
-
 
549
            info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y");
-
 
550
      if (green_Z != NULL)
-
 
551
         *green_Z = png_float(png_ptr,
-
 
552
            info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z");
-
 
553
      if (blue_X != NULL)
-
 
554
         *blue_X = png_float(png_ptr,
-
 
555
            info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X");
-
 
556
      if (blue_Y != NULL)
-
 
557
         *blue_Y = png_float(png_ptr,
-
 
558
            info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y");
-
 
559
      if (blue_Z != NULL)
-
 
560
         *blue_Z = png_float(png_ptr,
486
         *blue_y = png_float(png_ptr, info_ptr->y_blue, "cHRM blue Y");
561
            info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
487
      return (PNG_INFO_cHRM);
562
      return (PNG_INFO_cHRM);
Line 488... Line 563...
488
   }
563
   }
489
 
564
 
490
   return (0);
565
   return (0);
Line 491... Line 566...
491
}
566
}
492
#  endif
567
#  endif
-
 
568
 
-
 
569
#  ifdef PNG_FIXED_POINT_SUPPORTED
-
 
570
png_uint_32 PNGAPI
-
 
571
png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
-
 
572
    png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
-
 
573
    png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
-
 
574
    png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
-
 
575
    png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
-
 
576
    png_fixed_point *int_blue_Z)
-
 
577
{
-
 
578
   if (png_ptr != NULL && info_ptr != NULL &&
-
 
579
      (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
-
 
580
   {
-
 
581
      png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
-
 
582
 
-
 
583
      if (int_red_X != NULL)
-
 
584
         *int_red_X = info_ptr->colorspace.end_points_XYZ.red_X;
-
 
585
      if (int_red_Y != NULL)
-
 
586
         *int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y;
-
 
587
      if (int_red_Z != NULL)
-
 
588
         *int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z;
-
 
589
      if (int_green_X != NULL)
-
 
590
         *int_green_X = info_ptr->colorspace.end_points_XYZ.green_X;
-
 
591
      if (int_green_Y != NULL)
-
 
592
         *int_green_Y = info_ptr->colorspace.end_points_XYZ.green_Y;
-
 
593
      if (int_green_Z != NULL)
-
 
594
         *int_green_Z = info_ptr->colorspace.end_points_XYZ.green_Z;
-
 
595
      if (int_blue_X != NULL)
-
 
596
         *int_blue_X = info_ptr->colorspace.end_points_XYZ.blue_X;
-
 
597
      if (int_blue_Y != NULL)
-
 
598
         *int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y;
-
 
599
      if (int_blue_Z != NULL)
-
 
600
         *int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z;
-
 
601
      return (PNG_INFO_cHRM);
-
 
602
   }
-
 
603
 
-
 
604
   return (0);
493
 
605
}
494
#  ifdef PNG_FIXED_POINT_SUPPORTED
606
 
495
png_uint_32 PNGAPI
607
png_uint_32 PNGAPI
496
png_get_cHRM_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
608
png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
497
    png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
609
    png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
498
    png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
610
    png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
Line 499... Line 611...
499
    png_fixed_point *blue_x, png_fixed_point *blue_y)
611
    png_fixed_point *blue_x, png_fixed_point *blue_y)
-
 
612
{
500
{
613
   png_debug1(1, "in %s retrieval function", "cHRM");
501
   png_debug1(1, "in %s retrieval function", "cHRM");
614
 
502
 
615
   if (png_ptr != NULL && info_ptr != NULL &&
503
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
616
      (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
504
   {
617
   {
505
      if (white_x != NULL)
618
      if (white_x != NULL)
506
         *white_x = info_ptr->x_white;
619
         *white_x = info_ptr->colorspace.end_points_xy.whitex;
507
      if (white_y != NULL)
620
      if (white_y != NULL)
508
         *white_y = info_ptr->y_white;
621
         *white_y = info_ptr->colorspace.end_points_xy.whitey;
509
      if (red_x != NULL)
622
      if (red_x != NULL)
510
         *red_x = info_ptr->x_red;
623
         *red_x = info_ptr->colorspace.end_points_xy.redx;
511
      if (red_y != NULL)
624
      if (red_y != NULL)
512
         *red_y = info_ptr->y_red;
625
         *red_y = info_ptr->colorspace.end_points_xy.redy;
513
      if (green_x != NULL)
626
      if (green_x != NULL)
514
         *green_x = info_ptr->x_green;
627
         *green_x = info_ptr->colorspace.end_points_xy.greenx;
515
      if (green_y != NULL)
628
      if (green_y != NULL)
516
         *green_y = info_ptr->y_green;
629
         *green_y = info_ptr->colorspace.end_points_xy.greeny;
517
      if (blue_x != NULL)
630
      if (blue_x != NULL)
518
         *blue_x = info_ptr->x_blue;
631
         *blue_x = info_ptr->colorspace.end_points_xy.bluex;
Line 519... Line 632...
519
      if (blue_y != NULL)
632
      if (blue_y != NULL)
520
         *blue_y = info_ptr->y_blue;
633
         *blue_y = info_ptr->colorspace.end_points_xy.bluey;
521
      return (PNG_INFO_cHRM);
634
      return (PNG_INFO_cHRM);
522
   }
635
   }
Line 523... Line 636...
523
 
636
 
-
 
637
   return (0);
524
   return (0);
638
}
525
}
639
#  endif
526
#  endif
640
#endif
527
#endif
641
 
528
 
642
#ifdef PNG_gAMA_SUPPORTED
Line 529... Line 643...
529
#ifdef PNG_gAMA_SUPPORTED
643
#  ifdef PNG_FIXED_POINT_SUPPORTED
-
 
644
png_uint_32 PNGAPI
530
png_uint_32 PNGFAPI
645
png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
531
png_get_gAMA_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
646
    png_fixed_point *file_gamma)
532
    png_fixed_point *file_gamma)
647
{
533
{
648
   png_debug1(1, "in %s retrieval function", "gAMA");
534
   png_debug1(1, "in %s retrieval function", "gAMA");
649
 
Line 535... Line 650...
535
 
650
   if (png_ptr != NULL && info_ptr != NULL &&
536
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
651
      (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
-
 
652
      file_gamma != NULL)
-
 
653
   {
537
       && file_gamma != NULL)
654
      *file_gamma = info_ptr->colorspace.gamma;
538
   {
655
      return (PNG_INFO_gAMA);
539
      *file_gamma = info_ptr->gamma;
656
   }
540
      return (PNG_INFO_gAMA);
657
 
541
   }
658
   return (0);
542
 
-
 
543
   return (0);
-
 
544
}
-
 
545
#  ifdef PNG_FLOATING_POINT_SUPPORTED
-
 
546
png_uint_32 PNGAPI
659
}
Line -... Line 660...
-
 
660
#  endif
-
 
661
 
-
 
662
#  ifdef PNG_FLOATING_POINT_SUPPORTED
-
 
663
png_uint_32 PNGAPI
-
 
664
png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
-
 
665
    double *file_gamma)
547
png_get_gAMA(png_const_structp png_ptr, png_const_infop info_ptr,
666
{
548
    double *file_gamma)
667
   png_debug1(1, "in %s retrieval function", "gAMA(float)");
Line -... Line 668...
-
 
668
 
-
 
669
   if (png_ptr != NULL && info_ptr != NULL &&
549
{
670
      (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
550
   png_fixed_point igamma;
671
      file_gamma != NULL)
Line 551... Line 672...
551
   png_uint_32 ok = png_get_gAMA_fixed(png_ptr, info_ptr, &igamma);
672
   {
552
 
673
      *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
553
   if (ok)
674
         "png_get_gAMA");
554
      *file_gamma = png_float(png_ptr, igamma, "png_get_gAMA");
675
      return (PNG_INFO_gAMA);
555
 
676
   }
556
   return ok;
677
 
Line 557... Line 678...
557
}
678
   return (0);
558
 
679
}
559
#  endif
680
#  endif
560
#endif
681
#endif
561
 
682
 
562
#ifdef PNG_sRGB_SUPPORTED
683
#ifdef PNG_sRGB_SUPPORTED
Line 563... Line 684...
563
png_uint_32 PNGAPI
684
png_uint_32 PNGAPI
564
png_get_sRGB(png_const_structp png_ptr, png_const_infop info_ptr,
685
png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
565
    int *file_srgb_intent)
686
    int *file_srgb_intent)
Line 566... Line 687...
566
{
687
{
567
   png_debug1(1, "in %s retrieval function", "sRGB");
688
   png_debug1(1, "in %s retrieval function", "sRGB");
568
 
689
 
569
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
690
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
570
       && file_srgb_intent != NULL)
691
       && file_srgb_intent != NULL)
571
   {
692
   {
572
      *file_srgb_intent = (int)info_ptr->srgb_intent;
693
      *file_srgb_intent = info_ptr->colorspace.rendering_intent;
Line 573... Line 694...
573
      return (PNG_INFO_sRGB);
694
      return (PNG_INFO_sRGB);
574
   }
695
   }
-
 
696
 
575
 
697
   return (0);
576
   return (0);
698
}
577
}
699
#endif
-
 
700
 
578
#endif
701
#ifdef PNG_iCCP_SUPPORTED
579
 
702
png_uint_32 PNGAPI
580
#ifdef PNG_iCCP_SUPPORTED
703
png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
581
png_uint_32 PNGAPI
-
 
582
png_get_iCCP(png_const_structp png_ptr, png_const_infop info_ptr,
704
    png_charpp name, int *compression_type,
583
    png_charpp name, int *compression_type,
705
    png_bytepp profile, png_uint_32 *proflen)
584
    png_bytepp profile, png_uint_32 *proflen)
706
{
Line 585... Line 707...
585
{
707
   png_debug1(1, "in %s retrieval function", "iCCP");
586
   png_debug1(1, "in %s retrieval function", "iCCP");
708
 
587
 
709
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
Line 588... Line 710...
588
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
710
       && name != NULL && compression_type != NULL && profile != NULL &&
589
       && name != NULL && profile != NULL && proflen != NULL)
711
		 proflen != NULL)
590
   {
712
   {
591
      *name = info_ptr->iccp_name;
713
      *name = info_ptr->iccp_name;
592
      *profile = info_ptr->iccp_profile;
714
      *profile = info_ptr->iccp_profile;
593
      /* Compression_type is a dummy so the API won't have to change
715
      *proflen = png_get_uint_32(info_ptr->iccp_profile);
594
       * if we introduce multiple compression types later.
716
      /* This is somewhat irrelevant since the profile data returned has
595
       */
717
       * actually been uncompressed.
596
      *proflen = (int)info_ptr->iccp_proflen;
718
       */
597
      *compression_type = (int)info_ptr->iccp_compression;
719
      *compression_type = PNG_COMPRESSION_TYPE_BASE;
Line 598... Line 720...
598
      return (PNG_INFO_iCCP);
720
      return (PNG_INFO_iCCP);
599
   }
721
   }
600
 
722
 
Line 601... Line 723...
601
   return (0);
723
   return (0);
602
}
724
}
603
#endif
725
#endif
604
 
726
 
605
#ifdef PNG_sPLT_SUPPORTED
727
#ifdef PNG_sPLT_SUPPORTED
606
png_uint_32 PNGAPI
728
int PNGAPI
Line 607... Line 729...
607
png_get_sPLT(png_const_structp png_ptr, png_const_infop info_ptr,
729
png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,
Line 635... Line 757...
635
}
757
}
636
#endif
758
#endif
637
 
759
 
Line 638... Line 760...
638
png_uint_32 PNGAPI
760
png_uint_32 PNGAPI
639
png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
761
png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
640
    png_uint_32 *width, png_uint_32 *height, int *bit_depth,
762
    png_uint_32 *width, png_uint_32 *height, int *bit_depth,
641
    int *color_type, int *interlace_type, int *compression_type,
763
    int *color_type, int *interlace_type, int *compression_type,
642
    int *filter_type)
764
    int *filter_type)
643
 
-
 
644
{
765
{
645
   png_debug1(1, "in %s retrieval function", "IHDR");
766
   png_debug1(1, "in %s retrieval function", "IHDR");
Line 646... Line 767...
646
 
767
 
647
   if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
768
   if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
Line 675... Line 796...
675
}
796
}
676
 
797
 
Line 677... Line 798...
677
#ifdef PNG_oFFs_SUPPORTED
798
#ifdef PNG_oFFs_SUPPORTED
678
png_uint_32 PNGAPI
799
png_uint_32 PNGAPI
679
png_get_oFFs(png_const_structp png_ptr, png_const_infop info_ptr,
800
png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr,
680
    png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
801
    png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
681
{
802
{
682
   png_debug1(1, "in %s retrieval function", "oFFs");
803
   png_debug1(1, "in %s retrieval function", "oFFs");
Line 683... Line 804...
683
 
804
 
Line 695... Line 816...
695
#endif
816
#endif
696
 
817
 
Line 697... Line 818...
697
#ifdef PNG_pCAL_SUPPORTED
818
#ifdef PNG_pCAL_SUPPORTED
698
png_uint_32 PNGAPI
819
png_uint_32 PNGAPI
699
png_get_pCAL(png_const_structp png_ptr, png_const_infop info_ptr,
820
png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
700
    png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
821
    png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
701
    png_charp *units, png_charpp *params)
822
    png_charp *units, png_charpp *params)
702
{
823
{
703
   png_debug1(1, "in %s retrieval function", "pCAL");
824
   png_debug1(1, "in %s retrieval function", "pCAL");
Line 721... Line 842...
721
#endif
842
#endif
722
 
843
 
Line 723... Line 844...
723
#ifdef PNG_sCAL_SUPPORTED
844
#ifdef PNG_sCAL_SUPPORTED
724
#  ifdef PNG_FIXED_POINT_SUPPORTED
845
#  ifdef PNG_FIXED_POINT_SUPPORTED
725
#    ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
846
#    if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
-
 
847
         defined(PNG_FLOATING_POINT_SUPPORTED)
726
png_uint_32 PNGAPI
848
png_uint_32 PNGAPI
727
png_get_sCAL_fixed(png_structp png_ptr, png_const_infop info_ptr,
849
png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
728
    int *unit, png_fixed_point *width, png_fixed_point *height)
850
    int *unit, png_fixed_point *width, png_fixed_point *height)
729
{
851
{
730
   if (png_ptr != NULL && info_ptr != NULL &&
852
   if (png_ptr != NULL && info_ptr != NULL &&
731
       (info_ptr->valid & PNG_INFO_sCAL))
853
       (info_ptr->valid & PNG_INFO_sCAL))
732
   {
854
   {
733
      *unit = info_ptr->scal_unit;
855
      *unit = info_ptr->scal_unit;
734
      /*TODO: make this work without FP support */
856
      /*TODO: make this work without FP support; the API is currently eliminated
-
 
857
       * if neither floating point APIs nor internal floating point arithmetic
-
 
858
       * are enabled.
-
 
859
       */
735
      *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width");
860
      *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width");
736
      *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
861
      *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
737
         "sCAL height");
862
         "sCAL height");
738
      return (PNG_INFO_sCAL);
863
      return (PNG_INFO_sCAL);
739
   }
864
   }
Line 743... Line 868...
743
#    endif /* FLOATING_ARITHMETIC */
868
#    endif /* FLOATING_ARITHMETIC */
744
#  endif /* FIXED_POINT */
869
#  endif /* FIXED_POINT */
745
#  ifdef PNG_FLOATING_POINT_SUPPORTED
870
#  ifdef PNG_FLOATING_POINT_SUPPORTED
746
png_uint_32 PNGAPI
871
png_uint_32 PNGAPI
747
png_get_sCAL(png_const_structp png_ptr, png_const_infop info_ptr,
872
png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
748
    int *unit, double *width, double *height)
873
    int *unit, double *width, double *height)
749
{
874
{
750
   if (png_ptr != NULL && info_ptr != NULL &&
875
   if (png_ptr != NULL && info_ptr != NULL &&
751
       (info_ptr->valid & PNG_INFO_sCAL))
876
       (info_ptr->valid & PNG_INFO_sCAL))
752
   {
877
   {
753
      *unit = info_ptr->scal_unit;
878
      *unit = info_ptr->scal_unit;
Line 759... Line 884...
759
   return(0);
884
   return(0);
760
}
885
}
761
#  endif /* FLOATING POINT */
886
#  endif /* FLOATING POINT */
762
png_uint_32 PNGAPI
887
png_uint_32 PNGAPI
763
png_get_sCAL_s(png_const_structp png_ptr, png_const_infop info_ptr,
888
png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr,
764
    int *unit, png_charpp width, png_charpp height)
889
    int *unit, png_charpp width, png_charpp height)
765
{
890
{
766
   if (png_ptr != NULL && info_ptr != NULL &&
891
   if (png_ptr != NULL && info_ptr != NULL &&
767
       (info_ptr->valid & PNG_INFO_sCAL))
892
       (info_ptr->valid & PNG_INFO_sCAL))
768
   {
893
   {
Line 777... Line 902...
777
#endif /* sCAL */
902
#endif /* sCAL */
778
 
903
 
Line 779... Line 904...
779
#ifdef PNG_pHYs_SUPPORTED
904
#ifdef PNG_pHYs_SUPPORTED
780
png_uint_32 PNGAPI
905
png_uint_32 PNGAPI
781
png_get_pHYs(png_const_structp png_ptr, png_const_infop info_ptr,
906
png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr,
782
    png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
907
    png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
783
{
908
{
784
   png_uint_32 retval = 0;
909
   png_uint_32 retval = 0;
Line 785... Line 910...
785
 
910
 
Line 811... Line 936...
811
}
936
}
812
#endif /* pHYs */
937
#endif /* pHYs */
813
 
938
 
Line 814... Line 939...
814
png_uint_32 PNGAPI
939
png_uint_32 PNGAPI
815
png_get_PLTE(png_const_structp png_ptr, png_const_infop info_ptr,
940
png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr,
816
    png_colorp *palette, int *num_palette)
941
    png_colorp *palette, int *num_palette)
817
{
942
{
818
   png_debug1(1, "in %s retrieval function", "PLTE");
943
   png_debug1(1, "in %s retrieval function", "PLTE");
Line 819... Line 944...
819
 
944
 
Line 830... Line 955...
830
}
955
}
831
 
956
 
Line 832... Line 957...
832
#ifdef PNG_sBIT_SUPPORTED
957
#ifdef PNG_sBIT_SUPPORTED
833
png_uint_32 PNGAPI
958
png_uint_32 PNGAPI
834
png_get_sBIT(png_const_structp png_ptr, png_infop info_ptr,
959
png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,
835
    png_color_8p *sig_bit)
960
    png_color_8p *sig_bit)
836
{
961
{
837
   png_debug1(1, "in %s retrieval function", "sBIT");
962
   png_debug1(1, "in %s retrieval function", "sBIT");
Line 838... Line 963...
838
 
963
 
Line 847... Line 972...
847
}
972
}
848
#endif
973
#endif
849
 
974
 
Line 850... Line 975...
850
#ifdef PNG_TEXT_SUPPORTED
975
#ifdef PNG_TEXT_SUPPORTED
851
png_uint_32 PNGAPI
976
int PNGAPI
852
png_get_text(png_const_structp png_ptr, png_const_infop info_ptr,
977
png_get_text(png_const_structrp png_ptr, png_inforp info_ptr,
853
    png_textp *text_ptr, int *num_text)
978
    png_textp *text_ptr, int *num_text)
854
{
979
{
855
   if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
980
   if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
856
   {
981
   {
857
      png_debug1(1, "in %s retrieval function",
982
      png_debug1(1, "in 0x%lx retrieval function",
858
          (png_ptr->chunk_name[0] == '\0' ? "text" :
-
 
859
          (png_const_charp)png_ptr->chunk_name));
983
         (unsigned long)png_ptr->chunk_name);
Line 860... Line 984...
860
 
984
 
861
      if (text_ptr != NULL)
985
      if (text_ptr != NULL)
Line 862... Line 986...
862
         *text_ptr = info_ptr->text;
986
         *text_ptr = info_ptr->text;
863
 
987
 
Line 864... Line 988...
864
      if (num_text != NULL)
988
      if (num_text != NULL)
865
         *num_text = info_ptr->num_text;
989
         *num_text = info_ptr->num_text;
Line 866... Line 990...
866
 
990
 
867
      return ((png_uint_32)info_ptr->num_text);
991
      return info_ptr->num_text;
Line 875... Line 999...
875
#endif
999
#endif
876
 
1000
 
Line 877... Line 1001...
877
#ifdef PNG_tIME_SUPPORTED
1001
#ifdef PNG_tIME_SUPPORTED
878
png_uint_32 PNGAPI
1002
png_uint_32 PNGAPI
879
png_get_tIME(png_const_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
1003
png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
-
 
1004
    png_timep *mod_time)
880
{
1005
{
881
   png_debug1(1, "in %s retrieval function", "tIME");
1006
   png_debug1(1, "in %s retrieval function", "tIME");
Line 882... Line 1007...
882
 
1007
 
883
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
1008
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
Line 892... Line 1017...
892
#endif
1017
#endif
893
 
1018
 
Line 894... Line 1019...
894
#ifdef PNG_tRNS_SUPPORTED
1019
#ifdef PNG_tRNS_SUPPORTED
895
png_uint_32 PNGAPI
1020
png_uint_32 PNGAPI
896
png_get_tRNS(png_const_structp png_ptr, png_infop info_ptr,
1021
png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
897
    png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
1022
    png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
898
{
1023
{
899
   png_uint_32 retval = 0;
1024
   png_uint_32 retval = 0;
900
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
1025
   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
901
   {
1026
   {
Line 935... Line 1060...
935
   return (retval);
1060
   return (retval);
936
}
1061
}
937
#endif
1062
#endif
Line 938... Line 1063...
938
 
1063
 
939
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
1064
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
940
int PNGAPI
1065
int PNGAPI
941
png_get_unknown_chunks(png_const_structp png_ptr, png_const_infop info_ptr,
1066
png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr,
942
    png_unknown_chunkpp unknowns)
1067
    png_unknown_chunkpp unknowns)
943
{
1068
{
944
   if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
1069
   if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
945
   {
1070
   {
Line 952... Line 1077...
952
#endif
1077
#endif
953
 
1078
 
Line 954... Line 1079...
954
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
1079
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
955
png_byte PNGAPI
1080
png_byte PNGAPI
956
png_get_rgb_to_gray_status (png_const_structp png_ptr)
1081
png_get_rgb_to_gray_status (png_const_structrp png_ptr)
957
{
1082
{
958
   return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
1083
   return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
959
}
1084
}
960
#endif
1085
#endif
Line 961... Line 1086...
961
 
1086
 
962
#ifdef PNG_USER_CHUNKS_SUPPORTED
1087
#ifdef PNG_USER_CHUNKS_SUPPORTED
963
png_voidp PNGAPI
1088
png_voidp PNGAPI
964
png_get_user_chunk_ptr(png_const_structp png_ptr)
1089
png_get_user_chunk_ptr(png_const_structrp png_ptr)
965
{
1090
{
966
   return (png_ptr ? png_ptr->user_chunk_ptr : NULL);
1091
   return (png_ptr ? png_ptr->user_chunk_ptr : NULL);
967
}
1092
}
Line 968... Line 1093...
968
#endif
1093
#endif
969
 
1094
 
970
png_size_t PNGAPI
1095
png_size_t PNGAPI
-
 
1096
png_get_compression_buffer_size(png_const_structrp png_ptr)
-
 
1097
{
-
 
1098
   if (png_ptr == NULL)
-
 
1099
      return 0;
-
 
1100
 
-
 
1101
#  ifdef PNG_WRITE_SUPPORTED
-
 
1102
      if (png_ptr->mode & PNG_IS_READ_STRUCT)
-
 
1103
#  endif
971
png_get_compression_buffer_size(png_const_structp png_ptr)
1104
   {
-
 
1105
#     ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-
 
1106
         return png_ptr->IDAT_read_size;
-
 
1107
#     else
972
{
1108
         return PNG_IDAT_READ_SIZE;
Line -... Line 1109...
-
 
1109
#     endif
-
 
1110
   }
-
 
1111
 
-
 
1112
#  ifdef PNG_WRITE_SUPPORTED
-
 
1113
      else
Line 973... Line 1114...
973
   return (png_ptr ? png_ptr->zbuf_size : 0L);
1114
         return png_ptr->zbuffer_size;
974
}
1115
#  endif
975
 
1116
}
976
 
1117
 
977
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
1118
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
978
/* These functions were added to libpng 1.2.6 and were enabled
1119
/* These functions were added to libpng 1.2.6 and were enabled
979
 * by default in libpng-1.4.0 */
1120
 * by default in libpng-1.4.0 */
980
png_uint_32 PNGAPI
1121
png_uint_32 PNGAPI
Line 981... Line 1122...
981
png_get_user_width_max (png_const_structp png_ptr)
1122
png_get_user_width_max (png_const_structrp png_ptr)
982
{
1123
{
983
   return (png_ptr ? png_ptr->user_width_max : 0);
1124
   return (png_ptr ? png_ptr->user_width_max : 0);
984
}
1125
}
985
 
1126
 
Line 986... Line 1127...
986
png_uint_32 PNGAPI
1127
png_uint_32 PNGAPI
987
png_get_user_height_max (png_const_structp png_ptr)
1128
png_get_user_height_max (png_const_structrp png_ptr)
988
{
1129
{
989
   return (png_ptr ? png_ptr->user_height_max : 0);
1130
   return (png_ptr ? png_ptr->user_height_max : 0);
990
}
1131
}
991
 
1132
 
Line 992... Line 1133...
992
/* This function was added to libpng 1.4.0 */
1133
/* This function was added to libpng 1.4.0 */
993
png_uint_32 PNGAPI
1134
png_uint_32 PNGAPI
994
png_get_chunk_cache_max (png_const_structp png_ptr)
1135
png_get_chunk_cache_max (png_const_structrp png_ptr)
995
{
1136
{
996
   return (png_ptr ? png_ptr->user_chunk_cache_max : 0);
1137
   return (png_ptr ? png_ptr->user_chunk_cache_max : 0);
997
}
1138
}
998
 
1139
 
Line 999... Line 1140...
999
/* This function was added to libpng 1.4.1 */
1140
/* This function was added to libpng 1.4.1 */
1000
png_alloc_size_t PNGAPI
1141
png_alloc_size_t PNGAPI
1001
png_get_chunk_malloc_max (png_const_structp png_ptr)
1142
png_get_chunk_malloc_max (png_const_structrp png_ptr)
1002
{
1143
{
1003
   return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
1144
   return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
1004
}
1145
}
1005
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
1146
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
Line 1006... Line 1147...
1006
 
1147
 
1007
/* These functions were added to libpng 1.4.0 */
1148
/* These functions were added to libpng 1.4.0 */
1008
#ifdef PNG_IO_STATE_SUPPORTED
1149
#ifdef PNG_IO_STATE_SUPPORTED
1009
png_uint_32 PNGAPI
1150
png_uint_32 PNGAPI
1010
png_get_io_state (png_structp png_ptr)
-
 
1011
{
-
 
1012
   return png_ptr->io_state;
-
 
1013
}
1151
png_get_io_state (png_const_structrp png_ptr)
-
 
1152
{
Line -... Line 1153...
-
 
1153
   return png_ptr->io_state;
-
 
1154
}
1014
 
1155
 
1015
png_uint_32 PNGAPI
1156
png_uint_32 PNGAPI
1016
png_get_io_chunk_type (png_const_structp png_ptr)
1157
png_get_io_chunk_type (png_const_structrp png_ptr)
-
 
1158
{
1017
{
1159
   return png_ptr->chunk_name;
-
 
1160
}
-
 
1161
#endif /* ?PNG_IO_STATE_SUPPORTED */
1018
   return ((png_ptr->chunk_name[0] << 24) +
1162
 
-
 
1163
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
1019
           (png_ptr->chunk_name[1] << 16) +
1164
#  ifdef PNG_GET_PALETTE_MAX_SUPPORTED
Line 1020... Line 1165...
1020
           (png_ptr->chunk_name[2] <<  8) +
1165
int PNGAPI