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