VirtualBox

source: vbox/trunk/src/libs/libpng-1.6.45/pnginfo.h

Last change on this file was 107813, checked in by vboxsync, 3 weeks ago

libpng-1.6.45: Applied and adjusted our libpng changes to 1.6.45. bugref:8515

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette