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