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 |
*
|
|
32 |
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
|
33 |
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
|
34 |
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
|
35 |
*
|
|
36 |
* Last changed in libpng 1.5.0 [January 6, 2011]
|
|
37 |
*
|
|
38 |
* This code is released under the libpng license.
|
|
39 |
* For conditions of distribution and use, see the disclaimer
|
|
40 |
* and license in png.h
|
|
41 |
*/
|
|
42 |
|
|
43 |
/* png_info is a structure that holds the information in a PNG file so
|
|
44 |
* that the application can find out the characteristics of the image.
|
|
45 |
* If you are reading the file, this structure will tell you what is
|
|
46 |
* in the PNG file. If you are writing the file, fill in the information
|
|
47 |
* you want to put into the PNG file, using png_set_*() functions, then
|
|
48 |
* call png_write_info().
|
|
49 |
*
|
|
50 |
* The names chosen should be very close to the PNG specification, so
|
|
51 |
* consult that document for information about the meaning of each field.
|
|
52 |
*
|
|
53 |
* With libpng < 0.95, it was only possible to directly set and read the
|
|
54 |
* the values in the png_info_struct, which meant that the contents and
|
|
55 |
* order of the values had to remain fixed. With libpng 0.95 and later,
|
|
56 |
* however, there are now functions that abstract the contents of
|
|
57 |
* png_info_struct from the application, so this makes it easier to use
|
|
58 |
* libpng with dynamic libraries, and even makes it possible to use
|
|
59 |
* libraries that don't have all of the libpng ancillary chunk-handing
|
|
60 |
* functionality. In libpng-1.5.0 this was moved into a separate private
|
|
61 |
* file that is not visible to applications.
|
|
62 |
*
|
|
63 |
* The following members may have allocated storage attached that should be
|
|
64 |
* cleaned up before the structure is discarded: palette, trans, text,
|
|
65 |
* pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
|
|
66 |
* splt_palettes, scal_unit, row_pointers, and unknowns. By default, these
|
|
67 |
* are automatically freed when the info structure is deallocated, if they were
|
|
68 |
* allocated internally by libpng. This behavior can be changed by means
|
|
69 |
* of the png_data_freer() function.
|
|
70 |
*
|
|
71 |
* More allocation details: all the chunk-reading functions that
|
|
72 |
* change these members go through the corresponding png_set_*
|
|
73 |
* functions. A function to clear these members is available: see
|
|
74 |
* png_free_data(). The png_set_* functions do not depend on being
|
|
75 |
* able to point info structure members to any of the storage they are
|
|
76 |
* passed (they make their own copies), EXCEPT that the png_set_text
|
|
77 |
* functions use the same storage passed to them in the text_ptr or
|
|
78 |
* itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
|
|
79 |
* functions do not make their own copies.
|
|
80 |
*/
|
|
81 |
#ifndef PNGINFO_H
|
|
82 |
#define PNGINFO_H
|
|
83 |
|
|
84 |
struct png_info_def
|
|
85 |
{
|
|
86 |
/* the following are necessary for every PNG file */
|
|
87 |
png_uint_32 width; /* width of image in pixels (from IHDR) */
|
|
88 |
png_uint_32 height; /* height of image in pixels (from IHDR) */
|
|
89 |
png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
|
|
90 |
png_size_t rowbytes; /* bytes needed to hold an untransformed row */
|
|
91 |
png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */
|
|
92 |
png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
|
|
93 |
png_uint_16 num_trans; /* number of transparent palette color (tRNS) */
|
|
94 |
png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
|
|
95 |
png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */
|
|
96 |
/* The following three should have been named *_method not *_type */
|
|
97 |
png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
|
|
98 |
png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
|
|
99 |
png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
|
100 |
|
|
101 |
/* The following is informational only on read, and not used on writes. */
|
|
102 |
png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */
|
|
103 |
png_byte pixel_depth; /* number of bits per pixel */
|
|
104 |
png_byte spare_byte; /* to align the data, and for future use */
|
|
105 |
png_byte signature[8]; /* magic bytes read by libpng from start of file */
|
|
106 |
|
|
107 |
/* The rest of the data is optional. If you are reading, check the
|
|
108 |
* valid field to see if the information in these are valid. If you
|
|
109 |
* are writing, set the valid field to those chunks you want written,
|
|
110 |
* and initialize the appropriate fields below.
|
|
111 |
*/
|
|
112 |
|
|
113 |
#if defined(PNG_gAMA_SUPPORTED)
|
|
114 |
/* The gAMA chunk describes the gamma characteristics of the system
|
|
115 |
* on which the image was created, normally in the range [1.0, 2.5].
|
|
116 |
* Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
|
|
117 |
*/
|
|
118 |
png_fixed_point gamma;
|
|
119 |
#endif
|
|
120 |
|
|
121 |
#ifdef PNG_sRGB_SUPPORTED
|
|
122 |
/* GR-P, 0.96a */
|
|
123 |
/* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
|
|
124 |
png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */
|
|
125 |
#endif
|
|
126 |
|
|
127 |
#ifdef PNG_TEXT_SUPPORTED
|
|
128 |
/* The tEXt, and zTXt chunks contain human-readable textual data in
|
|
129 |
* uncompressed, compressed, and optionally compressed forms, respectively.
|
|
130 |
* The data in "text" is an array of pointers to uncompressed,
|
|
131 |
* null-terminated C strings. Each chunk has a keyword that describes the
|
|
132 |
* textual data contained in that chunk. Keywords are not required to be
|
|
133 |
* unique, and the text string may be empty. Any number of text chunks may
|
|
134 |
* be in an image.
|
|
135 |
*/
|
|
136 |
int num_text; /* number of comments read or comments to write */
|
|
137 |
int max_text; /* current size of text array */
|
|
138 |
png_textp text; /* array of comments read or comments to write */
|
|
139 |
#endif /* PNG_TEXT_SUPPORTED */
|
|
140 |
|
|
141 |
#ifdef PNG_tIME_SUPPORTED
|
|
142 |
/* The tIME chunk holds the last time the displayed image data was
|
|
143 |
* modified. See the png_time struct for the contents of this struct.
|
|
144 |
*/
|
|
145 |
png_time mod_time;
|
|
146 |
#endif
|
|
147 |
|
|
148 |
#ifdef PNG_sBIT_SUPPORTED
|
|
149 |
/* The sBIT chunk specifies the number of significant high-order bits
|
|
150 |
* in the pixel data. Values are in the range [1, bit_depth], and are
|
|
151 |
* only specified for the channels in the pixel data. The contents of
|
|
152 |
* the low-order bits is not specified. Data is valid if
|
|
153 |
* (valid & PNG_INFO_sBIT) is non-zero.
|
|
154 |
*/
|
|
155 |
png_color_8 sig_bit; /* significant bits in color channels */
|
|
156 |
#endif
|
|
157 |
|
|
158 |
#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \
|
|
159 |
defined(PNG_READ_BACKGROUND_SUPPORTED)
|
|
160 |
/* The tRNS chunk supplies transparency data for paletted images and
|
|
161 |
* other image types that don't need a full alpha channel. There are
|
|
162 |
* "num_trans" transparency values for a paletted image, stored in the
|
|
163 |
* same order as the palette colors, starting from index 0. Values
|
|
164 |
* for the data are in the range [0, 255], ranging from fully transparent
|
|
165 |
* to fully opaque, respectively. For non-paletted images, there is a
|
|
166 |
* single color specified that should be treated as fully transparent.
|
|
167 |
* Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
|
|
168 |
*/
|
|
169 |
png_bytep trans_alpha; /* alpha values for paletted image */
|
|
170 |
png_color_16 trans_color; /* transparent color for non-palette image */
|
|
171 |
#endif
|
|
172 |
|
|
173 |
#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
|
174 |
/* The bKGD chunk gives the suggested image background color if the
|
|
175 |
* display program does not have its own background color and the image
|
|
176 |
* is needs to composited onto a background before display. The colors
|
|
177 |
* in "background" are normally in the same color space/depth as the
|
|
178 |
* pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
|
|
179 |
*/
|
|
180 |
png_color_16 background;
|
|
181 |
#endif
|
|
182 |
|
|
183 |
#ifdef PNG_oFFs_SUPPORTED
|
|
184 |
/* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
|
|
185 |
* and downwards from the top-left corner of the display, page, or other
|
|
186 |
* application-specific co-ordinate space. See the PNG_OFFSET_ defines
|
|
187 |
* below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.
|
|
188 |
*/
|
|
189 |
png_int_32 x_offset; /* x offset on page */
|
|
190 |
png_int_32 y_offset; /* y offset on page */
|
|
191 |
png_byte offset_unit_type; /* offset units type */
|
|
192 |
#endif
|
|
193 |
|
|
194 |
#ifdef PNG_pHYs_SUPPORTED
|
|
195 |
/* The pHYs chunk gives the physical pixel density of the image for
|
|
196 |
* display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
|
|
197 |
* defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
|
|
198 |
*/
|
|
199 |
png_uint_32 x_pixels_per_unit; /* horizontal pixel density */
|
|
200 |
png_uint_32 y_pixels_per_unit; /* vertical pixel density */
|
|
201 |
png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
|
|
202 |
#endif
|
|
203 |
|
|
204 |
#ifdef PNG_hIST_SUPPORTED
|
|
205 |
/* The hIST chunk contains the relative frequency or importance of the
|
|
206 |
* various palette entries, so that a viewer can intelligently select a
|
|
207 |
* reduced-color palette, if required. Data is an array of "num_palette"
|
|
208 |
* values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
|
|
209 |
* is non-zero.
|
|
210 |
*/
|
|
211 |
png_uint_16p hist;
|
|
212 |
#endif
|
|
213 |
|
|
214 |
#ifdef PNG_cHRM_SUPPORTED
|
|
215 |
/* The cHRM chunk describes the CIE color characteristics of the monitor
|
|
216 |
* on which the PNG was created. This data allows the viewer to do gamut
|
|
217 |
* mapping of the input image to ensure that the viewer sees the same
|
|
218 |
* colors in the image as the creator. Values are in the range
|
|
219 |
* [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero.
|
|
220 |
*/
|
|
221 |
png_fixed_point x_white;
|
|
222 |
png_fixed_point y_white;
|
|
223 |
png_fixed_point x_red;
|
|
224 |
png_fixed_point y_red;
|
|
225 |
png_fixed_point x_green;
|
|
226 |
png_fixed_point y_green;
|
|
227 |
png_fixed_point x_blue;
|
|
228 |
png_fixed_point y_blue;
|
|
229 |
#endif
|
|
230 |
|
|
231 |
#ifdef PNG_pCAL_SUPPORTED
|
|
232 |
/* The pCAL chunk describes a transformation between the stored pixel
|
|
233 |
* values and original physical data values used to create the image.
|
|
234 |
* The integer range [0, 2^bit_depth - 1] maps to the floating-point
|
|
235 |
* range given by [pcal_X0, pcal_X1], and are further transformed by a
|
|
236 |
* (possibly non-linear) transformation function given by "pcal_type"
|
|
237 |
* and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_
|
|
238 |
* defines below, and the PNG-Group's PNG extensions document for a
|
|
239 |
* complete description of the transformations and how they should be
|
|
240 |
* implemented, and for a description of the ASCII parameter strings.
|
|
241 |
* Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
|
|
242 |
*/
|
|
243 |
png_charp pcal_purpose; /* pCAL chunk description string */
|
|
244 |
png_int_32 pcal_X0; /* minimum value */
|
|
245 |
png_int_32 pcal_X1; /* maximum value */
|
|
246 |
png_charp pcal_units; /* Latin-1 string giving physical units */
|
|
247 |
png_charpp pcal_params; /* ASCII strings containing parameter values */
|
|
248 |
png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */
|
|
249 |
png_byte pcal_nparams; /* number of parameters given in pcal_params */
|
|
250 |
#endif
|
|
251 |
|
|
252 |
/* New members added in libpng-1.0.6 */
|
|
253 |
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
|
|
254 |
|
|
255 |
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
|
|
256 |
defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
|
|
257 |
/* Storage for unknown chunks that the library doesn't recognize. */
|
|
258 |
png_unknown_chunkp unknown_chunks;
|
|
259 |
int unknown_chunks_num;
|
|
260 |
#endif
|
|
261 |
|
|
262 |
#ifdef PNG_iCCP_SUPPORTED
|
|
263 |
/* iCCP chunk data. */
|
|
264 |
png_charp iccp_name; /* profile name */
|
|
265 |
png_bytep iccp_profile; /* International Color Consortium profile data */
|
|
266 |
png_uint_32 iccp_proflen; /* ICC profile data length */
|
|
267 |
png_byte iccp_compression; /* Always zero */
|
|
268 |
#endif
|
|
269 |
|
|
270 |
#ifdef PNG_sPLT_SUPPORTED
|
|
271 |
/* Data on sPLT chunks (there may be more than one). */
|
|
272 |
png_sPLT_tp splt_palettes;
|
|
273 |
png_uint_32 splt_palettes_num;
|
|
274 |
#endif
|
|
275 |
|
|
276 |
#ifdef PNG_sCAL_SUPPORTED
|
|
277 |
/* The sCAL chunk describes the actual physical dimensions of the
|
|
278 |
* subject matter of the graphic. The chunk contains a unit specification
|
|
279 |
* a byte value, and two ASCII strings representing floating-point
|
|
280 |
* values. The values are width and height corresponsing to one pixel
|
|
281 |
* in the image. Data values are valid if (valid & PNG_INFO_sCAL) is
|
|
282 |
* non-zero.
|
|
283 |
*/
|
|
284 |
png_byte scal_unit; /* unit of physical scale */
|
|
285 |
png_charp scal_s_width; /* string containing height */
|
|
286 |
png_charp scal_s_height; /* string containing width */
|
|
287 |
#endif
|
|
288 |
|
|
289 |
#ifdef PNG_INFO_IMAGE_SUPPORTED
|
|
290 |
/* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)
|
|
291 |
non-zero */
|
|
292 |
/* Data valid if (valid & PNG_INFO_IDAT) non-zero */
|
|
293 |
png_bytepp row_pointers; /* the image bits */
|
|
294 |
#endif
|
|
295 |
|
|
296 |
};
|
|
297 |
#endif /* PNGINFO_H */
|