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 | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 4 | * Last changed in libpng 1.4.1 [May 6, 2010] |
Glenn Randers-Pehrson | e69b55d | 2010-01-01 10:29:06 -0600 | [diff] [blame] | 5 | * Copyright (c) 1998-2010 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 |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 20 | png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) |
| 21 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 22 | if (png_ptr != NULL && info_ptr != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 23 | return(info_ptr->valid & flag); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 24 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 25 | else |
| 26 | return(0); |
| 27 | } |
| 28 | |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 29 | png_size_t PNGAPI |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 30 | png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) |
| 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 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 35 | else |
| 36 | return(0); |
| 37 | } |
| 38 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 39 | #ifdef PNG_INFO_IMAGE_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 40 | png_bytepp PNGAPI |
Glenn Randers-Pehrson | a77ef62 | 2000-02-18 13:48:52 -0600 | [diff] [blame] | 41 | png_get_rows(png_structp png_ptr, png_infop info_ptr) |
| 42 | { |
| 43 | if (png_ptr != NULL && info_ptr != NULL) |
| 44 | return(info_ptr->row_pointers); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 45 | |
Glenn Randers-Pehrson | a77ef62 | 2000-02-18 13:48:52 -0600 | [diff] [blame] | 46 | else |
| 47 | return(0); |
| 48 | } |
| 49 | #endif |
| 50 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 51 | #ifdef PNG_EASY_ACCESS_SUPPORTED |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 52 | /* Easy access to info, added in libpng-0.99 */ |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 53 | png_uint_32 PNGAPI |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 54 | png_get_image_width(png_structp png_ptr, png_infop info_ptr) |
| 55 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 56 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 57 | return info_ptr->width; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 58 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 59 | return (0); |
| 60 | } |
| 61 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 62 | png_uint_32 PNGAPI |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 63 | png_get_image_height(png_structp png_ptr, png_infop info_ptr) |
| 64 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 65 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 66 | return info_ptr->height; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 67 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 68 | return (0); |
| 69 | } |
| 70 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 71 | png_byte PNGAPI |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 72 | png_get_bit_depth(png_structp png_ptr, png_infop info_ptr) |
| 73 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 74 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 75 | return info_ptr->bit_depth; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 76 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 77 | return (0); |
| 78 | } |
| 79 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 80 | png_byte PNGAPI |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 81 | png_get_color_type(png_structp png_ptr, png_infop info_ptr) |
| 82 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 83 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 84 | return info_ptr->color_type; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 85 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 86 | return (0); |
| 87 | } |
| 88 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 89 | png_byte PNGAPI |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 90 | png_get_filter_type(png_structp png_ptr, png_infop info_ptr) |
| 91 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 92 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 93 | return info_ptr->filter_type; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 94 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 95 | return (0); |
| 96 | } |
| 97 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 98 | png_byte PNGAPI |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 99 | png_get_interlace_type(png_structp png_ptr, png_infop info_ptr) |
| 100 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 101 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 102 | return info_ptr->interlace_type; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 103 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 104 | return (0); |
| 105 | } |
| 106 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 107 | png_byte PNGAPI |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 108 | png_get_compression_type(png_structp png_ptr, png_infop info_ptr) |
| 109 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 110 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 111 | return info_ptr->compression_type; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 112 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 113 | return (0); |
| 114 | } |
| 115 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 116 | png_uint_32 PNGAPI |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 117 | png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) |
| 118 | { |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 119 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 120 | #ifdef PNG_pHYs_SUPPORTED |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 121 | if (info_ptr->valid & PNG_INFO_pHYs) |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 122 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 123 | png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter"); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 124 | |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 125 | if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 126 | return (0); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 127 | |
Glenn Randers-Pehrson | d8eb62f | 2009-05-30 20:19:20 -0500 | [diff] [blame] | 128 | else |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 129 | return (info_ptr->x_pixels_per_unit); |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 130 | } |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 131 | #else |
| 132 | return (0); |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 133 | #endif |
| 134 | return (0); |
| 135 | } |
| 136 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 137 | png_uint_32 PNGAPI |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 138 | png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) |
| 139 | { |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 140 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 141 | #ifdef PNG_pHYs_SUPPORTED |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 142 | if (info_ptr->valid & PNG_INFO_pHYs) |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 143 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 144 | png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter"); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 145 | |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 146 | if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 147 | return (0); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 148 | |
Glenn Randers-Pehrson | d8eb62f | 2009-05-30 20:19:20 -0500 | [diff] [blame] | 149 | else |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 150 | return (info_ptr->y_pixels_per_unit); |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 151 | } |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 152 | #else |
| 153 | return (0); |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 154 | #endif |
| 155 | return (0); |
| 156 | } |
| 157 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 158 | png_uint_32 PNGAPI |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 159 | png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) |
| 160 | { |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 161 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 162 | #ifdef PNG_pHYs_SUPPORTED |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 163 | if (info_ptr->valid & PNG_INFO_pHYs) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 164 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 165 | 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] | 166 | |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 167 | if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER || |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 168 | info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) |
| 169 | return (0); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 170 | |
Glenn Randers-Pehrson | d8eb62f | 2009-05-30 20:19:20 -0500 | [diff] [blame] | 171 | else |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 172 | return (info_ptr->x_pixels_per_unit); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 173 | } |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 174 | #else |
| 175 | return (0); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 176 | #endif |
| 177 | return (0); |
| 178 | } |
| 179 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 180 | #ifdef PNG_FLOATING_POINT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 181 | float PNGAPI |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 182 | png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 183 | { |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 184 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 185 | #ifdef PNG_pHYs_SUPPORTED |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 186 | |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 187 | if (info_ptr->valid & PNG_INFO_pHYs) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 188 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 189 | png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); |
Glenn Randers-Pehrson | da00980 | 2009-08-15 13:25:47 -0500 | [diff] [blame] | 190 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 191 | if (info_ptr->x_pixels_per_unit == 0) |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 192 | return ((float)0.0); |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 193 | |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 194 | else |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 195 | return ((float)((float)info_ptr->y_pixels_per_unit |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 196 | /(float)info_ptr->x_pixels_per_unit)); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 197 | } |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 198 | #else |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 199 | return (0.0); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 200 | #endif |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 201 | return ((float)0.0); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 202 | } |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 203 | #endif |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 204 | |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 205 | png_int_32 PNGAPI |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 206 | png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) |
| 207 | { |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 208 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 209 | #ifdef PNG_oFFs_SUPPORTED |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 210 | |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 211 | if (info_ptr->valid & PNG_INFO_oFFs) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 212 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 213 | 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] | 214 | |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 215 | if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 216 | return (0); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 217 | |
Glenn Randers-Pehrson | d8eb62f | 2009-05-30 20:19:20 -0500 | [diff] [blame] | 218 | else |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 219 | return (info_ptr->x_offset); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 220 | } |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 221 | #else |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 222 | return (0); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 223 | #endif |
| 224 | return (0); |
| 225 | } |
| 226 | |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 227 | png_int_32 PNGAPI |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 228 | png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr) |
| 229 | { |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 230 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 231 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 232 | #ifdef PNG_oFFs_SUPPORTED |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 233 | if (info_ptr->valid & PNG_INFO_oFFs) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 234 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 235 | 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] | 236 | |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 237 | if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 238 | return (0); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 239 | |
Glenn Randers-Pehrson | d8eb62f | 2009-05-30 20:19:20 -0500 | [diff] [blame] | 240 | else |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 241 | return (info_ptr->y_offset); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 242 | } |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 243 | #else |
| 244 | return (0); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 245 | #endif |
| 246 | return (0); |
| 247 | } |
| 248 | |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 249 | png_int_32 PNGAPI |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 250 | png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr) |
| 251 | { |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 252 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 253 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 254 | #ifdef PNG_oFFs_SUPPORTED |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 255 | if (info_ptr->valid & PNG_INFO_oFFs) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 256 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 257 | 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] | 258 | |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 259 | if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 260 | return (0); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 261 | |
Glenn Randers-Pehrson | d8eb62f | 2009-05-30 20:19:20 -0500 | [diff] [blame] | 262 | else |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 263 | return (info_ptr->x_offset); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 264 | } |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 265 | #else |
| 266 | return (0); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 267 | #endif |
| 268 | return (0); |
| 269 | } |
| 270 | |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 271 | png_int_32 PNGAPI |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 272 | png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr) |
| 273 | { |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 274 | if (png_ptr != NULL && info_ptr != NULL) |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 275 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 276 | #ifdef PNG_oFFs_SUPPORTED |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 277 | if (info_ptr->valid & PNG_INFO_oFFs) |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 278 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 279 | 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] | 280 | |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 281 | if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 282 | return (0); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 283 | |
Glenn Randers-Pehrson | d8eb62f | 2009-05-30 20:19:20 -0500 | [diff] [blame] | 284 | else |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 285 | return (info_ptr->y_offset); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 286 | } |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 287 | #else |
| 288 | return (0); |
Glenn Randers-Pehrson | 46f61e2 | 1998-01-30 21:45:12 -0600 | [diff] [blame] | 289 | #endif |
| 290 | return (0); |
| 291 | } |
| 292 | |
Glenn Randers-Pehrson | 7253144 | 2010-04-17 08:17:51 -0500 | [diff] [blame] | 293 | #if defined(PNG_INCH_CONVERSIONS_SUPPORTED) && \ |
| 294 | defined(PNG_FLOATING_POINT_SUPPORTED) |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 295 | png_uint_32 PNGAPI |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 296 | png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) |
| 297 | { |
| 298 | return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 299 | *.0254 +.5)); |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 300 | } |
| 301 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 302 | png_uint_32 PNGAPI |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 303 | png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) |
| 304 | { |
| 305 | return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 306 | *.0254 +.5)); |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 307 | } |
| 308 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 309 | png_uint_32 PNGAPI |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 310 | png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) |
| 311 | { |
| 312 | return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 313 | *.0254 +.5)); |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 314 | } |
| 315 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 316 | float PNGAPI |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 317 | png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr) |
| 318 | { |
| 319 | return ((float)png_get_x_offset_microns(png_ptr, info_ptr) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 320 | *.00003937); |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 321 | } |
| 322 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 323 | float PNGAPI |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 324 | png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr) |
| 325 | { |
| 326 | return ((float)png_get_y_offset_microns(png_ptr, info_ptr) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 327 | *.00003937); |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 328 | } |
| 329 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 330 | #ifdef PNG_pHYs_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 331 | png_uint_32 PNGAPI |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 332 | png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 333 | 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] | 334 | { |
| 335 | png_uint_32 retval = 0; |
| 336 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 337 | 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] | 338 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 339 | png_debug1(1, "in %s retrieval function", "pHYs"); |
Glenn Randers-Pehrson | da00980 | 2009-08-15 13:25:47 -0500 | [diff] [blame] | 340 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 341 | if (res_x != NULL) |
| 342 | { |
| 343 | *res_x = info_ptr->x_pixels_per_unit; |
| 344 | retval |= PNG_INFO_pHYs; |
| 345 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 346 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 347 | if (res_y != NULL) |
| 348 | { |
| 349 | *res_y = info_ptr->y_pixels_per_unit; |
| 350 | retval |= PNG_INFO_pHYs; |
| 351 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 352 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 353 | if (unit_type != NULL) |
| 354 | { |
| 355 | *unit_type = (int)info_ptr->phys_unit_type; |
| 356 | retval |= PNG_INFO_pHYs; |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 357 | if (*unit_type == 1) |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 358 | { |
Glenn Randers-Pehrson | a77ef62 | 2000-02-18 13:48:52 -0600 | [diff] [blame] | 359 | if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); |
| 360 | 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] | 361 | } |
| 362 | } |
| 363 | } |
| 364 | return (retval); |
| 365 | } |
Glenn Randers-Pehrson | 3097f61 | 2001-05-07 14:52:45 -0500 | [diff] [blame] | 366 | #endif /* PNG_pHYs_SUPPORTED */ |
Glenn Randers-Pehrson | 7253144 | 2010-04-17 08:17:51 -0500 | [diff] [blame] | 367 | #endif /* PNG_INCH_CONVERSIONS_SUPPORTED && PNG_FLOATING_POINT_SUPPORTED */ |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 368 | |
| 369 | /* 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] | 370 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 371 | #endif /* PNG_EASY_ACCESS_SUPPORTED */ |
| 372 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 373 | png_byte PNGAPI |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 374 | png_get_channels(png_structp png_ptr, png_infop info_ptr) |
| 375 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 376 | if (png_ptr != NULL && info_ptr != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 377 | return(info_ptr->channels); |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 378 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 379 | else |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 380 | return (0); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 381 | } |
| 382 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 383 | png_bytep PNGAPI |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 384 | png_get_signature(png_structp png_ptr, png_infop info_ptr) |
| 385 | { |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 386 | if (png_ptr != NULL && info_ptr != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 387 | return(info_ptr->signature); |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 388 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 389 | else |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 390 | return (NULL); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 391 | } |
| 392 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 393 | #ifdef PNG_bKGD_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 394 | png_uint_32 PNGAPI |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 395 | png_get_bKGD(png_structp png_ptr, png_infop info_ptr, |
| 396 | png_color_16p *background) |
| 397 | { |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 398 | 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] | 399 | && background != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 400 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 401 | png_debug1(1, "in %s retrieval function", "bKGD"); |
Glenn Randers-Pehrson | da00980 | 2009-08-15 13:25:47 -0500 | [diff] [blame] | 402 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 403 | *background = &(info_ptr->background); |
| 404 | return (PNG_INFO_bKGD); |
| 405 | } |
| 406 | return (0); |
| 407 | } |
| 408 | #endif |
| 409 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 410 | #ifdef PNG_cHRM_SUPPORTED |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 411 | #ifdef PNG_FLOATING_POINT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 412 | png_uint_32 PNGAPI |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 413 | png_get_cHRM(png_structp png_ptr, png_infop info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 414 | double *white_x, double *white_y, double *red_x, double *red_y, |
| 415 | double *green_x, double *green_y, double *blue_x, double *blue_y) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 416 | { |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 417 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 418 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 419 | png_debug1(1, "in %s retrieval function", "cHRM"); |
Glenn Randers-Pehrson | da00980 | 2009-08-15 13:25:47 -0500 | [diff] [blame] | 420 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 421 | if (white_x != NULL) |
| 422 | *white_x = (double)info_ptr->x_white; |
| 423 | if (white_y != NULL) |
| 424 | *white_y = (double)info_ptr->y_white; |
| 425 | if (red_x != NULL) |
| 426 | *red_x = (double)info_ptr->x_red; |
| 427 | if (red_y != NULL) |
| 428 | *red_y = (double)info_ptr->y_red; |
| 429 | if (green_x != NULL) |
| 430 | *green_x = (double)info_ptr->x_green; |
| 431 | if (green_y != NULL) |
| 432 | *green_y = (double)info_ptr->y_green; |
| 433 | if (blue_x != NULL) |
| 434 | *blue_x = (double)info_ptr->x_blue; |
| 435 | if (blue_y != NULL) |
| 436 | *blue_y = (double)info_ptr->y_blue; |
| 437 | return (PNG_INFO_cHRM); |
| 438 | } |
| 439 | return (0); |
| 440 | } |
| 441 | #endif |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 442 | #ifdef PNG_FIXED_POINT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 443 | png_uint_32 PNGAPI |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 444 | png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 445 | png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, |
| 446 | png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, |
| 447 | png_fixed_point *blue_x, png_fixed_point *blue_y) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 448 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 449 | png_debug1(1, "in %s retrieval function", "cHRM"); |
| 450 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 451 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) |
| 452 | { |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 453 | if (white_x != NULL) |
| 454 | *white_x = info_ptr->int_x_white; |
| 455 | if (white_y != NULL) |
| 456 | *white_y = info_ptr->int_y_white; |
| 457 | if (red_x != NULL) |
| 458 | *red_x = info_ptr->int_x_red; |
| 459 | if (red_y != NULL) |
| 460 | *red_y = info_ptr->int_y_red; |
| 461 | if (green_x != NULL) |
| 462 | *green_x = info_ptr->int_x_green; |
| 463 | if (green_y != NULL) |
| 464 | *green_y = info_ptr->int_y_green; |
| 465 | if (blue_x != NULL) |
| 466 | *blue_x = info_ptr->int_x_blue; |
| 467 | if (blue_y != NULL) |
| 468 | *blue_y = info_ptr->int_y_blue; |
| 469 | return (PNG_INFO_cHRM); |
| 470 | } |
| 471 | return (0); |
| 472 | } |
| 473 | #endif |
| 474 | #endif |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 475 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 476 | #ifdef PNG_gAMA_SUPPORTED |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 477 | #ifdef PNG_FLOATING_POINT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 478 | png_uint_32 PNGAPI |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 479 | png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) |
| 480 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 481 | png_debug1(1, "in %s retrieval function", "gAMA"); |
| 482 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 483 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 484 | && file_gamma != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 485 | { |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 486 | *file_gamma = (double)info_ptr->gamma; |
| 487 | return (PNG_INFO_gAMA); |
| 488 | } |
| 489 | return (0); |
| 490 | } |
| 491 | #endif |
Glenn Randers-Pehrson | 6942d53 | 2000-05-01 09:31:54 -0500 | [diff] [blame] | 492 | #ifdef PNG_FIXED_POINT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 493 | png_uint_32 PNGAPI |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 494 | png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 495 | png_fixed_point *int_file_gamma) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 496 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 497 | png_debug1(1, "in %s retrieval function", "gAMA"); |
| 498 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 499 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 500 | && int_file_gamma != NULL) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 501 | { |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 502 | *int_file_gamma = info_ptr->int_gamma; |
| 503 | return (PNG_INFO_gAMA); |
| 504 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 505 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 506 | return (0); |
| 507 | } |
| 508 | #endif |
Glenn Randers-Pehrson | 6942d53 | 2000-05-01 09:31:54 -0500 | [diff] [blame] | 509 | #endif |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 510 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 511 | #ifdef PNG_sRGB_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 512 | png_uint_32 PNGAPI |
Glenn Randers-Pehrson | c4a2ae6 | 1998-01-16 22:06:18 -0600 | [diff] [blame] | 513 | png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 514 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 515 | png_debug1(1, "in %s retrieval function", "sRGB"); |
| 516 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 517 | 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] | 518 | && file_srgb_intent != NULL) |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 519 | { |
Glenn Randers-Pehrson | c4a2ae6 | 1998-01-16 22:06:18 -0600 | [diff] [blame] | 520 | *file_srgb_intent = (int)info_ptr->srgb_intent; |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 521 | return (PNG_INFO_sRGB); |
| 522 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 523 | |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 524 | return (0); |
| 525 | } |
| 526 | #endif |
| 527 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 528 | #ifdef PNG_iCCP_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 529 | png_uint_32 PNGAPI |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 530 | png_get_iCCP(png_structp png_ptr, png_infop info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 531 | png_charpp name, int *compression_type, |
| 532 | png_charpp profile, png_uint_32 *proflen) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 533 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 534 | png_debug1(1, "in %s retrieval function", "iCCP"); |
| 535 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 536 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 537 | && name != NULL && profile != NULL && proflen != NULL) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 538 | { |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 539 | *name = info_ptr->iccp_name; |
| 540 | *profile = info_ptr->iccp_profile; |
Glenn Randers-Pehrson | 4bb4d01 | 2009-05-20 12:45:29 -0500 | [diff] [blame] | 541 | /* Compression_type is a dummy so the API won't have to change |
| 542 | * if we introduce multiple compression types later. |
| 543 | */ |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 544 | *proflen = (int)info_ptr->iccp_proflen; |
| 545 | *compression_type = (int)info_ptr->iccp_compression; |
| 546 | return (PNG_INFO_iCCP); |
| 547 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 548 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 549 | return (0); |
| 550 | } |
| 551 | #endif |
| 552 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 553 | #ifdef PNG_sPLT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 554 | png_uint_32 PNGAPI |
Glenn Randers-Pehrson | a77ef62 | 2000-02-18 13:48:52 -0600 | [diff] [blame] | 555 | png_get_sPLT(png_structp png_ptr, png_infop info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 556 | png_sPLT_tpp spalettes) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 557 | { |
| 558 | if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 559 | { |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 560 | *spalettes = info_ptr->splt_palettes; |
| 561 | return ((png_uint_32)info_ptr->splt_palettes_num); |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 562 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 563 | |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 564 | return (0); |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 565 | } |
| 566 | #endif |
| 567 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 568 | #ifdef PNG_hIST_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 569 | png_uint_32 PNGAPI |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 570 | png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) |
| 571 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 572 | png_debug1(1, "in %s retrieval function", "hIST"); |
| 573 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 574 | 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] | 575 | && hist != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 576 | { |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 577 | *hist = info_ptr->hist; |
| 578 | return (PNG_INFO_hIST); |
| 579 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 580 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 581 | return (0); |
| 582 | } |
| 583 | #endif |
| 584 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 585 | png_uint_32 PNGAPI |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 586 | png_get_IHDR(png_structp png_ptr, png_infop info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 587 | png_uint_32 *width, png_uint_32 *height, int *bit_depth, |
| 588 | int *color_type, int *interlace_type, int *compression_type, |
| 589 | int *filter_type) |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 590 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 591 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 592 | png_debug1(1, "in %s retrieval function", "IHDR"); |
| 593 | |
Glenn Randers-Pehrson | 134bbe4 | 2009-09-24 18:10:49 -0500 | [diff] [blame] | 594 | if (png_ptr == NULL || info_ptr == NULL || width == NULL || |
| 595 | height == NULL || bit_depth == NULL || color_type == NULL) |
| 596 | return (0); |
| 597 | |
| 598 | *width = info_ptr->width; |
| 599 | *height = info_ptr->height; |
| 600 | *bit_depth = info_ptr->bit_depth; |
| 601 | *color_type = info_ptr->color_type; |
| 602 | |
| 603 | if (compression_type != NULL) |
Glenn Randers-Pehrson | 134bbe4 | 2009-09-24 18:10:49 -0500 | [diff] [blame] | 604 | *compression_type = info_ptr->compression_type; |
Glenn Randers-Pehrson | 134bbe4 | 2009-09-24 18:10:49 -0500 | [diff] [blame] | 605 | |
| 606 | if (filter_type != NULL) |
Glenn Randers-Pehrson | 134bbe4 | 2009-09-24 18:10:49 -0500 | [diff] [blame] | 607 | *filter_type = info_ptr->filter_type; |
Glenn Randers-Pehrson | 134bbe4 | 2009-09-24 18:10:49 -0500 | [diff] [blame] | 608 | |
| 609 | if (interlace_type != NULL) |
Glenn Randers-Pehrson | 134bbe4 | 2009-09-24 18:10:49 -0500 | [diff] [blame] | 610 | *interlace_type = info_ptr->interlace_type; |
Glenn Randers-Pehrson | 134bbe4 | 2009-09-24 18:10:49 -0500 | [diff] [blame] | 611 | |
Glenn Randers-Pehrson | b35a745 | 2009-09-30 23:12:13 -0500 | [diff] [blame] | 612 | /* This is redundant if we can be sure that the info_ptr values were all |
| 613 | * assigned in png_set_IHDR(). We do the check anyhow in case an |
| 614 | * application has ignored our advice not to mess with the members |
| 615 | * of info_ptr directly. |
| 616 | */ |
| 617 | png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height, |
| 618 | info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, |
| 619 | info_ptr->compression_type, info_ptr->filter_type); |
Glenn Randers-Pehrson | 134bbe4 | 2009-09-24 18:10:49 -0500 | [diff] [blame] | 620 | |
| 621 | return (1); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 622 | } |
| 623 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 624 | #ifdef PNG_oFFs_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 625 | png_uint_32 PNGAPI |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 626 | png_get_oFFs(png_structp png_ptr, png_infop info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 627 | 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] | 628 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 629 | png_debug1(1, "in %s retrieval function", "oFFs"); |
| 630 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 631 | 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] | 632 | && offset_x != NULL && offset_y != NULL && unit_type != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 633 | { |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 634 | *offset_x = info_ptr->x_offset; |
| 635 | *offset_y = info_ptr->y_offset; |
| 636 | *unit_type = (int)info_ptr->offset_unit_type; |
| 637 | return (PNG_INFO_oFFs); |
| 638 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 639 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 640 | return (0); |
| 641 | } |
| 642 | #endif |
| 643 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 644 | #ifdef PNG_pCAL_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 645 | png_uint_32 PNGAPI |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 646 | png_get_pCAL(png_structp png_ptr, png_infop info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 647 | png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, |
| 648 | png_charp *units, png_charpp *params) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 649 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 650 | png_debug1(1, "in %s retrieval function", "pCAL"); |
| 651 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 652 | 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] | 653 | && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && |
| 654 | nparams != NULL && units != NULL && params != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 655 | { |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 656 | *purpose = info_ptr->pcal_purpose; |
| 657 | *X0 = info_ptr->pcal_X0; |
| 658 | *X1 = info_ptr->pcal_X1; |
| 659 | *type = (int)info_ptr->pcal_type; |
| 660 | *nparams = (int)info_ptr->pcal_nparams; |
| 661 | *units = info_ptr->pcal_units; |
| 662 | *params = info_ptr->pcal_params; |
| 663 | return (PNG_INFO_pCAL); |
| 664 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 665 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 666 | return (0); |
| 667 | } |
| 668 | #endif |
| 669 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 670 | #ifdef PNG_sCAL_SUPPORTED |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 671 | #ifdef PNG_FLOATING_POINT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 672 | png_uint_32 PNGAPI |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 673 | png_get_sCAL(png_structp png_ptr, png_infop info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 674 | int *unit, double *width, double *height) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 675 | { |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 676 | if (png_ptr != NULL && info_ptr != NULL && |
| 677 | (info_ptr->valid & PNG_INFO_sCAL)) |
| 678 | { |
| 679 | *unit = info_ptr->scal_unit; |
| 680 | *width = info_ptr->scal_pixel_width; |
| 681 | *height = info_ptr->scal_pixel_height; |
| 682 | return (PNG_INFO_sCAL); |
| 683 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 684 | |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 685 | return(0); |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 686 | } |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 687 | #else |
| 688 | #ifdef PNG_FIXED_POINT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 689 | png_uint_32 PNGAPI |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 690 | png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr, |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 691 | int *unit, png_charpp width, png_charpp height) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 692 | { |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 693 | if (png_ptr != NULL && info_ptr != NULL && |
| 694 | (info_ptr->valid & PNG_INFO_sCAL)) |
| 695 | { |
| 696 | *unit = info_ptr->scal_unit; |
| 697 | *width = info_ptr->scal_s_width; |
| 698 | *height = info_ptr->scal_s_height; |
| 699 | return (PNG_INFO_sCAL); |
| 700 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 701 | |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 702 | return(0); |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 703 | } |
| 704 | #endif |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 705 | #endif |
| 706 | #endif |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 707 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 708 | #ifdef PNG_pHYs_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 709 | png_uint_32 PNGAPI |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 710 | png_get_pHYs(png_structp png_ptr, png_infop info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 711 | 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] | 712 | { |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 713 | png_uint_32 retval = 0; |
| 714 | |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 715 | png_debug1(1, "in %s retrieval function", "pHYs"); |
| 716 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 717 | if (png_ptr != NULL && info_ptr != NULL && |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 718 | (info_ptr->valid & PNG_INFO_pHYs)) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 719 | { |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 720 | if (res_x != NULL) |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 721 | { |
| 722 | *res_x = info_ptr->x_pixels_per_unit; |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 723 | retval |= PNG_INFO_pHYs; |
| 724 | } |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 725 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 726 | if (res_y != NULL) |
| 727 | { |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 728 | *res_y = info_ptr->y_pixels_per_unit; |
| 729 | retval |= PNG_INFO_pHYs; |
| 730 | } |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 731 | |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 732 | if (unit_type != NULL) |
| 733 | { |
| 734 | *unit_type = (int)info_ptr->phys_unit_type; |
| 735 | retval |= PNG_INFO_pHYs; |
| 736 | } |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 737 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 738 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 739 | return (retval); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 740 | } |
| 741 | #endif |
| 742 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 743 | png_uint_32 PNGAPI |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 744 | png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 745 | int *num_palette) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 746 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 747 | png_debug1(1, "in %s retrieval function", "PLTE"); |
| 748 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 749 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) |
| 750 | && palette != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 751 | { |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 752 | *palette = info_ptr->palette; |
| 753 | *num_palette = info_ptr->num_palette; |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 754 | png_debug1(3, "num_palette = %d", *num_palette); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 755 | return (PNG_INFO_PLTE); |
| 756 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 757 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 758 | return (0); |
| 759 | } |
| 760 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 761 | #ifdef PNG_sBIT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 762 | png_uint_32 PNGAPI |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 763 | png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) |
| 764 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 765 | png_debug1(1, "in %s retrieval function", "sBIT"); |
| 766 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 767 | 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] | 768 | && sig_bit != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 769 | { |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 770 | *sig_bit = &(info_ptr->sig_bit); |
| 771 | return (PNG_INFO_sBIT); |
| 772 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 773 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 774 | return (0); |
| 775 | } |
| 776 | #endif |
| 777 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 778 | #ifdef PNG_TEXT_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 779 | png_uint_32 PNGAPI |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 780 | png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 781 | int *num_text) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 782 | { |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 783 | if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 784 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 785 | png_debug1(1, "in %s retrieval function", |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 786 | (png_ptr->chunk_name[0] == '\0' ? "text" : |
| 787 | (png_const_charp)png_ptr->chunk_name)); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 788 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 789 | if (text_ptr != NULL) |
| 790 | *text_ptr = info_ptr->text; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 791 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 792 | if (num_text != NULL) |
| 793 | *num_text = info_ptr->num_text; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 794 | |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 795 | return ((png_uint_32)info_ptr->num_text); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 796 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 797 | |
Glenn Randers-Pehrson | a77ef62 | 2000-02-18 13:48:52 -0600 | [diff] [blame] | 798 | if (num_text != NULL) |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 799 | *num_text = 0; |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 800 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 801 | return(0); |
| 802 | } |
| 803 | #endif |
| 804 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 805 | #ifdef PNG_tIME_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 806 | png_uint_32 PNGAPI |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 807 | png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) |
| 808 | { |
Glenn Randers-Pehrson | b3ce365 | 2009-08-15 21:47:03 -0500 | [diff] [blame] | 809 | png_debug1(1, "in %s retrieval function", "tIME"); |
| 810 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 811 | if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) |
| 812 | && mod_time != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 813 | { |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 814 | *mod_time = &(info_ptr->mod_time); |
| 815 | return (PNG_INFO_tIME); |
| 816 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 817 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 818 | return (0); |
| 819 | } |
| 820 | #endif |
| 821 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 822 | #ifdef PNG_tRNS_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 823 | png_uint_32 PNGAPI |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 824 | png_get_tRNS(png_structp png_ptr, png_infop info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 825 | png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 826 | { |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 827 | png_uint_32 retval = 0; |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 828 | 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] | 829 | { |
Glenn Randers-Pehrson | 51650b8 | 2008-08-05 07:44:42 -0500 | [diff] [blame] | 830 | png_debug1(1, "in %s retrieval function", "tRNS"); |
Glenn Randers-Pehrson | da00980 | 2009-08-15 13:25:47 -0500 | [diff] [blame] | 831 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 832 | if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 833 | { |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 834 | if (trans_alpha != NULL) |
| 835 | { |
| 836 | *trans_alpha = info_ptr->trans_alpha; |
| 837 | retval |= PNG_INFO_tRNS; |
| 838 | } |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 839 | |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 840 | if (trans_color != NULL) |
| 841 | *trans_color = &(info_ptr->trans_color); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 842 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 843 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 844 | else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 845 | { |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 846 | if (trans_color != NULL) |
| 847 | { |
| 848 | *trans_color = &(info_ptr->trans_color); |
| 849 | retval |= PNG_INFO_tRNS; |
| 850 | } |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 851 | |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 852 | if (trans_alpha != NULL) |
| 853 | *trans_alpha = NULL; |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 854 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 855 | |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 856 | if (num_trans != NULL) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 857 | { |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 858 | *num_trans = info_ptr->num_trans; |
| 859 | retval |= PNG_INFO_tRNS; |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 860 | } |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 861 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 862 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 863 | return (retval); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 864 | } |
| 865 | #endif |
| 866 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 867 | #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 868 | png_uint_32 PNGAPI |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 869 | png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 870 | png_unknown_chunkpp unknowns) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 871 | { |
| 872 | if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL) |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 873 | { |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 874 | *unknowns = info_ptr->unknown_chunks; |
| 875 | return ((png_uint_32)info_ptr->unknown_chunks_num); |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 876 | } |
Glenn Randers-Pehrson | f24daf2 | 2010-05-06 09:44:04 -0500 | [diff] [blame^] | 877 | |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 878 | return (0); |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 879 | } |
| 880 | #endif |
| 881 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 882 | #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 883 | png_byte PNGAPI |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 884 | png_get_rgb_to_gray_status (png_structp png_ptr) |
| 885 | { |
Glenn Randers-Pehrson | a565f0e | 2010-03-06 08:24:45 -0600 | [diff] [blame] | 886 | 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] | 887 | } |
| 888 | #endif |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 889 | |
Glenn Randers-Pehrson | e26c095 | 2009-09-23 11:22:08 -0500 | [diff] [blame] | 890 | #ifdef PNG_USER_CHUNKS_SUPPORTED |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 891 | png_voidp PNGAPI |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 892 | png_get_user_chunk_ptr(png_structp png_ptr) |
| 893 | { |
Glenn Randers-Pehrson | a565f0e | 2010-03-06 08:24:45 -0600 | [diff] [blame] | 894 | return (png_ptr ? png_ptr->user_chunk_ptr : NULL); |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 895 | } |
| 896 | #endif |
| 897 | |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 898 | png_size_t PNGAPI |
Glenn Randers-Pehrson | 228bd39 | 2000-04-23 23:14:02 -0500 | [diff] [blame] | 899 | png_get_compression_buffer_size(png_structp png_ptr) |
| 900 | { |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 901 | return (png_ptr ? png_ptr->zbuf_size : 0L); |
Glenn Randers-Pehrson | 228bd39 | 2000-04-23 23:14:02 -0500 | [diff] [blame] | 902 | } |
Glenn Randers-Pehrson | e68f5a3 | 2001-05-14 09:20:53 -0500 | [diff] [blame] | 903 | |
Glenn Randers-Pehrson | 272489d | 2004-08-04 06:34:52 -0500 | [diff] [blame] | 904 | |
| 905 | #ifdef PNG_SET_USER_LIMITS_SUPPORTED |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 906 | /* These functions were added to libpng 1.2.6 and were enabled |
| 907 | * by default in libpng-1.4.0 */ |
Glenn Randers-Pehrson | 272489d | 2004-08-04 06:34:52 -0500 | [diff] [blame] | 908 | png_uint_32 PNGAPI |
| 909 | png_get_user_width_max (png_structp png_ptr) |
| 910 | { |
Glenn Randers-Pehrson | a565f0e | 2010-03-06 08:24:45 -0600 | [diff] [blame] | 911 | return (png_ptr ? png_ptr->user_width_max : 0); |
Glenn Randers-Pehrson | 272489d | 2004-08-04 06:34:52 -0500 | [diff] [blame] | 912 | } |
| 913 | png_uint_32 PNGAPI |
| 914 | png_get_user_height_max (png_structp png_ptr) |
| 915 | { |
Glenn Randers-Pehrson | a565f0e | 2010-03-06 08:24:45 -0600 | [diff] [blame] | 916 | return (png_ptr ? png_ptr->user_height_max : 0); |
Glenn Randers-Pehrson | 272489d | 2004-08-04 06:34:52 -0500 | [diff] [blame] | 917 | } |
Glenn Randers-Pehrson | 17ca340 | 2009-11-09 06:51:16 -0600 | [diff] [blame] | 918 | /* This function was added to libpng 1.4.0 */ |
Glenn Randers-Pehrson | 800d1e9 | 2008-08-20 17:25:21 -0500 | [diff] [blame] | 919 | png_uint_32 PNGAPI |
| 920 | png_get_chunk_cache_max (png_structp png_ptr) |
| 921 | { |
Glenn Randers-Pehrson | a565f0e | 2010-03-06 08:24:45 -0600 | [diff] [blame] | 922 | return (png_ptr ? png_ptr->user_chunk_cache_max : 0); |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 923 | } |
| 924 | /* This function was added to libpng 1.4.1 */ |
Glenn Randers-Pehrson | 7a5be53 | 2010-02-14 07:16:19 -0600 | [diff] [blame] | 925 | png_alloc_size_t PNGAPI |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 926 | png_get_chunk_malloc_max (png_structp png_ptr) |
| 927 | { |
Glenn Randers-Pehrson | a565f0e | 2010-03-06 08:24:45 -0600 | [diff] [blame] | 928 | return (png_ptr ? png_ptr->user_chunk_malloc_max : 0); |
Glenn Randers-Pehrson | 800d1e9 | 2008-08-20 17:25:21 -0500 | [diff] [blame] | 929 | } |
Glenn Randers-Pehrson | 272489d | 2004-08-04 06:34:52 -0500 | [diff] [blame] | 930 | #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ |
Glenn Randers-Pehrson | d60c886 | 2009-06-15 21:56:14 -0500 | [diff] [blame] | 931 | |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 932 | /* These functions were added to libpng 1.4.0 */ |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 933 | #ifdef PNG_IO_STATE_SUPPORTED |
| 934 | png_uint_32 PNGAPI |
| 935 | png_get_io_state (png_structp png_ptr) |
| 936 | { |
Glenn Randers-Pehrson | 16908a1 | 2010-03-06 07:34:28 -0600 | [diff] [blame] | 937 | return png_ptr->io_state; |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 938 | } |
| 939 | |
| 940 | png_bytep PNGAPI |
| 941 | png_get_io_chunk_name (png_structp png_ptr) |
| 942 | { |
| 943 | return png_ptr->chunk_name; |
| 944 | } |
| 945 | #endif /* ?PNG_IO_STATE_SUPPORTED */ |
| 946 | |
Glenn Randers-Pehrson | 9c3ab68 | 2006-02-20 22:09:05 -0600 | [diff] [blame] | 947 | #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ |