CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

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