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