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