10576
|
1 |
/*
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3 |
*
|
|
4 |
* This code is free software; you can redistribute it and/or modify it
|
|
5 |
* under the terms of the GNU General Public License version 2 only, as
|
|
6 |
* published by the Free Software Foundation. Oracle designates this
|
|
7 |
* particular file as subject to the "Classpath" exception as provided
|
|
8 |
* by Oracle in the LICENSE file that accompanied this code.
|
|
9 |
*
|
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
14 |
* accompanied this code).
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License version
|
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
19 |
*
|
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
21 |
* or visit www.oracle.com if you need additional information or have any
|
|
22 |
* questions.
|
|
23 |
*/
|
|
24 |
|
|
25 |
/* pnginfo.h - header file for PNG reference library
|
|
26 |
*
|
|
27 |
* This file is available under and governed by the GNU General Public
|
|
28 |
* License version 2 only, as published by the Free Software Foundation.
|
|
29 |
* However, the following notice accompanied the original version of this
|
|
30 |
* file and, per its terms, should not be removed:
|
|
31 |
*
|
57618
|
32 |
* Copyright (c) 2018 Cosmin Truta
|
51304
|
33 |
* Copyright (c) 1998-2002,2004,2006-2013,2018 Glenn Randers-Pehrson
|
57618
|
34 |
* Copyright (c) 1996-1997 Andreas Dilger
|
|
35 |
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
10576
|
36 |
*
|
|
37 |
* This code is released under the libpng license.
|
|
38 |
* For conditions of distribution and use, see the disclaimer
|
|
39 |
* and license in png.h
|
|
40 |
*/
|
|
41 |
|
|
42 |
/* png_info is a structure that holds the information in a PNG file so
|
|
43 |
* that the application can find out the characteristics of the image.
|
|
44 |
* If you are reading the file, this structure will tell you what is
|
|
45 |
* in the PNG file. If you are writing the file, fill in the information
|
|
46 |
* you want to put into the PNG file, using png_set_*() functions, then
|
|
47 |
* call png_write_info().
|
|
48 |
*
|
|
49 |
* The names chosen should be very close to the PNG specification, so
|
|
50 |
* consult that document for information about the meaning of each field.
|
|
51 |
*
|
|
52 |
* With libpng < 0.95, it was only possible to directly set and read the
|
|
53 |
* the values in the png_info_struct, which meant that the contents and
|
|
54 |
* order of the values had to remain fixed. With libpng 0.95 and later,
|
|
55 |
* however, there are now functions that abstract the contents of
|
|
56 |
* png_info_struct from the application, so this makes it easier to use
|
|
57 |
* libpng with dynamic libraries, and even makes it possible to use
|
|
58 |
* libraries that don't have all of the libpng ancillary chunk-handing
|
|
59 |
* functionality. In libpng-1.5.0 this was moved into a separate private
|
|
60 |
* file that is not visible to applications.
|
|
61 |
*
|
|
62 |
* The following members may have allocated storage attached that should be
|
|
63 |
* cleaned up before the structure is discarded: palette, trans, text,
|
|
64 |
* pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
|
|
65 |
* splt_palettes, scal_unit, row_pointers, and unknowns. By default, these
|
|
66 |
* are automatically freed when the info structure is deallocated, if they were
|
|
67 |
* allocated internally by libpng. This behavior can be changed by means
|
|
68 |
* of the png_data_freer() function.
|
|
69 |
*
|
|
70 |
* More allocation details: all the chunk-reading functions that
|
|
71 |
* change these members go through the corresponding png_set_*
|
|
72 |
* functions. A function to clear these members is available: see
|
|
73 |
* png_free_data(). The png_set_* functions do not depend on being
|
|
74 |
* able to point info structure members to any of the storage they are
|
|
75 |
* passed (they make their own copies), EXCEPT that the png_set_text
|
|
76 |
* functions use the same storage passed to them in the text_ptr or
|
|
77 |
* itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
|
|
78 |
* functions do not make their own copies.
|
|
79 |
*/
|
|
80 |
#ifndef PNGINFO_H
|
|
81 |
#define PNGINFO_H
|
|
82 |
|
|
83 |
struct png_info_def
|
|
84 |
{
|
29913
|
85 |
/* The following are necessary for every PNG file */
|
51304
|
86 |
png_uint_32 width; /* width of image in pixels (from IHDR) */
|
|
87 |
png_uint_32 height; /* height of image in pixels (from IHDR) */
|
|
88 |
png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
|
|
89 |
size_t rowbytes; /* bytes needed to hold an untransformed row */
|
10576
|
90 |
png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */
|
|
91 |
png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
|
|
92 |
png_uint_16 num_trans; /* number of transparent palette color (tRNS) */
|
|
93 |
png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
|
|
94 |
png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */
|
|
95 |
/* The following three should have been named *_method not *_type */
|
|
96 |
png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
|
|
97 |
png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
|
|
98 |
png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
|
99 |
|
29913
|
100 |
/* The following are set by png_set_IHDR, called from the application on
|
|
101 |
* write, but the are never actually used by the write code.
|
|
102 |
*/
|
10576
|
103 |
png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */
|
|
104 |
png_byte pixel_depth; /* number of bits per pixel */
|
|
105 |
png_byte spare_byte; /* to align the data, and for future use */
|
29913
|
106 |
|
|
107 |
#ifdef PNG_READ_SUPPORTED
|
|
108 |
/* This is never set during write */
|
10576
|
109 |
png_byte signature[8]; /* magic bytes read by libpng from start of file */
|
29913
|
110 |
#endif
|
10576
|
111 |
|
|
112 |
/* The rest of the data is optional. If you are reading, check the
|
|
113 |
* valid field to see if the information in these are valid. If you
|
|
114 |
* are writing, set the valid field to those chunks you want written,
|
|
115 |
* and initialize the appropriate fields below.
|
|
116 |
*/
|
|
117 |
|
29913
|
118 |
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
|
119 |
/* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are
|
|
120 |
* defined. When COLORSPACE is switched on all the colorspace-defining
|
|
121 |
* chunks should be enabled, when GAMMA is switched on all the gamma-defining
|
|
122 |
* chunks should be enabled. If this is not done it becomes possible to read
|
|
123 |
* inconsistent PNG files and assign a probably incorrect interpretation to
|
|
124 |
* the information. (In other words, by carefully choosing which chunks to
|
|
125 |
* recognize the system configuration can select an interpretation for PNG
|
|
126 |
* files containing ambiguous data and this will result in inconsistent
|
|
127 |
* behavior between different libpng builds!)
|
10576
|
128 |
*/
|
29913
|
129 |
png_colorspace colorspace;
|
10576
|
130 |
#endif
|
|
131 |
|
29913
|
132 |
#ifdef PNG_iCCP_SUPPORTED
|
|
133 |
/* iCCP chunk data. */
|
|
134 |
png_charp iccp_name; /* profile name */
|
|
135 |
png_bytep iccp_profile; /* International Color Consortium profile data */
|
|
136 |
png_uint_32 iccp_proflen; /* ICC profile data length */
|
10576
|
137 |
#endif
|
|
138 |
|
|
139 |
#ifdef PNG_TEXT_SUPPORTED
|
|
140 |
/* The tEXt, and zTXt chunks contain human-readable textual data in
|
|
141 |
* uncompressed, compressed, and optionally compressed forms, respectively.
|
|
142 |
* The data in "text" is an array of pointers to uncompressed,
|
|
143 |
* null-terminated C strings. Each chunk has a keyword that describes the
|
|
144 |
* textual data contained in that chunk. Keywords are not required to be
|
|
145 |
* unique, and the text string may be empty. Any number of text chunks may
|
|
146 |
* be in an image.
|
|
147 |
*/
|
|
148 |
int num_text; /* number of comments read or comments to write */
|
|
149 |
int max_text; /* current size of text array */
|
|
150 |
png_textp text; /* array of comments read or comments to write */
|
29913
|
151 |
#endif /* TEXT */
|
10576
|
152 |
|
|
153 |
#ifdef PNG_tIME_SUPPORTED
|
|
154 |
/* The tIME chunk holds the last time the displayed image data was
|
|
155 |
* modified. See the png_time struct for the contents of this struct.
|
|
156 |
*/
|
|
157 |
png_time mod_time;
|
|
158 |
#endif
|
|
159 |
|
|
160 |
#ifdef PNG_sBIT_SUPPORTED
|
|
161 |
/* The sBIT chunk specifies the number of significant high-order bits
|
|
162 |
* in the pixel data. Values are in the range [1, bit_depth], and are
|
|
163 |
* only specified for the channels in the pixel data. The contents of
|
|
164 |
* the low-order bits is not specified. Data is valid if
|
|
165 |
* (valid & PNG_INFO_sBIT) is non-zero.
|
|
166 |
*/
|
|
167 |
png_color_8 sig_bit; /* significant bits in color channels */
|
|
168 |
#endif
|
|
169 |
|
|
170 |
#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \
|
|
171 |
defined(PNG_READ_BACKGROUND_SUPPORTED)
|
|
172 |
/* The tRNS chunk supplies transparency data for paletted images and
|
|
173 |
* other image types that don't need a full alpha channel. There are
|
|
174 |
* "num_trans" transparency values for a paletted image, stored in the
|
|
175 |
* same order as the palette colors, starting from index 0. Values
|
|
176 |
* for the data are in the range [0, 255], ranging from fully transparent
|
|
177 |
* to fully opaque, respectively. For non-paletted images, there is a
|
|
178 |
* single color specified that should be treated as fully transparent.
|
|
179 |
* Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
|
|
180 |
*/
|
|
181 |
png_bytep trans_alpha; /* alpha values for paletted image */
|
|
182 |
png_color_16 trans_color; /* transparent color for non-palette image */
|
|
183 |
#endif
|
|
184 |
|
|
185 |
#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
|
186 |
/* The bKGD chunk gives the suggested image background color if the
|
|
187 |
* display program does not have its own background color and the image
|
|
188 |
* is needs to composited onto a background before display. The colors
|
|
189 |
* in "background" are normally in the same color space/depth as the
|
|
190 |
* pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
|
|
191 |
*/
|
|
192 |
png_color_16 background;
|
|
193 |
#endif
|
|
194 |
|
|
195 |
#ifdef PNG_oFFs_SUPPORTED
|
|
196 |
/* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
|
|
197 |
* and downwards from the top-left corner of the display, page, or other
|
|
198 |
* application-specific co-ordinate space. See the PNG_OFFSET_ defines
|
|
199 |
* below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.
|
|
200 |
*/
|
|
201 |
png_int_32 x_offset; /* x offset on page */
|
|
202 |
png_int_32 y_offset; /* y offset on page */
|
|
203 |
png_byte offset_unit_type; /* offset units type */
|
|
204 |
#endif
|
|
205 |
|
|
206 |
#ifdef PNG_pHYs_SUPPORTED
|
|
207 |
/* The pHYs chunk gives the physical pixel density of the image for
|
|
208 |
* display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
|
|
209 |
* defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
|
|
210 |
*/
|
|
211 |
png_uint_32 x_pixels_per_unit; /* horizontal pixel density */
|
|
212 |
png_uint_32 y_pixels_per_unit; /* vertical pixel density */
|
|
213 |
png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
|
|
214 |
#endif
|
|
215 |
|
48280
|
216 |
#ifdef PNG_eXIf_SUPPORTED
|
|
217 |
int num_exif; /* Added at libpng-1.6.31 */
|
|
218 |
png_bytep exif;
|
|
219 |
# ifdef PNG_READ_eXIf_SUPPORTED
|
|
220 |
png_bytep eXIf_buf; /* Added at libpng-1.6.32 */
|
|
221 |
# endif
|
|
222 |
#endif
|
|
223 |
|
10576
|
224 |
#ifdef PNG_hIST_SUPPORTED
|
|
225 |
/* The hIST chunk contains the relative frequency or importance of the
|
|
226 |
* various palette entries, so that a viewer can intelligently select a
|
|
227 |
* reduced-color palette, if required. Data is an array of "num_palette"
|
|
228 |
* values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
|
|
229 |
* is non-zero.
|
|
230 |
*/
|
|
231 |
png_uint_16p hist;
|
|
232 |
#endif
|
|
233 |
|
|
234 |
#ifdef PNG_pCAL_SUPPORTED
|
|
235 |
/* The pCAL chunk describes a transformation between the stored pixel
|
|
236 |
* values and original physical data values used to create the image.
|
|
237 |
* The integer range [0, 2^bit_depth - 1] maps to the floating-point
|
|
238 |
* range given by [pcal_X0, pcal_X1], and are further transformed by a
|
|
239 |
* (possibly non-linear) transformation function given by "pcal_type"
|
|
240 |
* and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_
|
|
241 |
* defines below, and the PNG-Group's PNG extensions document for a
|
|
242 |
* complete description of the transformations and how they should be
|
|
243 |
* implemented, and for a description of the ASCII parameter strings.
|
|
244 |
* Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
|
|
245 |
*/
|
|
246 |
png_charp pcal_purpose; /* pCAL chunk description string */
|
|
247 |
png_int_32 pcal_X0; /* minimum value */
|
|
248 |
png_int_32 pcal_X1; /* maximum value */
|
|
249 |
png_charp pcal_units; /* Latin-1 string giving physical units */
|
|
250 |
png_charpp pcal_params; /* ASCII strings containing parameter values */
|
|
251 |
png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */
|
|
252 |
png_byte pcal_nparams; /* number of parameters given in pcal_params */
|
|
253 |
#endif
|
|
254 |
|
|
255 |
/* New members added in libpng-1.0.6 */
|
|
256 |
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
|
|
257 |
|
29913
|
258 |
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
10576
|
259 |
/* Storage for unknown chunks that the library doesn't recognize. */
|
|
260 |
png_unknown_chunkp unknown_chunks;
|
|
261 |
|
29913
|
262 |
/* The type of this field is limited by the type of
|
|
263 |
* png_struct::user_chunk_cache_max, else overflow can occur.
|
|
264 |
*/
|
|
265 |
int unknown_chunks_num;
|
10576
|
266 |
#endif
|
|
267 |
|
|
268 |
#ifdef PNG_sPLT_SUPPORTED
|
|
269 |
/* Data on sPLT chunks (there may be more than one). */
|
|
270 |
png_sPLT_tp splt_palettes;
|
29913
|
271 |
int splt_palettes_num; /* Match type returned by png_get API */
|
10576
|
272 |
#endif
|
|
273 |
|
|
274 |
#ifdef PNG_sCAL_SUPPORTED
|
|
275 |
/* The sCAL chunk describes the actual physical dimensions of the
|
|
276 |
* subject matter of the graphic. The chunk contains a unit specification
|
|
277 |
* a byte value, and two ASCII strings representing floating-point
|
51304
|
278 |
* values. The values are width and height corresponding to one pixel
|
10576
|
279 |
* in the image. Data values are valid if (valid & PNG_INFO_sCAL) is
|
|
280 |
* non-zero.
|
|
281 |
*/
|
|
282 |
png_byte scal_unit; /* unit of physical scale */
|
|
283 |
png_charp scal_s_width; /* string containing height */
|
|
284 |
png_charp scal_s_height; /* string containing width */
|
|
285 |
#endif
|
|
286 |
|
|
287 |
#ifdef PNG_INFO_IMAGE_SUPPORTED
|
|
288 |
/* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)
|
|
289 |
non-zero */
|
|
290 |
/* Data valid if (valid & PNG_INFO_IDAT) non-zero */
|
|
291 |
png_bytepp row_pointers; /* the image bits */
|
|
292 |
#endif
|
|
293 |
|
|
294 |
};
|
|
295 |
#endif /* PNGINFO_H */
|