2 /* pngget.c - retrieval of values from info struct
\r
4 * Last changed in libpng 1.2.30 [August 15, 2008]
\r
5 * For conditions of distribution and use, see copyright notice in png.h
\r
6 * Copyright (c) 1998-2008 Glenn Randers-Pehrson
\r
7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
\r
8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
\r
11 #define PNG_INTERNAL
\r
13 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
\r
16 png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
\r
18 if (png_ptr != NULL && info_ptr != NULL)
\r
19 return(info_ptr->valid & flag);
\r
25 png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
\r
27 if (png_ptr != NULL && info_ptr != NULL)
\r
28 return(info_ptr->rowbytes);
\r
33 #if defined(PNG_INFO_IMAGE_SUPPORTED)
\r
35 png_get_rows(png_structp png_ptr, png_infop info_ptr)
\r
37 if (png_ptr != NULL && info_ptr != NULL)
\r
38 return(info_ptr->row_pointers);
\r
44 #ifdef PNG_EASY_ACCESS_SUPPORTED
\r
45 /* easy access to info, added in libpng-0.99 */
\r
47 png_get_image_width(png_structp png_ptr, png_infop info_ptr)
\r
49 if (png_ptr != NULL && info_ptr != NULL)
\r
51 return info_ptr->width;
\r
57 png_get_image_height(png_structp png_ptr, png_infop info_ptr)
\r
59 if (png_ptr != NULL && info_ptr != NULL)
\r
61 return info_ptr->height;
\r
67 png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
\r
69 if (png_ptr != NULL && info_ptr != NULL)
\r
71 return info_ptr->bit_depth;
\r
77 png_get_color_type(png_structp png_ptr, png_infop info_ptr)
\r
79 if (png_ptr != NULL && info_ptr != NULL)
\r
81 return info_ptr->color_type;
\r
87 png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
\r
89 if (png_ptr != NULL && info_ptr != NULL)
\r
91 return info_ptr->filter_type;
\r
97 png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
\r
99 if (png_ptr != NULL && info_ptr != NULL)
\r
101 return info_ptr->interlace_type;
\r
107 png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
\r
109 if (png_ptr != NULL && info_ptr != NULL)
\r
111 return info_ptr->compression_type;
\r
117 png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
\r
119 if (png_ptr != NULL && info_ptr != NULL)
\r
120 #if defined(PNG_pHYs_SUPPORTED)
\r
121 if (info_ptr->valid & PNG_INFO_pHYs)
\r
123 png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter");
\r
124 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
\r
126 else return (info_ptr->x_pixels_per_unit);
\r
135 png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
\r
137 if (png_ptr != NULL && info_ptr != NULL)
\r
138 #if defined(PNG_pHYs_SUPPORTED)
\r
139 if (info_ptr->valid & PNG_INFO_pHYs)
\r
141 png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter");
\r
142 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
\r
144 else return (info_ptr->y_pixels_per_unit);
\r
153 png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
\r
155 if (png_ptr != NULL && info_ptr != NULL)
\r
156 #if defined(PNG_pHYs_SUPPORTED)
\r
157 if (info_ptr->valid & PNG_INFO_pHYs)
\r
159 png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter");
\r
160 if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
\r
161 info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
\r
163 else return (info_ptr->x_pixels_per_unit);
\r
171 #ifdef PNG_FLOATING_POINT_SUPPORTED
\r
173 png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
\r
175 if (png_ptr != NULL && info_ptr != NULL)
\r
176 #if defined(PNG_pHYs_SUPPORTED)
\r
177 if (info_ptr->valid & PNG_INFO_pHYs)
\r
179 png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio");
\r
180 if (info_ptr->x_pixels_per_unit == 0)
\r
181 return ((float)0.0);
\r
183 return ((float)((float)info_ptr->y_pixels_per_unit
\r
184 /(float)info_ptr->x_pixels_per_unit));
\r
189 return ((float)0.0);
\r
194 png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
\r
196 if (png_ptr != NULL && info_ptr != NULL)
\r
197 #if defined(PNG_oFFs_SUPPORTED)
\r
198 if (info_ptr->valid & PNG_INFO_oFFs)
\r
200 png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
\r
201 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
\r
203 else return (info_ptr->x_offset);
\r
212 png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
\r
214 if (png_ptr != NULL && info_ptr != NULL)
\r
215 #if defined(PNG_oFFs_SUPPORTED)
\r
216 if (info_ptr->valid & PNG_INFO_oFFs)
\r
218 png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
\r
219 if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
\r
221 else return (info_ptr->y_offset);
\r
230 png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
\r
232 if (png_ptr != NULL && info_ptr != NULL)
\r
233 #if defined(PNG_oFFs_SUPPORTED)
\r
234 if (info_ptr->valid & PNG_INFO_oFFs)
\r
236 png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
\r
237 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
\r
239 else return (info_ptr->x_offset);
\r
248 png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
\r
250 if (png_ptr != NULL && info_ptr != NULL)
\r
251 #if defined(PNG_oFFs_SUPPORTED)
\r
252 if (info_ptr->valid & PNG_INFO_oFFs)
\r
254 png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
\r
255 if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
\r
257 else return (info_ptr->y_offset);
\r
265 #if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
\r
267 png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
\r
269 return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr)
\r
274 png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
\r
276 return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr)
\r
281 png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
\r
283 return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr)
\r
288 png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
\r
290 return ((float)png_get_x_offset_microns(png_ptr, info_ptr)
\r
295 png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
\r
297 return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
\r
301 #if defined(PNG_pHYs_SUPPORTED)
\r
303 png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
\r
304 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
\r
306 png_uint_32 retval = 0;
\r
308 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
\r
310 png_debug1(1, "in %s retrieval function\n", "pHYs");
\r
313 *res_x = info_ptr->x_pixels_per_unit;
\r
314 retval |= PNG_INFO_pHYs;
\r
318 *res_y = info_ptr->y_pixels_per_unit;
\r
319 retval |= PNG_INFO_pHYs;
\r
321 if (unit_type != NULL)
\r
323 *unit_type = (int)info_ptr->phys_unit_type;
\r
324 retval |= PNG_INFO_pHYs;
\r
325 if (*unit_type == 1)
\r
327 if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
\r
328 if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
\r
334 #endif /* PNG_pHYs_SUPPORTED */
\r
335 #endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
\r
337 /* png_get_channels really belongs in here, too, but it's been around longer */
\r
339 #endif /* PNG_EASY_ACCESS_SUPPORTED */
\r
342 png_get_channels(png_structp png_ptr, png_infop info_ptr)
\r
344 if (png_ptr != NULL && info_ptr != NULL)
\r
345 return(info_ptr->channels);
\r
351 png_get_signature(png_structp png_ptr, png_infop info_ptr)
\r
353 if (png_ptr != NULL && info_ptr != NULL)
\r
354 return(info_ptr->signature);
\r
359 #if defined(PNG_bKGD_SUPPORTED)
\r
361 png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
\r
362 png_color_16p *background)
\r
364 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
\r
365 && background != NULL)
\r
367 png_debug1(1, "in %s retrieval function\n", "bKGD");
\r
368 *background = &(info_ptr->background);
\r
369 return (PNG_INFO_bKGD);
\r
375 #if defined(PNG_cHRM_SUPPORTED)
\r
376 #ifdef PNG_FLOATING_POINT_SUPPORTED
\r
378 png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
\r
379 double *white_x, double *white_y, double *red_x, double *red_y,
\r
380 double *green_x, double *green_y, double *blue_x, double *blue_y)
\r
382 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
\r
384 png_debug1(1, "in %s retrieval function\n", "cHRM");
\r
385 if (white_x != NULL)
\r
386 *white_x = (double)info_ptr->x_white;
\r
387 if (white_y != NULL)
\r
388 *white_y = (double)info_ptr->y_white;
\r
390 *red_x = (double)info_ptr->x_red;
\r
392 *red_y = (double)info_ptr->y_red;
\r
393 if (green_x != NULL)
\r
394 *green_x = (double)info_ptr->x_green;
\r
395 if (green_y != NULL)
\r
396 *green_y = (double)info_ptr->y_green;
\r
397 if (blue_x != NULL)
\r
398 *blue_x = (double)info_ptr->x_blue;
\r
399 if (blue_y != NULL)
\r
400 *blue_y = (double)info_ptr->y_blue;
\r
401 return (PNG_INFO_cHRM);
\r
406 #ifdef PNG_FIXED_POINT_SUPPORTED
\r
408 png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
\r
409 png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
\r
410 png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
\r
411 png_fixed_point *blue_x, png_fixed_point *blue_y)
\r
413 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
\r
415 png_debug1(1, "in %s retrieval function\n", "cHRM");
\r
416 if (white_x != NULL)
\r
417 *white_x = info_ptr->int_x_white;
\r
418 if (white_y != NULL)
\r
419 *white_y = info_ptr->int_y_white;
\r
421 *red_x = info_ptr->int_x_red;
\r
423 *red_y = info_ptr->int_y_red;
\r
424 if (green_x != NULL)
\r
425 *green_x = info_ptr->int_x_green;
\r
426 if (green_y != NULL)
\r
427 *green_y = info_ptr->int_y_green;
\r
428 if (blue_x != NULL)
\r
429 *blue_x = info_ptr->int_x_blue;
\r
430 if (blue_y != NULL)
\r
431 *blue_y = info_ptr->int_y_blue;
\r
432 return (PNG_INFO_cHRM);
\r
439 #if defined(PNG_gAMA_SUPPORTED)
\r
440 #ifdef PNG_FLOATING_POINT_SUPPORTED
\r
442 png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
\r
444 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
\r
445 && file_gamma != NULL)
\r
447 png_debug1(1, "in %s retrieval function\n", "gAMA");
\r
448 *file_gamma = (double)info_ptr->gamma;
\r
449 return (PNG_INFO_gAMA);
\r
454 #ifdef PNG_FIXED_POINT_SUPPORTED
\r
456 png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
\r
457 png_fixed_point *int_file_gamma)
\r
459 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
\r
460 && int_file_gamma != NULL)
\r
462 png_debug1(1, "in %s retrieval function\n", "gAMA");
\r
463 *int_file_gamma = info_ptr->int_gamma;
\r
464 return (PNG_INFO_gAMA);
\r
471 #if defined(PNG_sRGB_SUPPORTED)
\r
473 png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
\r
475 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
\r
476 && file_srgb_intent != NULL)
\r
478 png_debug1(1, "in %s retrieval function\n", "sRGB");
\r
479 *file_srgb_intent = (int)info_ptr->srgb_intent;
\r
480 return (PNG_INFO_sRGB);
\r
486 #if defined(PNG_iCCP_SUPPORTED)
\r
488 png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
\r
489 png_charpp name, int *compression_type,
\r
490 png_charpp profile, png_uint_32 *proflen)
\r
492 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
\r
493 && name != NULL && profile != NULL && proflen != NULL)
\r
495 png_debug1(1, "in %s retrieval function\n", "iCCP");
\r
496 *name = info_ptr->iccp_name;
\r
497 *profile = info_ptr->iccp_profile;
\r
498 /* compression_type is a dummy so the API won't have to change
\r
499 if we introduce multiple compression types later. */
\r
500 *proflen = (int)info_ptr->iccp_proflen;
\r
501 *compression_type = (int)info_ptr->iccp_compression;
\r
502 return (PNG_INFO_iCCP);
\r
508 #if defined(PNG_sPLT_SUPPORTED)
\r
510 png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
\r
511 png_sPLT_tpp spalettes)
\r
513 if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
\r
515 *spalettes = info_ptr->splt_palettes;
\r
516 return ((png_uint_32)info_ptr->splt_palettes_num);
\r
522 #if defined(PNG_hIST_SUPPORTED)
\r
524 png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
\r
526 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
\r
529 png_debug1(1, "in %s retrieval function\n", "hIST");
\r
530 *hist = info_ptr->hist;
\r
531 return (PNG_INFO_hIST);
\r
538 png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
\r
539 png_uint_32 *width, png_uint_32 *height, int *bit_depth,
\r
540 int *color_type, int *interlace_type, int *compression_type,
\r
544 if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
\r
545 bit_depth != NULL && color_type != NULL)
\r
547 png_debug1(1, "in %s retrieval function\n", "IHDR");
\r
548 *width = info_ptr->width;
\r
549 *height = info_ptr->height;
\r
550 *bit_depth = info_ptr->bit_depth;
\r
551 if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16)
\r
552 png_error(png_ptr, "Invalid bit depth");
\r
553 *color_type = info_ptr->color_type;
\r
554 if (info_ptr->color_type > 6)
\r
555 png_error(png_ptr, "Invalid color type");
\r
556 if (compression_type != NULL)
\r
557 *compression_type = info_ptr->compression_type;
\r
558 if (filter_type != NULL)
\r
559 *filter_type = info_ptr->filter_type;
\r
560 if (interlace_type != NULL)
\r
561 *interlace_type = info_ptr->interlace_type;
\r
563 /* check for potential overflow of rowbytes */
\r
564 if (*width == 0 || *width > PNG_UINT_31_MAX)
\r
565 png_error(png_ptr, "Invalid image width");
\r
566 if (*height == 0 || *height > PNG_UINT_31_MAX)
\r
567 png_error(png_ptr, "Invalid image height");
\r
568 if (info_ptr->width > (PNG_UINT_32_MAX
\r
569 >> 3) /* 8-byte RGBA pixels */
\r
570 - 64 /* bigrowbuf hack */
\r
571 - 1 /* filter byte */
\r
572 - 7*8 /* rounding of width to multiple of 8 pixels */
\r
573 - 8) /* extra max_pixel_depth pad */
\r
575 png_warning(png_ptr,
\r
576 "Width too large for libpng to process image data.");
\r
583 #if defined(PNG_oFFs_SUPPORTED)
\r
585 png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
\r
586 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
\r
588 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
\r
589 && offset_x != NULL && offset_y != NULL && unit_type != NULL)
\r
591 png_debug1(1, "in %s retrieval function\n", "oFFs");
\r
592 *offset_x = info_ptr->x_offset;
\r
593 *offset_y = info_ptr->y_offset;
\r
594 *unit_type = (int)info_ptr->offset_unit_type;
\r
595 return (PNG_INFO_oFFs);
\r
601 #if defined(PNG_pCAL_SUPPORTED)
\r
603 png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
\r
604 png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
\r
605 png_charp *units, png_charpp *params)
\r
607 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
\r
608 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
\r
609 nparams != NULL && units != NULL && params != NULL)
\r
611 png_debug1(1, "in %s retrieval function\n", "pCAL");
\r
612 *purpose = info_ptr->pcal_purpose;
\r
613 *X0 = info_ptr->pcal_X0;
\r
614 *X1 = info_ptr->pcal_X1;
\r
615 *type = (int)info_ptr->pcal_type;
\r
616 *nparams = (int)info_ptr->pcal_nparams;
\r
617 *units = info_ptr->pcal_units;
\r
618 *params = info_ptr->pcal_params;
\r
619 return (PNG_INFO_pCAL);
\r
625 #if defined(PNG_sCAL_SUPPORTED)
\r
626 #ifdef PNG_FLOATING_POINT_SUPPORTED
\r
628 png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
\r
629 int *unit, double *width, double *height)
\r
631 if (png_ptr != NULL && info_ptr != NULL &&
\r
632 (info_ptr->valid & PNG_INFO_sCAL))
\r
634 *unit = info_ptr->scal_unit;
\r
635 *width = info_ptr->scal_pixel_width;
\r
636 *height = info_ptr->scal_pixel_height;
\r
637 return (PNG_INFO_sCAL);
\r
642 #ifdef PNG_FIXED_POINT_SUPPORTED
\r
644 png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
\r
645 int *unit, png_charpp width, png_charpp height)
\r
647 if (png_ptr != NULL && info_ptr != NULL &&
\r
648 (info_ptr->valid & PNG_INFO_sCAL))
\r
650 *unit = info_ptr->scal_unit;
\r
651 *width = info_ptr->scal_s_width;
\r
652 *height = info_ptr->scal_s_height;
\r
653 return (PNG_INFO_sCAL);
\r
661 #if defined(PNG_pHYs_SUPPORTED)
\r
663 png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
\r
664 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
\r
666 png_uint_32 retval = 0;
\r
668 if (png_ptr != NULL && info_ptr != NULL &&
\r
669 (info_ptr->valid & PNG_INFO_pHYs))
\r
671 png_debug1(1, "in %s retrieval function\n", "pHYs");
\r
674 *res_x = info_ptr->x_pixels_per_unit;
\r
675 retval |= PNG_INFO_pHYs;
\r
679 *res_y = info_ptr->y_pixels_per_unit;
\r
680 retval |= PNG_INFO_pHYs;
\r
682 if (unit_type != NULL)
\r
684 *unit_type = (int)info_ptr->phys_unit_type;
\r
685 retval |= PNG_INFO_pHYs;
\r
693 png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
\r
696 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
\r
697 && palette != NULL)
\r
699 png_debug1(1, "in %s retrieval function\n", "PLTE");
\r
700 *palette = info_ptr->palette;
\r
701 *num_palette = info_ptr->num_palette;
\r
702 png_debug1(3, "num_palette = %d\n", *num_palette);
\r
703 return (PNG_INFO_PLTE);
\r
708 #if defined(PNG_sBIT_SUPPORTED)
\r
710 png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
\r
712 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
\r
713 && sig_bit != NULL)
\r
715 png_debug1(1, "in %s retrieval function\n", "sBIT");
\r
716 *sig_bit = &(info_ptr->sig_bit);
\r
717 return (PNG_INFO_sBIT);
\r
723 #if defined(PNG_TEXT_SUPPORTED)
\r
725 png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
\r
728 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
\r
730 png_debug1(1, "in %s retrieval function\n",
\r
731 (png_ptr->chunk_name[0] == '\0' ? "text"
\r
732 : (png_const_charp)png_ptr->chunk_name));
\r
733 if (text_ptr != NULL)
\r
734 *text_ptr = info_ptr->text;
\r
735 if (num_text != NULL)
\r
736 *num_text = info_ptr->num_text;
\r
737 return ((png_uint_32)info_ptr->num_text);
\r
739 if (num_text != NULL)
\r
745 #if defined(PNG_tIME_SUPPORTED)
\r
747 png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
\r
749 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
\r
750 && mod_time != NULL)
\r
752 png_debug1(1, "in %s retrieval function\n", "tIME");
\r
753 *mod_time = &(info_ptr->mod_time);
\r
754 return (PNG_INFO_tIME);
\r
760 #if defined(PNG_tRNS_SUPPORTED)
\r
762 png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
\r
763 png_bytep *trans, int *num_trans, png_color_16p *trans_values)
\r
765 png_uint_32 retval = 0;
\r
766 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
\r
768 png_debug1(1, "in %s retrieval function\n", "tRNS");
\r
769 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
\r
773 *trans = info_ptr->trans;
\r
774 retval |= PNG_INFO_tRNS;
\r
776 if (trans_values != NULL)
\r
777 *trans_values = &(info_ptr->trans_values);
\r
779 else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
\r
781 if (trans_values != NULL)
\r
783 *trans_values = &(info_ptr->trans_values);
\r
784 retval |= PNG_INFO_tRNS;
\r
789 if (num_trans != NULL)
\r
791 *num_trans = info_ptr->num_trans;
\r
792 retval |= PNG_INFO_tRNS;
\r
799 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
\r
801 png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
\r
802 png_unknown_chunkpp unknowns)
\r
804 if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
\r
806 *unknowns = info_ptr->unknown_chunks;
\r
807 return ((png_uint_32)info_ptr->unknown_chunks_num);
\r
813 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
\r
815 png_get_rgb_to_gray_status (png_structp png_ptr)
\r
817 return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0);
\r
821 #if defined(PNG_USER_CHUNKS_SUPPORTED)
\r
823 png_get_user_chunk_ptr(png_structp png_ptr)
\r
825 return (png_ptr? png_ptr->user_chunk_ptr : NULL);
\r
829 #ifdef PNG_WRITE_SUPPORTED
\r
831 png_get_compression_buffer_size(png_structp png_ptr)
\r
833 return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L);
\r
837 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
\r
839 /* this function was added to libpng 1.2.0 and should exist by default */
\r
841 png_get_asm_flags (png_structp png_ptr)
\r
843 /* obsolete, to be removed from libpng-1.4.0 */
\r
844 return (png_ptr? 0L: 0L);
\r
847 /* this function was added to libpng 1.2.0 and should exist by default */
\r
849 png_get_asm_flagmask (int flag_select)
\r
851 /* obsolete, to be removed from libpng-1.4.0 */
\r
852 flag_select=flag_select;
\r
856 /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
\r
857 /* this function was added to libpng 1.2.0 */
\r
859 png_get_mmx_flagmask (int flag_select, int *compilerID)
\r
861 /* obsolete, to be removed from libpng-1.4.0 */
\r
862 flag_select=flag_select;
\r
863 *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */
\r
867 /* this function was added to libpng 1.2.0 */
\r
869 png_get_mmx_bitdepth_threshold (png_structp png_ptr)
\r
871 /* obsolete, to be removed from libpng-1.4.0 */
\r
872 return (png_ptr? 0: 0);
\r
875 /* this function was added to libpng 1.2.0 */
\r
877 png_get_mmx_rowbytes_threshold (png_structp png_ptr)
\r
879 /* obsolete, to be removed from libpng-1.4.0 */
\r
880 return (png_ptr? 0L: 0L);
\r
882 #endif /* ?PNG_1_0_X */
\r
883 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
\r
885 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
\r
886 /* these functions were added to libpng 1.2.6 */
\r
888 png_get_user_width_max (png_structp png_ptr)
\r
890 return (png_ptr? png_ptr->user_width_max : 0);
\r
893 png_get_user_height_max (png_structp png_ptr)
\r
895 return (png_ptr? png_ptr->user_height_max : 0);
\r
897 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
\r
900 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
\r