Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 1 | |
| 2 | /* pngget.c - retrieval of values from info struct |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 3 | * |
Glenn Randers-Pehrson | 67ee8ce | 2011-12-22 08:21:00 -0600 | [diff] [blame] | 4 | * Last changed in libpng 1.6.0 [(PENDING RELEASE)] |
Glenn Randers-Pehrson | 1531bd6 | 2012-01-01 14:45:04 -0600 | [diff] [blame] | 5 | * Copyright (c) 1998-2012 Glenn Randers-Pehrson |
Glenn Randers-Pehrson | d436672 | 2000-06-04 14:29:29 -0500 | [diff] [blame] | 6 | * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) |
| 7 | * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) |
Glenn Randers-Pehrson | 3e61d79 | 2009-06-24 09:31:28 -0500 | [diff] [blame] | 8 | * |
Glenn Randers-Pehrson | bfbf865 | 2009-06-26 21:46:52 -0500 | [diff] [blame] | 9 | * This code is released under the libpng license. |
Glenn Randers-Pehrson | c332bbc | 2009-06-25 13:43:50 -0500 | [diff] [blame] | 10 | * For conditions of distribution and use, see the disclaimer |
Glenn Randers-Pehrson | 037023b | 2009-06-24 10:27:36 -0500 | [diff] [blame] | 11 | * and license in png.h |
Glenn Randers-Pehrson | 3e61d79 | 2009-06-24 09:31:28 -0500 | [diff] [blame] | 12 | * |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 13 | */ |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 14 | |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 15 | #include "pngpriv.h" |
Glenn Randers-Pehrson | 9c3ab68 | 2006-02-20 22:09:05 -0600 | [diff] [blame] | 16 | |
Glenn Randers-Pehrson | c3cd22b | 2010-03-08 21:10:25 -0600 | [diff] [blame] | 17 | #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) |
| 18 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 19 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 20 | png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | b86b492 | 2011-01-21 23:12:51 -0600 | [diff] [blame] | 21 | png_uint_32 flag) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 22 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 23 | if (png_ptr != NULL && info_ptr != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 24 | return(info_ptr->valid & flag); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 25 | |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 26 | return(0); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 27 | } |
| 28 | |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 29 | png_size_t PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 30 | png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 31 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 32 | if (png_ptr != NULL && info_ptr != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 33 | return(info_ptr->rowbytes); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 34 | |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 35 | return(0); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 36 | } |
| 37 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 38 | #ifdef PNG_INFO_IMAGE_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 39 | png_bytepp PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 40 | png_get_rows(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | a77ef62 | 2000-02-18 13:48:52 -0600 | [diff] [blame] | 41 | { |
| 42 | if (png_ptr != NULL && info_ptr != NULL) |
| 43 | return(info_ptr->row_pointers); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 44 | |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 45 | return(0); |
Glenn Randers-Pehrson | a77ef62 | 2000-02-18 13:48:52 -0600 | [diff] [blame] | 46 | } |
| 47 | #endif |
| 48 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 49 | #ifdef PNG_EASY_ACCESS_SUPPORTED |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 50 | /* Easy access to info, added in libpng-0.99 */ |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 51 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 52 | png_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 53 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 54 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 55 | return info_ptr->width; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 56 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 57 | return (0); |
| 58 | } |
| 59 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 60 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 61 | png_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 62 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 63 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 64 | return info_ptr->height; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 65 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 66 | return (0); |
| 67 | } |
| 68 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 69 | png_byte PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 70 | png_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 71 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 72 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 73 | return info_ptr->bit_depth; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 74 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 75 | return (0); |
| 76 | } |
| 77 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 78 | png_byte PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 79 | png_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 80 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 81 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 82 | return info_ptr->color_type; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 83 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 84 | return (0); |
| 85 | } |
| 86 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 87 | png_byte PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 88 | png_get_filter_type(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 89 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 90 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 91 | return info_ptr->filter_type; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 92 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 93 | return (0); |
| 94 | } |
| 95 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 96 | png_byte PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 97 | png_get_interlace_type(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 98 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 99 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 100 | return info_ptr->interlace_type; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 101 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 102 | return (0); |
| 103 | } |
| 104 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 105 | png_byte PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 106 | png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 107 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 108 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 109 | return info_ptr->compression_type; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 110 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 111 | return (0); |
| 112 | } |
| 113 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 114 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 115 | png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 116 | { |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 117 | #ifdef PNG_pHYs_SUPPORTED |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 118 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) |
| 119 | { |
| 120 | png_debug1(1, "in %s retrieval function", |
| 121 | "png_get_x_pixels_per_meter"); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 122 | |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 123 | if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) |
| 124 | return (info_ptr->x_pixels_per_unit); |
| 125 | } |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 126 | #endif |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 127 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 128 | return (0); |
| 129 | } |
| 130 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 131 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 132 | png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 133 | { |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 134 | #ifdef PNG_pHYs_SUPPORTED |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 135 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 136 | { |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 137 | png_debug1(1, "in %s retrieval function", |
| 138 | "png_get_y_pixels_per_meter"); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 139 | |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 140 | if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 141 | return (info_ptr->y_pixels_per_unit); |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 142 | } |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 143 | #endif |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 144 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 145 | return (0); |
| 146 | } |
| 147 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 148 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 149 | png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 150 | { |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 151 | #ifdef PNG_pHYs_SUPPORTED |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 152 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 153 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 154 | png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter"); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 155 | |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 156 | if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER && |
| 157 | info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 158 | return (info_ptr->x_pixels_per_unit); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 159 | } |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 160 | #endif |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 161 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 162 | return (0); |
| 163 | } |
| 164 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 165 | #ifdef PNG_FLOATING_POINT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 166 | float PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 167 | png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 168 | { |
Glenn Randers-Pehrson | 4009a76 | 2010-07-31 06:34:36 -0500 | [diff] [blame] | 169 | #ifdef PNG_READ_pHYs_SUPPORTED |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 170 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 171 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 172 | png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); |
Glenn Randers-Pehrson | da00980 | 2009-08-15 13:25:47 -0500 | [diff] [blame] | 173 | |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 174 | if (info_ptr->x_pixels_per_unit != 0) |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 175 | return ((float)((float)info_ptr->y_pixels_per_unit |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 176 | /(float)info_ptr->x_pixels_per_unit)); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 177 | } |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 178 | #endif |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 179 | |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 180 | return ((float)0.0); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 181 | } |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 182 | #endif |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 183 | |
Glenn Randers-Pehrson | 4009a76 | 2010-07-31 06:34:36 -0500 | [diff] [blame] | 184 | #ifdef PNG_FIXED_POINT_SUPPORTED |
| 185 | png_fixed_point PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 186 | png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr, |
| 187 | png_const_inforp info_ptr) |
Glenn Randers-Pehrson | 4009a76 | 2010-07-31 06:34:36 -0500 | [diff] [blame] | 188 | { |
| 189 | #ifdef PNG_READ_pHYs_SUPPORTED |
| 190 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs) |
Glenn Randers-Pehrson | 4aa2cd6 | 2010-08-19 16:52:01 -0500 | [diff] [blame] | 191 | && info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 |
| 192 | && info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX |
| 193 | && info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX) |
Glenn Randers-Pehrson | 4009a76 | 2010-07-31 06:34:36 -0500 | [diff] [blame] | 194 | { |
| 195 | png_fixed_point res; |
| 196 | |
| 197 | png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio_fixed"); |
| 198 | |
Glenn Randers-Pehrson | 4aa2cd6 | 2010-08-19 16:52:01 -0500 | [diff] [blame] | 199 | /* The following casts work because a PNG 4 byte integer only has a valid |
| 200 | * range of 0..2^31-1; otherwise the cast might overflow. |
| 201 | */ |
| 202 | if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1, |
| 203 | (png_int_32)info_ptr->x_pixels_per_unit)) |
Glenn Randers-Pehrson | 3df324d | 2010-07-31 13:45:04 -0500 | [diff] [blame] | 204 | return res; |
Glenn Randers-Pehrson | 4009a76 | 2010-07-31 06:34:36 -0500 | [diff] [blame] | 205 | } |
| 206 | #endif |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 207 | |
Glenn Randers-Pehrson | 4009a76 | 2010-07-31 06:34:36 -0500 | [diff] [blame] | 208 | return 0; |
| 209 | } |
| 210 | #endif |
| 211 | |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 212 | png_int_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 213 | png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 214 | { |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 215 | #ifdef PNG_oFFs_SUPPORTED |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 216 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 217 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 218 | png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 219 | |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 220 | if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 221 | return (info_ptr->x_offset); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 222 | } |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 223 | #endif |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 224 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 225 | return (0); |
| 226 | } |
| 227 | |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 228 | png_int_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 229 | png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 230 | { |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 231 | #ifdef PNG_oFFs_SUPPORTED |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 232 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 233 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 234 | png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 235 | |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 236 | if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 237 | return (info_ptr->y_offset); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 238 | } |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 239 | #endif |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 240 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 241 | return (0); |
| 242 | } |
| 243 | |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 244 | png_int_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 245 | png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 246 | { |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 247 | #ifdef PNG_oFFs_SUPPORTED |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 248 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 249 | { |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 250 | png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels"); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 251 | |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 252 | if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 253 | return (info_ptr->x_offset); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 254 | } |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 255 | #endif |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 256 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 257 | return (0); |
| 258 | } |
| 259 | |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 260 | png_int_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 261 | png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 262 | { |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 263 | #ifdef PNG_oFFs_SUPPORTED |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 264 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 265 | { |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 266 | png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels"); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 267 | |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 268 | if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 269 | return (info_ptr->y_offset); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 270 | } |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 271 | #endif |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 272 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 273 | return (0); |
| 274 | } |
| 275 | |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 276 | #ifdef PNG_INCH_CONVERSIONS_SUPPORTED |
| 277 | static png_uint_32 |
| 278 | ppi_from_ppm(png_uint_32 ppm) |
| 279 | { |
| 280 | #if 0 |
Glenn Randers-Pehrson | 233357e | 2010-07-29 21:49:38 -0500 | [diff] [blame] | 281 | /* The conversion is *(2.54/100), in binary (32 digits): |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 282 | * .00000110100000001001110101001001 |
| 283 | */ |
| 284 | png_uint_32 t1001, t1101; |
| 285 | ppm >>= 1; /* .1 */ |
| 286 | t1001 = ppm + (ppm >> 3); /* .1001 */ |
| 287 | t1101 = t1001 + (ppm >> 1); /* .1101 */ |
| 288 | ppm >>= 20; /* .000000000000000000001 */ |
| 289 | t1101 += t1101 >> 15; /* .1101000000000001101 */ |
| 290 | t1001 >>= 11; /* .000000000001001 */ |
| 291 | t1001 += t1001 >> 12; /* .000000000001001000000001001 */ |
| 292 | ppm += t1001; /* .000000000001001000001001001 */ |
| 293 | ppm += t1101; /* .110100000001001110101001001 */ |
| 294 | return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */ |
| 295 | #else |
| 296 | /* The argument is a PNG unsigned integer, so it is not permitted |
| 297 | * to be bigger than 2^31. |
| 298 | */ |
| 299 | png_fixed_point result; |
Glenn Randers-Pehrson | 4aa2cd6 | 2010-08-19 16:52:01 -0500 | [diff] [blame] | 300 | if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127, |
| 301 | 5000)) |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 302 | return result; |
| 303 | |
| 304 | /* Overflow. */ |
| 305 | return 0; |
| 306 | #endif |
| 307 | } |
| 308 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 309 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 310 | png_get_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 311 | { |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 312 | return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr)); |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 313 | } |
| 314 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 315 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 316 | png_get_x_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 317 | { |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 318 | return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr)); |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 319 | } |
| 320 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 321 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 322 | png_get_y_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 323 | { |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 324 | return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr)); |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 325 | } |
| 326 | |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 327 | #ifdef PNG_FIXED_POINT_SUPPORTED |
| 328 | static png_fixed_point |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 329 | png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns) |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 330 | { |
| 331 | /* Convert from metres * 1,000,000 to inches * 100,000, meters to |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 332 | * inches is simply *(100/2.54), so we want *(10/2.54) == 500/127. |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 333 | * Notice that this can overflow - a warning is output and 0 is |
| 334 | * returned. |
| 335 | */ |
| 336 | return png_muldiv_warn(png_ptr, microns, 500, 127); |
| 337 | } |
| 338 | |
| 339 | png_fixed_point PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 340 | png_get_x_offset_inches_fixed(png_const_structrp png_ptr, |
| 341 | png_const_inforp info_ptr) |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 342 | { |
| 343 | return png_fixed_inches_from_microns(png_ptr, |
Glenn Randers-Pehrson | 4aa2cd6 | 2010-08-19 16:52:01 -0500 | [diff] [blame] | 344 | png_get_x_offset_microns(png_ptr, info_ptr)); |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 345 | } |
| 346 | #endif |
| 347 | |
| 348 | #ifdef PNG_FIXED_POINT_SUPPORTED |
| 349 | png_fixed_point PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 350 | png_get_y_offset_inches_fixed(png_const_structrp png_ptr, |
| 351 | png_const_inforp info_ptr) |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 352 | { |
| 353 | return png_fixed_inches_from_microns(png_ptr, |
Glenn Randers-Pehrson | 4aa2cd6 | 2010-08-19 16:52:01 -0500 | [diff] [blame] | 354 | png_get_y_offset_microns(png_ptr, info_ptr)); |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 355 | } |
| 356 | #endif |
| 357 | |
| 358 | #ifdef PNG_FLOATING_POINT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 359 | float PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 360 | png_get_x_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 361 | { |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 362 | /* To avoid the overflow do the conversion directly in floating |
| 363 | * point. |
| 364 | */ |
Glenn Randers-Pehrson | 4aa2cd6 | 2010-08-19 16:52:01 -0500 | [diff] [blame] | 365 | return (float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937); |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 366 | } |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 367 | #endif |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 368 | |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 369 | #ifdef PNG_FLOATING_POINT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 370 | float PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 371 | png_get_y_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 372 | { |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 373 | /* To avoid the overflow do the conversion directly in floating |
| 374 | * point. |
| 375 | */ |
Glenn Randers-Pehrson | 4aa2cd6 | 2010-08-19 16:52:01 -0500 | [diff] [blame] | 376 | return (float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937); |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 377 | } |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 378 | #endif |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 379 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 380 | #ifdef PNG_pHYs_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 381 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 382 | png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 383 | png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 384 | { |
| 385 | png_uint_32 retval = 0; |
| 386 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 387 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 388 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 389 | png_debug1(1, "in %s retrieval function", "pHYs"); |
Glenn Randers-Pehrson | da00980 | 2009-08-15 13:25:47 -0500 | [diff] [blame] | 390 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 391 | if (res_x != NULL) |
| 392 | { |
| 393 | *res_x = info_ptr->x_pixels_per_unit; |
| 394 | retval |= PNG_INFO_pHYs; |
| 395 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 396 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 397 | if (res_y != NULL) |
| 398 | { |
| 399 | *res_y = info_ptr->y_pixels_per_unit; |
| 400 | retval |= PNG_INFO_pHYs; |
| 401 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 402 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 403 | if (unit_type != NULL) |
| 404 | { |
| 405 | *unit_type = (int)info_ptr->phys_unit_type; |
| 406 | retval |= PNG_INFO_pHYs; |
Glenn Randers-Pehrson | 4aa2cd6 | 2010-08-19 16:52:01 -0500 | [diff] [blame] | 407 | |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 408 | if (*unit_type == 1) |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 409 | { |
Glenn Randers-Pehrson | a77ef62 | 2000-02-18 13:48:52 -0600 | [diff] [blame] | 410 | if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); |
| 411 | if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 412 | } |
| 413 | } |
| 414 | } |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 415 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 416 | return (retval); |
| 417 | } |
Glenn Randers-Pehrson | 3097f61 | 2001-05-07 14:52:45 -0500 | [diff] [blame] | 418 | #endif /* PNG_pHYs_SUPPORTED */ |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 419 | #endif /* PNG_INCH_CONVERSIONS_SUPPORTED */ |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 420 | |
| 421 | /* png_get_channels really belongs in here, too, but it's been around longer */ |
Glenn Randers-Pehrson | f7d1a17 | 1998-06-06 15:31:35 -0500 | [diff] [blame] | 422 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 423 | #endif /* PNG_EASY_ACCESS_SUPPORTED */ |
| 424 | |
Glenn Randers-Pehrson | 4430b91 | 2012-08-09 22:24:04 -0500 | [diff] [blame] | 425 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 426 | png_byte PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 427 | png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 428 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 429 | if (png_ptr != NULL && info_ptr != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 430 | return(info_ptr->channels); |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 431 | |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 432 | return (0); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 433 | } |
| 434 | |
Glenn Randers-Pehrson | 5d1df4f | 2012-08-10 07:49:44 -0500 | [diff] [blame^] | 435 | #ifdef PNG_READ_SUPPORTED |
Glenn Randers-Pehrson | e600c51 | 2010-08-18 07:25:46 -0500 | [diff] [blame] | 436 | png_const_bytep PNGAPI |
John Bowler | 4f67e40 | 2011-12-28 08:43:37 -0600 | [diff] [blame] | 437 | png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 438 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 439 | if (png_ptr != NULL && info_ptr != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 440 | return(info_ptr->signature); |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 441 | |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 442 | return (NULL); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 443 | } |
Glenn Randers-Pehrson | 4430b91 | 2012-08-09 22:24:04 -0500 | [diff] [blame] | 444 | #endif |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 445 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 446 | #ifdef PNG_bKGD_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 447 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 448 | png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr, |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 449 | png_color_16p *background) |
| 450 | { |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 451 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 452 | && background != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 453 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 454 | png_debug1(1, "in %s retrieval function", "bKGD"); |
Glenn Randers-Pehrson | da00980 | 2009-08-15 13:25:47 -0500 | [diff] [blame] | 455 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 456 | *background = &(info_ptr->background); |
| 457 | return (PNG_INFO_bKGD); |
| 458 | } |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 459 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 460 | return (0); |
| 461 | } |
| 462 | #endif |
| 463 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 464 | #ifdef PNG_cHRM_SUPPORTED |
John Bowler | 736f40f | 2011-08-25 16:19:44 -0500 | [diff] [blame] | 465 | /* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the |
| 466 | * same time to correct the rgb grayscale coefficient defaults obtained from the |
| 467 | * cHRM chunk in 1.5.4 |
| 468 | */ |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 469 | # ifdef PNG_FLOATING_POINT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 470 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 471 | png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 472 | double *white_x, double *white_y, double *red_x, double *red_y, |
| 473 | double *green_x, double *green_y, double *blue_x, double *blue_y) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 474 | { |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 475 | /* Quiet API change: this code used to only return the end points if a cHRM |
| 476 | * chunk was present, but the end points can also come from iCCP or sRGB |
| 477 | * chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and |
| 478 | * the png_set_ APIs merely check that set end points are mutually |
| 479 | * consistent. |
| 480 | */ |
| 481 | if (png_ptr != NULL && info_ptr != NULL && |
| 482 | (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 483 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 484 | png_debug1(1, "in %s retrieval function", "cHRM"); |
Glenn Randers-Pehrson | da00980 | 2009-08-15 13:25:47 -0500 | [diff] [blame] | 485 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 486 | if (white_x != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 487 | *white_x = png_float(png_ptr, |
| 488 | info_ptr->colorspace.end_points_xy.whitex, "cHRM white X"); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 489 | if (white_y != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 490 | *white_y = png_float(png_ptr, |
| 491 | info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y"); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 492 | if (red_x != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 493 | *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx, |
| 494 | "cHRM red X"); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 495 | if (red_y != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 496 | *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy, |
| 497 | "cHRM red Y"); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 498 | if (green_x != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 499 | *green_x = png_float(png_ptr, |
| 500 | info_ptr->colorspace.end_points_xy.greenx, "cHRM green X"); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 501 | if (green_y != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 502 | *green_y = png_float(png_ptr, |
| 503 | info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y"); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 504 | if (blue_x != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 505 | *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex, |
| 506 | "cHRM blue X"); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 507 | if (blue_y != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 508 | *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey, |
| 509 | "cHRM blue Y"); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 510 | return (PNG_INFO_cHRM); |
| 511 | } |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 512 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 513 | return (0); |
| 514 | } |
John Bowler | 736f40f | 2011-08-25 16:19:44 -0500 | [diff] [blame] | 515 | |
| 516 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 517 | png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr, |
John Bowler | 736f40f | 2011-08-25 16:19:44 -0500 | [diff] [blame] | 518 | double *red_X, double *red_Y, double *red_Z, double *green_X, |
| 519 | double *green_Y, double *green_Z, double *blue_X, double *blue_Y, |
| 520 | double *blue_Z) |
| 521 | { |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 522 | if (png_ptr != NULL && info_ptr != NULL && |
| 523 | (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) |
John Bowler | 736f40f | 2011-08-25 16:19:44 -0500 | [diff] [blame] | 524 | { |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 525 | png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)"); |
| 526 | |
John Bowler | 736f40f | 2011-08-25 16:19:44 -0500 | [diff] [blame] | 527 | if (red_X != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 528 | *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.redX, |
| 529 | "cHRM red X"); |
John Bowler | 736f40f | 2011-08-25 16:19:44 -0500 | [diff] [blame] | 530 | if (red_Y != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 531 | *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.redY, |
| 532 | "cHRM red Y"); |
John Bowler | 736f40f | 2011-08-25 16:19:44 -0500 | [diff] [blame] | 533 | if (red_Z != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 534 | *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.redZ, |
| 535 | "cHRM red Z"); |
John Bowler | 736f40f | 2011-08-25 16:19:44 -0500 | [diff] [blame] | 536 | if (green_X != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 537 | *green_X = png_float(png_ptr, |
| 538 | info_ptr->colorspace.end_points_XYZ.greenX, "cHRM green X"); |
John Bowler | 736f40f | 2011-08-25 16:19:44 -0500 | [diff] [blame] | 539 | if (green_Y != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 540 | *green_Y = png_float(png_ptr, |
| 541 | info_ptr->colorspace.end_points_XYZ.greenY, "cHRM green Y"); |
John Bowler | 736f40f | 2011-08-25 16:19:44 -0500 | [diff] [blame] | 542 | if (green_Z != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 543 | *green_Z = png_float(png_ptr, |
| 544 | info_ptr->colorspace.end_points_XYZ.greenZ, "cHRM green Z"); |
John Bowler | 736f40f | 2011-08-25 16:19:44 -0500 | [diff] [blame] | 545 | if (blue_X != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 546 | *blue_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.blueX, |
| 547 | "cHRM blue X"); |
John Bowler | 736f40f | 2011-08-25 16:19:44 -0500 | [diff] [blame] | 548 | if (blue_Y != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 549 | *blue_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.blueY, |
| 550 | "cHRM blue Y"); |
John Bowler | 736f40f | 2011-08-25 16:19:44 -0500 | [diff] [blame] | 551 | if (blue_Z != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 552 | *blue_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.blueZ, |
| 553 | "cHRM blue Z"); |
John Bowler | 736f40f | 2011-08-25 16:19:44 -0500 | [diff] [blame] | 554 | return (PNG_INFO_cHRM); |
| 555 | } |
| 556 | |
| 557 | return (0); |
| 558 | } |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 559 | # endif |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 560 | |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 561 | # ifdef PNG_FIXED_POINT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 562 | png_uint_32 PNGAPI |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 563 | png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, |
| 564 | png_fixed_point *int_red_X, png_fixed_point *int_red_Y, |
| 565 | png_fixed_point *int_red_Z, png_fixed_point *int_green_X, |
| 566 | png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, |
| 567 | png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, |
| 568 | png_fixed_point *int_blue_Z) |
| 569 | { |
| 570 | if (png_ptr != NULL && info_ptr != NULL && |
| 571 | (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) |
| 572 | { |
| 573 | png_debug1(1, "in %s retrieval function", "cHRM_XYZ"); |
| 574 | |
| 575 | if (int_red_X != NULL) |
| 576 | *int_red_X = info_ptr->colorspace.end_points_XYZ.redX; |
| 577 | if (int_red_Y != NULL) |
| 578 | *int_red_Y = info_ptr->colorspace.end_points_XYZ.redY; |
| 579 | if (int_red_Z != NULL) |
| 580 | *int_red_Z = info_ptr->colorspace.end_points_XYZ.redZ; |
| 581 | if (int_green_X != NULL) |
| 582 | *int_green_X = info_ptr->colorspace.end_points_XYZ.greenX; |
| 583 | if (int_green_Y != NULL) |
| 584 | *int_green_Y = info_ptr->colorspace.end_points_XYZ.greenY; |
| 585 | if (int_green_Z != NULL) |
| 586 | *int_green_Z = info_ptr->colorspace.end_points_XYZ.greenZ; |
| 587 | if (int_blue_X != NULL) |
| 588 | *int_blue_X = info_ptr->colorspace.end_points_XYZ.blueX; |
| 589 | if (int_blue_Y != NULL) |
| 590 | *int_blue_Y = info_ptr->colorspace.end_points_XYZ.blueY; |
| 591 | if (int_blue_Z != NULL) |
| 592 | *int_blue_Z = info_ptr->colorspace.end_points_XYZ.blueZ; |
| 593 | return (PNG_INFO_cHRM); |
| 594 | } |
| 595 | |
| 596 | return (0); |
| 597 | } |
| 598 | |
| 599 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 600 | png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 601 | png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, |
| 602 | png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, |
| 603 | png_fixed_point *blue_x, png_fixed_point *blue_y) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 604 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 605 | png_debug1(1, "in %s retrieval function", "cHRM"); |
| 606 | |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 607 | if (png_ptr != NULL && info_ptr != NULL && |
| 608 | (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 609 | { |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 610 | if (white_x != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 611 | *white_x = info_ptr->colorspace.end_points_xy.whitex; |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 612 | if (white_y != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 613 | *white_y = info_ptr->colorspace.end_points_xy.whitey; |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 614 | if (red_x != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 615 | *red_x = info_ptr->colorspace.end_points_xy.redx; |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 616 | if (red_y != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 617 | *red_y = info_ptr->colorspace.end_points_xy.redy; |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 618 | if (green_x != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 619 | *green_x = info_ptr->colorspace.end_points_xy.greenx; |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 620 | if (green_y != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 621 | *green_y = info_ptr->colorspace.end_points_xy.greeny; |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 622 | if (blue_x != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 623 | *blue_x = info_ptr->colorspace.end_points_xy.bluex; |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 624 | if (blue_y != NULL) |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 625 | *blue_y = info_ptr->colorspace.end_points_xy.bluey; |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 626 | return (PNG_INFO_cHRM); |
| 627 | } |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 628 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 629 | return (0); |
| 630 | } |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 631 | # endif |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 632 | #endif |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 633 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 634 | #ifdef PNG_gAMA_SUPPORTED |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 635 | # ifdef PNG_FIXED_POINT_SUPPORTED |
| 636 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 637 | png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 638 | png_fixed_point *file_gamma) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 639 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 640 | png_debug1(1, "in %s retrieval function", "gAMA"); |
| 641 | |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 642 | if (png_ptr != NULL && info_ptr != NULL && |
| 643 | (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) && |
| 644 | file_gamma != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 645 | { |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 646 | *file_gamma = info_ptr->colorspace.gamma; |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 647 | return (PNG_INFO_gAMA); |
| 648 | } |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 649 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 650 | return (0); |
| 651 | } |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 652 | # endif |
| 653 | |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 654 | # ifdef PNG_FLOATING_POINT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 655 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 656 | png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | b86b492 | 2011-01-21 23:12:51 -0600 | [diff] [blame] | 657 | double *file_gamma) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 658 | { |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 659 | png_debug1(1, "in %s retrieval function", "gAMA(float)"); |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 660 | |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 661 | if (png_ptr != NULL && info_ptr != NULL && |
| 662 | (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) && |
| 663 | file_gamma != NULL) |
| 664 | { |
| 665 | *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma, |
| 666 | "png_get_gAMA"); |
| 667 | return (PNG_INFO_gAMA); |
| 668 | } |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 669 | |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 670 | return (0); |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 671 | } |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 672 | # endif |
Glenn Randers-Pehrson | 6942d53 | 2000-05-01 09:31:54 -0500 | [diff] [blame] | 673 | #endif |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 674 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 675 | #ifdef PNG_sRGB_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 676 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 677 | png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | b86b492 | 2011-01-21 23:12:51 -0600 | [diff] [blame] | 678 | int *file_srgb_intent) |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 679 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 680 | png_debug1(1, "in %s retrieval function", "sRGB"); |
| 681 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 682 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 683 | && file_srgb_intent != NULL) |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 684 | { |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 685 | *file_srgb_intent = info_ptr->colorspace.rendering_intent; |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 686 | return (PNG_INFO_sRGB); |
| 687 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 688 | |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 689 | return (0); |
| 690 | } |
| 691 | #endif |
| 692 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 693 | #ifdef PNG_iCCP_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 694 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 695 | png_get_iCCP(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 696 | png_charpp name, int *compression_type, |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 697 | png_bytepp profile, png_uint_32 *proflen) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 698 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 699 | png_debug1(1, "in %s retrieval function", "iCCP"); |
| 700 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 701 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) |
John Bowler | 88bcdc2 | 2011-11-04 20:11:16 -0500 | [diff] [blame] | 702 | && name != NULL && compression_type != NULL && profile != NULL && |
| 703 | proflen != NULL) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 704 | { |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 705 | *name = info_ptr->iccp_name; |
| 706 | *profile = info_ptr->iccp_profile; |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 707 | *proflen = png_get_uint_32(info_ptr->iccp_profile); |
| 708 | /* This is somewhat irrelevant since the profile data returned has |
| 709 | * actually been uncompressed. |
Glenn Randers-Pehrson | 4bb4d01 | 2009-05-20 12:45:29 -0500 | [diff] [blame] | 710 | */ |
John Bowler | b11b31a | 2012-03-21 07:55:46 -0500 | [diff] [blame] | 711 | *compression_type = PNG_COMPRESSION_TYPE_BASE; |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 712 | return (PNG_INFO_iCCP); |
| 713 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 714 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 715 | return (0); |
| 716 | } |
| 717 | #endif |
| 718 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 719 | #ifdef PNG_sPLT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 720 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 721 | png_get_sPLT(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 722 | png_sPLT_tpp spalettes) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 723 | { |
| 724 | if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 725 | { |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 726 | *spalettes = info_ptr->splt_palettes; |
| 727 | return ((png_uint_32)info_ptr->splt_palettes_num); |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 728 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 729 | |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 730 | return (0); |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 731 | } |
| 732 | #endif |
| 733 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 734 | #ifdef PNG_hIST_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 735 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 736 | png_get_hIST(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | b86b492 | 2011-01-21 23:12:51 -0600 | [diff] [blame] | 737 | png_uint_16p *hist) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 738 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 739 | png_debug1(1, "in %s retrieval function", "hIST"); |
| 740 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 741 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 742 | && hist != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 743 | { |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 744 | *hist = info_ptr->hist; |
| 745 | return (PNG_INFO_hIST); |
| 746 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 747 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 748 | return (0); |
| 749 | } |
| 750 | #endif |
| 751 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 752 | png_uint_32 PNGAPI |
John Bowler | 4f67e40 | 2011-12-28 08:43:37 -0600 | [diff] [blame] | 753 | png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 754 | png_uint_32 *width, png_uint_32 *height, int *bit_depth, |
| 755 | int *color_type, int *interlace_type, int *compression_type, |
| 756 | int *filter_type) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 757 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 758 | png_debug1(1, "in %s retrieval function", "IHDR"); |
| 759 | |
Glenn Randers-Pehrson | 134bbe4 | 2009-09-24 18:10:49 -0500 | [diff] [blame] | 760 | if (png_ptr == NULL || info_ptr == NULL || width == NULL || |
| 761 | height == NULL || bit_depth == NULL || color_type == NULL) |
| 762 | return (0); |
| 763 | |
| 764 | *width = info_ptr->width; |
| 765 | *height = info_ptr->height; |
| 766 | *bit_depth = info_ptr->bit_depth; |
| 767 | *color_type = info_ptr->color_type; |
| 768 | |
| 769 | if (compression_type != NULL) |
Glenn Randers-Pehrson | 134bbe4 | 2009-09-24 18:10:49 -0500 | [diff] [blame] | 770 | *compression_type = info_ptr->compression_type; |
Glenn Randers-Pehrson | 134bbe4 | 2009-09-24 18:10:49 -0500 | [diff] [blame] | 771 | |
| 772 | if (filter_type != NULL) |
Glenn Randers-Pehrson | 134bbe4 | 2009-09-24 18:10:49 -0500 | [diff] [blame] | 773 | *filter_type = info_ptr->filter_type; |
Glenn Randers-Pehrson | 134bbe4 | 2009-09-24 18:10:49 -0500 | [diff] [blame] | 774 | |
| 775 | if (interlace_type != NULL) |
Glenn Randers-Pehrson | 134bbe4 | 2009-09-24 18:10:49 -0500 | [diff] [blame] | 776 | *interlace_type = info_ptr->interlace_type; |
Glenn Randers-Pehrson | 134bbe4 | 2009-09-24 18:10:49 -0500 | [diff] [blame] | 777 | |
Glenn Randers-Pehrson | b35a745 | 2009-09-30 23:12:13 -0500 | [diff] [blame] | 778 | /* This is redundant if we can be sure that the info_ptr values were all |
| 779 | * assigned in png_set_IHDR(). We do the check anyhow in case an |
| 780 | * application has ignored our advice not to mess with the members |
| 781 | * of info_ptr directly. |
| 782 | */ |
Glenn Randers-Pehrson | ad41b88 | 2011-12-22 07:31:13 -0600 | [diff] [blame] | 783 | png_check_IHDR(png_ptr, info_ptr->width, info_ptr->height, |
Glenn Randers-Pehrson | b35a745 | 2009-09-30 23:12:13 -0500 | [diff] [blame] | 784 | info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, |
| 785 | info_ptr->compression_type, info_ptr->filter_type); |
Glenn Randers-Pehrson | 134bbe4 | 2009-09-24 18:10:49 -0500 | [diff] [blame] | 786 | |
| 787 | return (1); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 788 | } |
| 789 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 790 | #ifdef PNG_oFFs_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 791 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 792 | png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 793 | png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 794 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 795 | png_debug1(1, "in %s retrieval function", "oFFs"); |
| 796 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 797 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 798 | && offset_x != NULL && offset_y != NULL && unit_type != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 799 | { |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 800 | *offset_x = info_ptr->x_offset; |
| 801 | *offset_y = info_ptr->y_offset; |
| 802 | *unit_type = (int)info_ptr->offset_unit_type; |
| 803 | return (PNG_INFO_oFFs); |
| 804 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 805 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 806 | return (0); |
| 807 | } |
| 808 | #endif |
| 809 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 810 | #ifdef PNG_pCAL_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 811 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 812 | png_get_pCAL(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 813 | png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, |
| 814 | png_charp *units, png_charpp *params) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 815 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 816 | png_debug1(1, "in %s retrieval function", "pCAL"); |
| 817 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 818 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 819 | && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && |
| 820 | nparams != NULL && units != NULL && params != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 821 | { |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 822 | *purpose = info_ptr->pcal_purpose; |
| 823 | *X0 = info_ptr->pcal_X0; |
| 824 | *X1 = info_ptr->pcal_X1; |
| 825 | *type = (int)info_ptr->pcal_type; |
| 826 | *nparams = (int)info_ptr->pcal_nparams; |
| 827 | *units = info_ptr->pcal_units; |
| 828 | *params = info_ptr->pcal_params; |
| 829 | return (PNG_INFO_pCAL); |
| 830 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 831 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 832 | return (0); |
| 833 | } |
| 834 | #endif |
| 835 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 836 | #ifdef PNG_sCAL_SUPPORTED |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 837 | # ifdef PNG_FIXED_POINT_SUPPORTED |
John Bowler | 29fca0d | 2011-12-24 07:57:43 -0600 | [diff] [blame] | 838 | # if (defined PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ |
| 839 | (defined PNG_FLOATING_POINT_SUPPORTED) |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 840 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 841 | png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 842 | int *unit, png_fixed_point *width, png_fixed_point *height) |
| 843 | { |
| 844 | if (png_ptr != NULL && info_ptr != NULL && |
| 845 | (info_ptr->valid & PNG_INFO_sCAL)) |
| 846 | { |
| 847 | *unit = info_ptr->scal_unit; |
John Bowler | 29fca0d | 2011-12-24 07:57:43 -0600 | [diff] [blame] | 848 | /*TODO: make this work without FP support; the API is currently eliminated |
| 849 | * if neither floating point APIs nor internal floating point arithmetic |
| 850 | * are enabled. |
| 851 | */ |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 852 | *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width"); |
| 853 | *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height), |
| 854 | "sCAL height"); |
| 855 | return (PNG_INFO_sCAL); |
| 856 | } |
| 857 | |
| 858 | return(0); |
| 859 | } |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 860 | # endif /* FLOATING_ARITHMETIC */ |
| 861 | # endif /* FIXED_POINT */ |
| 862 | # ifdef PNG_FLOATING_POINT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 863 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 864 | png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 865 | int *unit, double *width, double *height) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 866 | { |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 867 | if (png_ptr != NULL && info_ptr != NULL && |
| 868 | (info_ptr->valid & PNG_INFO_sCAL)) |
| 869 | { |
| 870 | *unit = info_ptr->scal_unit; |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 871 | *width = atof(info_ptr->scal_s_width); |
| 872 | *height = atof(info_ptr->scal_s_height); |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 873 | return (PNG_INFO_sCAL); |
| 874 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 875 | |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 876 | return(0); |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 877 | } |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 878 | # endif /* FLOATING POINT */ |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 879 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 880 | png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | 4aa2cd6 | 2010-08-19 16:52:01 -0500 | [diff] [blame] | 881 | int *unit, png_charpp width, png_charpp height) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 882 | { |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 883 | if (png_ptr != NULL && info_ptr != NULL && |
| 884 | (info_ptr->valid & PNG_INFO_sCAL)) |
| 885 | { |
| 886 | *unit = info_ptr->scal_unit; |
| 887 | *width = info_ptr->scal_s_width; |
| 888 | *height = info_ptr->scal_s_height; |
| 889 | return (PNG_INFO_sCAL); |
| 890 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 891 | |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 892 | return(0); |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 893 | } |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 894 | #endif /* sCAL */ |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 895 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 896 | #ifdef PNG_pHYs_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 897 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 898 | png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 899 | png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 900 | { |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 901 | png_uint_32 retval = 0; |
| 902 | |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 903 | png_debug1(1, "in %s retrieval function", "pHYs"); |
| 904 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 905 | if (png_ptr != NULL && info_ptr != NULL && |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 906 | (info_ptr->valid & PNG_INFO_pHYs)) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 907 | { |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 908 | if (res_x != NULL) |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 909 | { |
| 910 | *res_x = info_ptr->x_pixels_per_unit; |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 911 | retval |= PNG_INFO_pHYs; |
| 912 | } |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 913 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 914 | if (res_y != NULL) |
| 915 | { |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 916 | *res_y = info_ptr->y_pixels_per_unit; |
| 917 | retval |= PNG_INFO_pHYs; |
| 918 | } |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 919 | |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 920 | if (unit_type != NULL) |
| 921 | { |
| 922 | *unit_type = (int)info_ptr->phys_unit_type; |
| 923 | retval |= PNG_INFO_pHYs; |
| 924 | } |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 925 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 926 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 927 | return (retval); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 928 | } |
Glenn Randers-Pehrson | 5c5f593 | 2010-10-23 10:14:42 -0500 | [diff] [blame] | 929 | #endif /* pHYs */ |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 930 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 931 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 932 | png_get_PLTE(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | b86b492 | 2011-01-21 23:12:51 -0600 | [diff] [blame] | 933 | png_colorp *palette, int *num_palette) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 934 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 935 | png_debug1(1, "in %s retrieval function", "PLTE"); |
| 936 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 937 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) |
| 938 | && palette != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 939 | { |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 940 | *palette = info_ptr->palette; |
| 941 | *num_palette = info_ptr->num_palette; |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 942 | png_debug1(3, "num_palette = %d", *num_palette); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 943 | return (PNG_INFO_PLTE); |
| 944 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 945 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 946 | return (0); |
| 947 | } |
| 948 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 949 | #ifdef PNG_sBIT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 950 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 951 | png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr, |
Glenn Randers-Pehrson | b86b492 | 2011-01-21 23:12:51 -0600 | [diff] [blame] | 952 | png_color_8p *sig_bit) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 953 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 954 | png_debug1(1, "in %s retrieval function", "sBIT"); |
| 955 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 956 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 957 | && sig_bit != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 958 | { |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 959 | *sig_bit = &(info_ptr->sig_bit); |
| 960 | return (PNG_INFO_sBIT); |
| 961 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 962 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 963 | return (0); |
| 964 | } |
| 965 | #endif |
| 966 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 967 | #ifdef PNG_TEXT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 968 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 969 | png_get_text(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | b86b492 | 2011-01-21 23:12:51 -0600 | [diff] [blame] | 970 | png_textp *text_ptr, int *num_text) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 971 | { |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 972 | if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 973 | { |
Glenn Randers-Pehrson | bb5cb14 | 2011-09-22 12:41:58 -0500 | [diff] [blame] | 974 | png_debug1(1, "in 0x%lx retrieval function", |
| 975 | (unsigned long)png_ptr->chunk_name); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 976 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 977 | if (text_ptr != NULL) |
| 978 | *text_ptr = info_ptr->text; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 979 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 980 | if (num_text != NULL) |
| 981 | *num_text = info_ptr->num_text; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 982 | |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 983 | return ((png_uint_32)info_ptr->num_text); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 984 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 985 | |
Glenn Randers-Pehrson | a77ef62 | 2000-02-18 13:48:52 -0600 | [diff] [blame] | 986 | if (num_text != NULL) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 987 | *num_text = 0; |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 988 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 989 | return(0); |
| 990 | } |
| 991 | #endif |
| 992 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 993 | #ifdef PNG_tIME_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 994 | png_uint_32 PNGAPI |
John Bowler | 4f67e40 | 2011-12-28 08:43:37 -0600 | [diff] [blame] | 995 | png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr, |
| 996 | png_timep *mod_time) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 997 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 998 | png_debug1(1, "in %s retrieval function", "tIME"); |
| 999 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1000 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) |
| 1001 | && mod_time != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 1002 | { |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 1003 | *mod_time = &(info_ptr->mod_time); |
| 1004 | return (PNG_INFO_tIME); |
| 1005 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 1006 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 1007 | return (0); |
| 1008 | } |
| 1009 | #endif |
| 1010 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 1011 | #ifdef PNG_tRNS_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 1012 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 1013 | png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 1014 | png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 1015 | { |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 1016 | png_uint_32 retval = 0; |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1017 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 1018 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 1019 | png_debug1(1, "in %s retrieval function", "tRNS"); |
Glenn Randers-Pehrson | da00980 | 2009-08-15 13:25:47 -0500 | [diff] [blame] | 1020 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 1021 | if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 1022 | { |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 1023 | if (trans_alpha != NULL) |
| 1024 | { |
| 1025 | *trans_alpha = info_ptr->trans_alpha; |
| 1026 | retval |= PNG_INFO_tRNS; |
| 1027 | } |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 1028 | |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 1029 | if (trans_color != NULL) |
| 1030 | *trans_color = &(info_ptr->trans_color); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 1031 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 1032 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 1033 | else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 1034 | { |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 1035 | if (trans_color != NULL) |
| 1036 | { |
| 1037 | *trans_color = &(info_ptr->trans_color); |
| 1038 | retval |= PNG_INFO_tRNS; |
| 1039 | } |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 1040 | |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 1041 | if (trans_alpha != NULL) |
| 1042 | *trans_alpha = NULL; |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 1043 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 1044 | |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 1045 | if (num_trans != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 1046 | { |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 1047 | *num_trans = info_ptr->num_trans; |
| 1048 | retval |= PNG_INFO_tRNS; |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 1049 | } |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 1050 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 1051 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 1052 | return (retval); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 1053 | } |
| 1054 | #endif |
| 1055 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 1056 | #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED |
Glenn Randers-Pehrson | 4aa2cd6 | 2010-08-19 16:52:01 -0500 | [diff] [blame] | 1057 | int PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 1058 | png_get_unknown_chunks(png_const_structrp png_ptr, png_const_inforp info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 1059 | png_unknown_chunkpp unknowns) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 1060 | { |
| 1061 | if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL) |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 1062 | { |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 1063 | *unknowns = info_ptr->unknown_chunks; |
Glenn Randers-Pehrson | 4aa2cd6 | 2010-08-19 16:52:01 -0500 | [diff] [blame] | 1064 | return info_ptr->unknown_chunks_num; |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 1065 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame] | 1066 | |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 1067 | return (0); |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 1068 | } |
| 1069 | #endif |
| 1070 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 1071 | #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 1072 | png_byte PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 1073 | png_get_rgb_to_gray_status (png_const_structrp png_ptr) |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 1074 | { |
Glenn Randers-Pehrson | a565f0e | 2010-03-06 08:24:45 -0600 | [diff] [blame] | 1075 | return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0); |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 1076 | } |
| 1077 | #endif |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1078 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 1079 | #ifdef PNG_USER_CHUNKS_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 1080 | png_voidp PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 1081 | png_get_user_chunk_ptr(png_const_structrp png_ptr) |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1082 | { |
Glenn Randers-Pehrson | a565f0e | 2010-03-06 08:24:45 -0600 | [diff] [blame] | 1083 | return (png_ptr ? png_ptr->user_chunk_ptr : NULL); |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1084 | } |
| 1085 | #endif |
| 1086 | |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 1087 | png_size_t PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 1088 | png_get_compression_buffer_size(png_const_structrp png_ptr) |
Glenn Randers-Pehrson | 228bd39 | 2000-04-23 23:14:02 -0500 | [diff] [blame] | 1089 | { |
John Bowler | b5d0051 | 2012-03-09 09:15:18 -0600 | [diff] [blame] | 1090 | if (png_ptr == NULL) |
| 1091 | return 0; |
| 1092 | |
| 1093 | # ifdef PNG_WRITE_SUPPORTED |
| 1094 | if (png_ptr->mode & PNG_IS_READ_STRUCT) |
| 1095 | # endif |
| 1096 | { |
| 1097 | # ifdef PNG_SEQUENTIAL_READ_SUPPORTED |
| 1098 | return png_ptr->IDAT_read_size; |
| 1099 | # else |
| 1100 | return PNG_IDAT_READ_SIZE; |
| 1101 | # endif |
| 1102 | } |
| 1103 | |
| 1104 | # ifdef PNG_WRITE_SUPPORTED |
| 1105 | else |
| 1106 | return png_ptr->zbuffer_size; |
| 1107 | # endif |
Glenn Randers-Pehrson | 228bd39 | 2000-04-23 23:14:02 -0500 | [diff] [blame] | 1108 | } |
Glenn Randers-Pehrson | e68f5a3 | 2001-05-14 09:20:53 -0500 | [diff] [blame] | 1109 | |
Glenn Randers-Pehrson | 272489d | 2004-08-04 06:34:52 -0500 | [diff] [blame] | 1110 | #ifdef PNG_SET_USER_LIMITS_SUPPORTED |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 1111 | /* These functions were added to libpng 1.2.6 and were enabled |
| 1112 | * by default in libpng-1.4.0 */ |
Glenn Randers-Pehrson | 272489d | 2004-08-04 06:34:52 -0500 | [diff] [blame] | 1113 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 1114 | png_get_user_width_max (png_const_structrp png_ptr) |
Glenn Randers-Pehrson | 272489d | 2004-08-04 06:34:52 -0500 | [diff] [blame] | 1115 | { |
Glenn Randers-Pehrson | a565f0e | 2010-03-06 08:24:45 -0600 | [diff] [blame] | 1116 | return (png_ptr ? png_ptr->user_width_max : 0); |
Glenn Randers-Pehrson | 272489d | 2004-08-04 06:34:52 -0500 | [diff] [blame] | 1117 | } |
Glenn Randers-Pehrson | 4aa2cd6 | 2010-08-19 16:52:01 -0500 | [diff] [blame] | 1118 | |
Glenn Randers-Pehrson | 272489d | 2004-08-04 06:34:52 -0500 | [diff] [blame] | 1119 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 1120 | png_get_user_height_max (png_const_structrp png_ptr) |
Glenn Randers-Pehrson | 272489d | 2004-08-04 06:34:52 -0500 | [diff] [blame] | 1121 | { |
Glenn Randers-Pehrson | a565f0e | 2010-03-06 08:24:45 -0600 | [diff] [blame] | 1122 | return (png_ptr ? png_ptr->user_height_max : 0); |
Glenn Randers-Pehrson | 272489d | 2004-08-04 06:34:52 -0500 | [diff] [blame] | 1123 | } |
Glenn Randers-Pehrson | 4aa2cd6 | 2010-08-19 16:52:01 -0500 | [diff] [blame] | 1124 | |
Glenn Randers-Pehrson | 17ca340 | 2009-11-09 06:51:16 -0600 | [diff] [blame] | 1125 | /* This function was added to libpng 1.4.0 */ |
Glenn Randers-Pehrson | 800d1e9 | 2008-08-20 17:25:21 -0500 | [diff] [blame] | 1126 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 1127 | png_get_chunk_cache_max (png_const_structrp png_ptr) |
Glenn Randers-Pehrson | 800d1e9 | 2008-08-20 17:25:21 -0500 | [diff] [blame] | 1128 | { |
Glenn Randers-Pehrson | a565f0e | 2010-03-06 08:24:45 -0600 | [diff] [blame] | 1129 | return (png_ptr ? png_ptr->user_chunk_cache_max : 0); |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 1130 | } |
Glenn Randers-Pehrson | 4aa2cd6 | 2010-08-19 16:52:01 -0500 | [diff] [blame] | 1131 | |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 1132 | /* This function was added to libpng 1.4.1 */ |
Glenn Randers-Pehrson | 7a5be53 | 2010-02-14 07:16:19 -0600 | [diff] [blame] | 1133 | png_alloc_size_t PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 1134 | png_get_chunk_malloc_max (png_const_structrp png_ptr) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 1135 | { |
Glenn Randers-Pehrson | a565f0e | 2010-03-06 08:24:45 -0600 | [diff] [blame] | 1136 | return (png_ptr ? png_ptr->user_chunk_malloc_max : 0); |
Glenn Randers-Pehrson | 800d1e9 | 2008-08-20 17:25:21 -0500 | [diff] [blame] | 1137 | } |
Glenn Randers-Pehrson | 272489d | 2004-08-04 06:34:52 -0500 | [diff] [blame] | 1138 | #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ |
Glenn Randers-Pehrson | d60c886 | 2009-06-15 21:56:14 -0500 | [diff] [blame] | 1139 | |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 1140 | /* These functions were added to libpng 1.4.0 */ |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 1141 | #ifdef PNG_IO_STATE_SUPPORTED |
| 1142 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 1143 | png_get_io_state (png_const_structrp png_ptr) |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 1144 | { |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 1145 | return png_ptr->io_state; |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 1146 | } |
| 1147 | |
Glenn Randers-Pehrson | a63dbed | 2011-01-22 08:51:19 -0600 | [diff] [blame] | 1148 | png_uint_32 PNGAPI |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 1149 | png_get_io_chunk_type (png_const_structrp png_ptr) |
Glenn Randers-Pehrson | a63dbed | 2011-01-22 08:51:19 -0600 | [diff] [blame] | 1150 | { |
Glenn Randers-Pehrson | bb5cb14 | 2011-09-22 12:41:58 -0500 | [diff] [blame] | 1151 | return png_ptr->chunk_name; |
Glenn Randers-Pehrson | a63dbed | 2011-01-22 08:51:19 -0600 | [diff] [blame] | 1152 | } |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 1153 | #endif /* ?PNG_IO_STATE_SUPPORTED */ |
| 1154 | |
Glenn Randers-Pehrson | 9c3ab68 | 2006-02-20 22:09:05 -0600 | [diff] [blame] | 1155 | #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ |