1 |
1 |
2 /* pngget.c - retrieval of values from info struct |
2 /* pngget.c - retrieval of values from info struct |
3 * |
3 * |
4 * Last changed in libpng 1.2.37 [June 4, 2009] |
4 * Last changed in libpng 1.4.0 [January 3, 2010] |
5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson |
5 * Copyright (c) 1998-2010 Glenn Randers-Pehrson |
6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) |
6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) |
7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) |
7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) |
8 * |
8 * |
9 * This code is released under the libpng license. |
9 * This code is released under the libpng license. |
10 * For conditions of distribution and use, see the disclaimer |
10 * For conditions of distribution and use, see the disclaimer |
11 * and license in png.h |
11 * and license in png.h |
12 * |
12 * |
13 */ |
13 */ |
14 |
14 |
15 #define PNG_INTERNAL |
15 #define PNG_NO_PEDANTIC_WARNINGS |
16 #include "png.h" |
16 #include "png.h" |
17 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) |
17 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) |
|
18 #include "pngpriv.h" |
18 |
19 |
19 png_uint_32 PNGAPI |
20 png_uint_32 PNGAPI |
20 png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) |
21 png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) |
21 { |
22 { |
22 if (png_ptr != NULL && info_ptr != NULL) |
23 if (png_ptr != NULL && info_ptr != NULL) |
380 return(info_ptr->signature); |
384 return(info_ptr->signature); |
381 else |
385 else |
382 return (NULL); |
386 return (NULL); |
383 } |
387 } |
384 |
388 |
385 #if defined(PNG_bKGD_SUPPORTED) |
389 #ifdef PNG_bKGD_SUPPORTED |
386 png_uint_32 PNGAPI |
390 png_uint_32 PNGAPI |
387 png_get_bKGD(png_structp png_ptr, png_infop info_ptr, |
391 png_get_bKGD(png_structp png_ptr, png_infop info_ptr, |
388 png_color_16p *background) |
392 png_color_16p *background) |
389 { |
393 { |
390 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) |
394 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) |
391 && background != NULL) |
395 && background != NULL) |
392 { |
396 { |
393 png_debug1(1, "in %s retrieval function", "bKGD"); |
397 png_debug1(1, "in %s retrieval function", "bKGD"); |
|
398 |
394 *background = &(info_ptr->background); |
399 *background = &(info_ptr->background); |
395 return (PNG_INFO_bKGD); |
400 return (PNG_INFO_bKGD); |
396 } |
401 } |
397 return (0); |
402 return (0); |
398 } |
403 } |
399 #endif |
404 #endif |
400 |
405 |
401 #if defined(PNG_cHRM_SUPPORTED) |
406 #ifdef PNG_cHRM_SUPPORTED |
402 #ifdef PNG_FLOATING_POINT_SUPPORTED |
407 #ifdef PNG_FLOATING_POINT_SUPPORTED |
403 png_uint_32 PNGAPI |
408 png_uint_32 PNGAPI |
404 png_get_cHRM(png_structp png_ptr, png_infop info_ptr, |
409 png_get_cHRM(png_structp png_ptr, png_infop info_ptr, |
405 double *white_x, double *white_y, double *red_x, double *red_y, |
410 double *white_x, double *white_y, double *red_x, double *red_y, |
406 double *green_x, double *green_y, double *blue_x, double *blue_y) |
411 double *green_x, double *green_y, double *blue_x, double *blue_y) |
407 { |
412 { |
408 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) |
413 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) |
409 { |
414 { |
410 png_debug1(1, "in %s retrieval function", "cHRM"); |
415 png_debug1(1, "in %s retrieval function", "cHRM"); |
|
416 |
411 if (white_x != NULL) |
417 if (white_x != NULL) |
412 *white_x = (double)info_ptr->x_white; |
418 *white_x = (double)info_ptr->x_white; |
413 if (white_y != NULL) |
419 if (white_y != NULL) |
414 *white_y = (double)info_ptr->y_white; |
420 *white_y = (double)info_ptr->y_white; |
415 if (red_x != NULL) |
421 if (red_x != NULL) |
434 png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, |
440 png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, |
435 png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, |
441 png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, |
436 png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, |
442 png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, |
437 png_fixed_point *blue_x, png_fixed_point *blue_y) |
443 png_fixed_point *blue_x, png_fixed_point *blue_y) |
438 { |
444 { |
|
445 png_debug1(1, "in %s retrieval function", "cHRM"); |
|
446 |
439 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) |
447 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) |
440 { |
448 { |
441 png_debug1(1, "in %s retrieval function", "cHRM"); |
|
442 if (white_x != NULL) |
449 if (white_x != NULL) |
443 *white_x = info_ptr->int_x_white; |
450 *white_x = info_ptr->int_x_white; |
444 if (white_y != NULL) |
451 if (white_y != NULL) |
445 *white_y = info_ptr->int_y_white; |
452 *white_y = info_ptr->int_y_white; |
446 if (red_x != NULL) |
453 if (red_x != NULL) |
480 #ifdef PNG_FIXED_POINT_SUPPORTED |
488 #ifdef PNG_FIXED_POINT_SUPPORTED |
481 png_uint_32 PNGAPI |
489 png_uint_32 PNGAPI |
482 png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, |
490 png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, |
483 png_fixed_point *int_file_gamma) |
491 png_fixed_point *int_file_gamma) |
484 { |
492 { |
|
493 png_debug1(1, "in %s retrieval function", "gAMA"); |
|
494 |
485 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) |
495 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) |
486 && int_file_gamma != NULL) |
496 && int_file_gamma != NULL) |
487 { |
497 { |
488 png_debug1(1, "in %s retrieval function", "gAMA"); |
|
489 *int_file_gamma = info_ptr->int_gamma; |
498 *int_file_gamma = info_ptr->int_gamma; |
490 return (PNG_INFO_gAMA); |
499 return (PNG_INFO_gAMA); |
491 } |
500 } |
492 return (0); |
501 return (0); |
493 } |
502 } |
494 #endif |
503 #endif |
495 #endif |
504 #endif |
496 |
505 |
497 #if defined(PNG_sRGB_SUPPORTED) |
506 #ifdef PNG_sRGB_SUPPORTED |
498 png_uint_32 PNGAPI |
507 png_uint_32 PNGAPI |
499 png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) |
508 png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) |
500 { |
509 { |
|
510 png_debug1(1, "in %s retrieval function", "sRGB"); |
|
511 |
501 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) |
512 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) |
502 && file_srgb_intent != NULL) |
513 && file_srgb_intent != NULL) |
503 { |
514 { |
504 png_debug1(1, "in %s retrieval function", "sRGB"); |
|
505 *file_srgb_intent = (int)info_ptr->srgb_intent; |
515 *file_srgb_intent = (int)info_ptr->srgb_intent; |
506 return (PNG_INFO_sRGB); |
516 return (PNG_INFO_sRGB); |
507 } |
517 } |
508 return (0); |
518 return (0); |
509 } |
519 } |
510 #endif |
520 #endif |
511 |
521 |
512 #if defined(PNG_iCCP_SUPPORTED) |
522 #ifdef PNG_iCCP_SUPPORTED |
513 png_uint_32 PNGAPI |
523 png_uint_32 PNGAPI |
514 png_get_iCCP(png_structp png_ptr, png_infop info_ptr, |
524 png_get_iCCP(png_structp png_ptr, png_infop info_ptr, |
515 png_charpp name, int *compression_type, |
525 png_charpp name, int *compression_type, |
516 png_charpp profile, png_uint_32 *proflen) |
526 png_charpp profile, png_uint_32 *proflen) |
517 { |
527 { |
|
528 png_debug1(1, "in %s retrieval function", "iCCP"); |
|
529 |
518 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) |
530 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) |
519 && name != NULL && profile != NULL && proflen != NULL) |
531 && name != NULL && profile != NULL && proflen != NULL) |
520 { |
532 { |
521 png_debug1(1, "in %s retrieval function", "iCCP"); |
|
522 *name = info_ptr->iccp_name; |
533 *name = info_ptr->iccp_name; |
523 *profile = info_ptr->iccp_profile; |
534 *profile = info_ptr->iccp_profile; |
524 /* Compression_type is a dummy so the API won't have to change |
535 /* Compression_type is a dummy so the API won't have to change |
525 * if we introduce multiple compression types later. |
536 * if we introduce multiple compression types later. |
526 */ |
537 */ |
566 png_uint_32 *width, png_uint_32 *height, int *bit_depth, |
578 png_uint_32 *width, png_uint_32 *height, int *bit_depth, |
567 int *color_type, int *interlace_type, int *compression_type, |
579 int *color_type, int *interlace_type, int *compression_type, |
568 int *filter_type) |
580 int *filter_type) |
569 |
581 |
570 { |
582 { |
571 if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && |
583 png_debug1(1, "in %s retrieval function", "IHDR"); |
572 bit_depth != NULL && color_type != NULL) |
584 |
573 { |
585 if (png_ptr == NULL || info_ptr == NULL || width == NULL || |
574 png_debug1(1, "in %s retrieval function", "IHDR"); |
586 height == NULL || bit_depth == NULL || color_type == NULL) |
575 *width = info_ptr->width; |
587 return (0); |
576 *height = info_ptr->height; |
588 |
577 *bit_depth = info_ptr->bit_depth; |
589 *width = info_ptr->width; |
578 if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16) |
590 *height = info_ptr->height; |
579 png_error(png_ptr, "Invalid bit depth"); |
591 *bit_depth = info_ptr->bit_depth; |
580 |
592 *color_type = info_ptr->color_type; |
581 *color_type = info_ptr->color_type; |
593 |
582 |
594 if (compression_type != NULL) |
583 if (info_ptr->color_type > 6) |
595 *compression_type = info_ptr->compression_type; |
584 png_error(png_ptr, "Invalid color type"); |
596 |
585 |
597 if (filter_type != NULL) |
586 if (compression_type != NULL) |
598 *filter_type = info_ptr->filter_type; |
587 *compression_type = info_ptr->compression_type; |
599 |
588 |
600 if (interlace_type != NULL) |
589 if (filter_type != NULL) |
601 *interlace_type = info_ptr->interlace_type; |
590 *filter_type = info_ptr->filter_type; |
602 |
591 |
603 /* This is redundant if we can be sure that the info_ptr values were all |
592 if (interlace_type != NULL) |
604 * assigned in png_set_IHDR(). We do the check anyhow in case an |
593 *interlace_type = info_ptr->interlace_type; |
605 * application has ignored our advice not to mess with the members |
594 |
606 * of info_ptr directly. |
595 /* Check for potential overflow of rowbytes */ |
607 */ |
596 if (*width == 0 || *width > PNG_UINT_31_MAX) |
608 png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height, |
597 png_error(png_ptr, "Invalid image width"); |
609 info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, |
598 |
610 info_ptr->compression_type, info_ptr->filter_type); |
599 if (*height == 0 || *height > PNG_UINT_31_MAX) |
611 |
600 png_error(png_ptr, "Invalid image height"); |
612 return (1); |
601 |
613 } |
602 if (info_ptr->width > (PNG_UINT_32_MAX |
614 |
603 >> 3) /* 8-byte RGBA pixels */ |
615 #ifdef PNG_oFFs_SUPPORTED |
604 - 64 /* bigrowbuf hack */ |
|
605 - 1 /* filter byte */ |
|
606 - 7*8 /* rounding of width to multiple of 8 pixels */ |
|
607 - 8) /* extra max_pixel_depth pad */ |
|
608 { |
|
609 png_warning(png_ptr, |
|
610 "Width too large for libpng to process image data."); |
|
611 } |
|
612 |
|
613 return (1); |
|
614 } |
|
615 return (0); |
|
616 } |
|
617 |
|
618 #if defined(PNG_oFFs_SUPPORTED) |
|
619 png_uint_32 PNGAPI |
616 png_uint_32 PNGAPI |
620 png_get_oFFs(png_structp png_ptr, png_infop info_ptr, |
617 png_get_oFFs(png_structp png_ptr, png_infop info_ptr, |
621 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) |
618 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) |
622 { |
619 { |
|
620 png_debug1(1, "in %s retrieval function", "oFFs"); |
|
621 |
623 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) |
622 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) |
624 && offset_x != NULL && offset_y != NULL && unit_type != NULL) |
623 && offset_x != NULL && offset_y != NULL && unit_type != NULL) |
625 { |
624 { |
626 png_debug1(1, "in %s retrieval function", "oFFs"); |
|
627 *offset_x = info_ptr->x_offset; |
625 *offset_x = info_ptr->x_offset; |
628 *offset_y = info_ptr->y_offset; |
626 *offset_y = info_ptr->y_offset; |
629 *unit_type = (int)info_ptr->offset_unit_type; |
627 *unit_type = (int)info_ptr->offset_unit_type; |
630 return (PNG_INFO_oFFs); |
628 return (PNG_INFO_oFFs); |
631 } |
629 } |
632 return (0); |
630 return (0); |
633 } |
631 } |
634 #endif |
632 #endif |
635 |
633 |
636 #if defined(PNG_pCAL_SUPPORTED) |
634 #ifdef PNG_pCAL_SUPPORTED |
637 png_uint_32 PNGAPI |
635 png_uint_32 PNGAPI |
638 png_get_pCAL(png_structp png_ptr, png_infop info_ptr, |
636 png_get_pCAL(png_structp png_ptr, png_infop info_ptr, |
639 png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, |
637 png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, |
640 png_charp *units, png_charpp *params) |
638 png_charp *units, png_charpp *params) |
641 { |
639 { |
|
640 png_debug1(1, "in %s retrieval function", "pCAL"); |
|
641 |
642 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) |
642 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) |
643 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && |
643 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && |
644 nparams != NULL && units != NULL && params != NULL) |
644 nparams != NULL && units != NULL && params != NULL) |
645 { |
645 { |
646 png_debug1(1, "in %s retrieval function", "pCAL"); |
|
647 *purpose = info_ptr->pcal_purpose; |
646 *purpose = info_ptr->pcal_purpose; |
648 *X0 = info_ptr->pcal_X0; |
647 *X0 = info_ptr->pcal_X0; |
649 *X1 = info_ptr->pcal_X1; |
648 *X1 = info_ptr->pcal_X1; |
650 *type = (int)info_ptr->pcal_type; |
649 *type = (int)info_ptr->pcal_type; |
651 *nparams = (int)info_ptr->pcal_nparams; |
650 *nparams = (int)info_ptr->pcal_nparams; |
729 |
728 |
730 png_uint_32 PNGAPI |
729 png_uint_32 PNGAPI |
731 png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, |
730 png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, |
732 int *num_palette) |
731 int *num_palette) |
733 { |
732 { |
|
733 png_debug1(1, "in %s retrieval function", "PLTE"); |
|
734 |
734 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) |
735 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) |
735 && palette != NULL) |
736 && palette != NULL) |
736 { |
737 { |
737 png_debug1(1, "in %s retrieval function", "PLTE"); |
|
738 *palette = info_ptr->palette; |
738 *palette = info_ptr->palette; |
739 *num_palette = info_ptr->num_palette; |
739 *num_palette = info_ptr->num_palette; |
740 png_debug1(3, "num_palette = %d", *num_palette); |
740 png_debug1(3, "num_palette = %d", *num_palette); |
741 return (PNG_INFO_PLTE); |
741 return (PNG_INFO_PLTE); |
742 } |
742 } |
743 return (0); |
743 return (0); |
744 } |
744 } |
745 |
745 |
746 #if defined(PNG_sBIT_SUPPORTED) |
746 #ifdef PNG_sBIT_SUPPORTED |
747 png_uint_32 PNGAPI |
747 png_uint_32 PNGAPI |
748 png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) |
748 png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) |
749 { |
749 { |
|
750 png_debug1(1, "in %s retrieval function", "sBIT"); |
|
751 |
750 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) |
752 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) |
751 && sig_bit != NULL) |
753 && sig_bit != NULL) |
752 { |
754 { |
753 png_debug1(1, "in %s retrieval function", "sBIT"); |
|
754 *sig_bit = &(info_ptr->sig_bit); |
755 *sig_bit = &(info_ptr->sig_bit); |
755 return (PNG_INFO_sBIT); |
756 return (PNG_INFO_sBIT); |
756 } |
757 } |
757 return (0); |
758 return (0); |
758 } |
759 } |
759 #endif |
760 #endif |
760 |
761 |
761 #if defined(PNG_TEXT_SUPPORTED) |
762 #ifdef PNG_TEXT_SUPPORTED |
762 png_uint_32 PNGAPI |
763 png_uint_32 PNGAPI |
763 png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, |
764 png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, |
764 int *num_text) |
765 int *num_text) |
765 { |
766 { |
766 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) |
767 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) |
781 *num_text = 0; |
782 *num_text = 0; |
782 return(0); |
783 return(0); |
783 } |
784 } |
784 #endif |
785 #endif |
785 |
786 |
786 #if defined(PNG_tIME_SUPPORTED) |
787 #ifdef PNG_tIME_SUPPORTED |
787 png_uint_32 PNGAPI |
788 png_uint_32 PNGAPI |
788 png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) |
789 png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) |
789 { |
790 { |
|
791 png_debug1(1, "in %s retrieval function", "tIME"); |
|
792 |
790 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) |
793 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) |
791 && mod_time != NULL) |
794 && mod_time != NULL) |
792 { |
795 { |
793 png_debug1(1, "in %s retrieval function", "tIME"); |
|
794 *mod_time = &(info_ptr->mod_time); |
796 *mod_time = &(info_ptr->mod_time); |
795 return (PNG_INFO_tIME); |
797 return (PNG_INFO_tIME); |
796 } |
798 } |
797 return (0); |
799 return (0); |
798 } |
800 } |
799 #endif |
801 #endif |
800 |
802 |
801 #if defined(PNG_tRNS_SUPPORTED) |
803 #ifdef PNG_tRNS_SUPPORTED |
802 png_uint_32 PNGAPI |
804 png_uint_32 PNGAPI |
803 png_get_tRNS(png_structp png_ptr, png_infop info_ptr, |
805 png_get_tRNS(png_structp png_ptr, png_infop info_ptr, |
804 png_bytep *trans, int *num_trans, png_color_16p *trans_values) |
806 png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color) |
805 { |
807 { |
806 png_uint_32 retval = 0; |
808 png_uint_32 retval = 0; |
807 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) |
809 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) |
808 { |
810 { |
809 png_debug1(1, "in %s retrieval function", "tRNS"); |
811 png_debug1(1, "in %s retrieval function", "tRNS"); |
|
812 |
810 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) |
813 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) |
811 { |
814 { |
812 if (trans != NULL) |
815 if (trans_alpha != NULL) |
813 { |
816 { |
814 *trans = info_ptr->trans; |
817 *trans_alpha = info_ptr->trans_alpha; |
815 retval |= PNG_INFO_tRNS; |
818 retval |= PNG_INFO_tRNS; |
816 } |
819 } |
817 |
820 |
818 if (trans_values != NULL) |
821 if (trans_color != NULL) |
819 *trans_values = &(info_ptr->trans_values); |
822 *trans_color = &(info_ptr->trans_color); |
820 } |
823 } |
821 else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ |
824 else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ |
822 { |
825 { |
823 if (trans_values != NULL) |
826 if (trans_color != NULL) |
824 { |
827 { |
825 *trans_values = &(info_ptr->trans_values); |
828 *trans_color = &(info_ptr->trans_color); |
826 retval |= PNG_INFO_tRNS; |
829 retval |= PNG_INFO_tRNS; |
827 } |
830 } |
828 |
831 |
829 if (trans != NULL) |
832 if (trans_alpha != NULL) |
830 *trans = NULL; |
833 *trans_alpha = NULL; |
831 } |
834 } |
832 if (num_trans != NULL) |
835 if (num_trans != NULL) |
833 { |
836 { |
834 *num_trans = info_ptr->num_trans; |
837 *num_trans = info_ptr->num_trans; |
835 retval |= PNG_INFO_tRNS; |
838 retval |= PNG_INFO_tRNS; |
851 } |
854 } |
852 return (0); |
855 return (0); |
853 } |
856 } |
854 #endif |
857 #endif |
855 |
858 |
856 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) |
859 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED |
857 png_byte PNGAPI |
860 png_byte PNGAPI |
858 png_get_rgb_to_gray_status (png_structp png_ptr) |
861 png_get_rgb_to_gray_status (png_structp png_ptr) |
859 { |
862 { |
860 return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0); |
863 return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0); |
861 } |
864 } |
862 #endif |
865 #endif |
863 |
866 |
864 #if defined(PNG_USER_CHUNKS_SUPPORTED) |
867 #ifdef PNG_USER_CHUNKS_SUPPORTED |
865 png_voidp PNGAPI |
868 png_voidp PNGAPI |
866 png_get_user_chunk_ptr(png_structp png_ptr) |
869 png_get_user_chunk_ptr(png_structp png_ptr) |
867 { |
870 { |
868 return (png_ptr? png_ptr->user_chunk_ptr : NULL); |
871 return (png_ptr? png_ptr->user_chunk_ptr : NULL); |
869 } |
872 } |
870 #endif |
873 #endif |
871 |
874 |
872 #ifdef PNG_WRITE_SUPPORTED |
875 #ifdef PNG_WRITE_SUPPORTED |
873 png_uint_32 PNGAPI |
876 png_size_t PNGAPI |
874 png_get_compression_buffer_size(png_structp png_ptr) |
877 png_get_compression_buffer_size(png_structp png_ptr) |
875 { |
878 { |
876 return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L); |
879 return (png_ptr ? png_ptr->zbuf_size : 0L); |
877 } |
880 } |
878 #endif |
881 #endif |
879 |
882 |
880 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED |
|
881 #ifndef PNG_1_0_X |
|
882 /* This function was added to libpng 1.2.0 and should exist by default */ |
|
883 png_uint_32 PNGAPI |
|
884 png_get_asm_flags (png_structp png_ptr) |
|
885 { |
|
886 /* Obsolete, to be removed from libpng-1.4.0 */ |
|
887 return (png_ptr? 0L: 0L); |
|
888 } |
|
889 |
|
890 /* This function was added to libpng 1.2.0 and should exist by default */ |
|
891 png_uint_32 PNGAPI |
|
892 png_get_asm_flagmask (int flag_select) |
|
893 { |
|
894 /* Obsolete, to be removed from libpng-1.4.0 */ |
|
895 flag_select=flag_select; |
|
896 return 0L; |
|
897 } |
|
898 |
|
899 /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ |
|
900 /* This function was added to libpng 1.2.0 */ |
|
901 png_uint_32 PNGAPI |
|
902 png_get_mmx_flagmask (int flag_select, int *compilerID) |
|
903 { |
|
904 /* Obsolete, to be removed from libpng-1.4.0 */ |
|
905 flag_select=flag_select; |
|
906 *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */ |
|
907 return 0L; |
|
908 } |
|
909 |
|
910 /* This function was added to libpng 1.2.0 */ |
|
911 png_byte PNGAPI |
|
912 png_get_mmx_bitdepth_threshold (png_structp png_ptr) |
|
913 { |
|
914 /* Obsolete, to be removed from libpng-1.4.0 */ |
|
915 return (png_ptr? 0: 0); |
|
916 } |
|
917 |
|
918 /* This function was added to libpng 1.2.0 */ |
|
919 png_uint_32 PNGAPI |
|
920 png_get_mmx_rowbytes_threshold (png_structp png_ptr) |
|
921 { |
|
922 /* Obsolete, to be removed from libpng-1.4.0 */ |
|
923 return (png_ptr? 0L: 0L); |
|
924 } |
|
925 #endif /* ?PNG_1_0_X */ |
|
926 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ |
|
927 |
883 |
928 #ifdef PNG_SET_USER_LIMITS_SUPPORTED |
884 #ifdef PNG_SET_USER_LIMITS_SUPPORTED |
929 /* These functions were added to libpng 1.2.6 */ |
885 /* These functions were added to libpng 1.2.6 */ |
930 png_uint_32 PNGAPI |
886 png_uint_32 PNGAPI |
931 png_get_user_width_max (png_structp png_ptr) |
887 png_get_user_width_max (png_structp png_ptr) |