Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/libpng/pnginfo.h
9833 views
1
/* pnginfo.h - internal structures for libpng
2
*
3
* Copyright (c) 2018-2025 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
#ifndef PNGPRIV_H
14
# error This file must not be included by applications; please include <png.h>
15
#endif
16
17
/* INTERNAL, PRIVATE definition of a PNG.
18
*
19
* png_info is a modifiable description of a PNG datastream. The fields inside
20
* this structure are accessed through png_get_<CHUNK>() functions and modified
21
* using png_set_<CHUNK>() functions.
22
*
23
* Some functions in libpng do directly access members of png_info. However,
24
* this should be avoided. png_struct objects contain members which hold
25
* caches, sometimes optimised, of the values from png_info objects, and
26
* png_info is not passed to the functions which read and write image data.
27
*/
28
#ifndef PNGINFO_H
29
#define PNGINFO_H
30
31
struct png_info_def
32
{
33
/* The following are necessary for every PNG file */
34
png_uint_32 width; /* width of image in pixels (from IHDR) */
35
png_uint_32 height; /* height of image in pixels (from IHDR) */
36
png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
37
size_t rowbytes; /* bytes needed to hold an untransformed row */
38
png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */
39
png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
40
png_uint_16 num_trans; /* number of transparent palette color (tRNS) */
41
png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
42
png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */
43
/* The following three should have been named *_method not *_type */
44
png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
45
png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
46
png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
47
48
/* The following are set by png_set_IHDR, called from the application on
49
* write, but the are never actually used by the write code.
50
*/
51
png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */
52
png_byte pixel_depth; /* number of bits per pixel */
53
png_byte spare_byte; /* to align the data, and for future use */
54
55
#ifdef PNG_READ_SUPPORTED
56
/* This is never set during write */
57
png_byte signature[8]; /* magic bytes read by libpng from start of file */
58
#endif
59
60
/* The rest of the data is optional. If you are reading, check the
61
* valid field to see if the information in these are valid. If you
62
* are writing, set the valid field to those chunks you want written,
63
* and initialize the appropriate fields below.
64
*/
65
66
#ifdef PNG_cICP_SUPPORTED
67
/* cICP chunk data */
68
png_byte cicp_colour_primaries;
69
png_byte cicp_transfer_function;
70
png_byte cicp_matrix_coefficients;
71
png_byte cicp_video_full_range_flag;
72
#endif
73
74
#ifdef PNG_iCCP_SUPPORTED
75
/* iCCP chunk data. */
76
png_charp iccp_name; /* profile name */
77
png_bytep iccp_profile; /* International Color Consortium profile data */
78
png_uint_32 iccp_proflen; /* ICC profile data length */
79
#endif
80
81
#ifdef PNG_cLLI_SUPPORTED
82
png_uint_32 maxCLL; /* cd/m2 (nits) * 10,000 */
83
png_uint_32 maxFALL;
84
#endif
85
86
#ifdef PNG_mDCV_SUPPORTED
87
png_uint_16 mastering_red_x; /* CIE (xy) x * 50,000 */
88
png_uint_16 mastering_red_y;
89
png_uint_16 mastering_green_x;
90
png_uint_16 mastering_green_y;
91
png_uint_16 mastering_blue_x;
92
png_uint_16 mastering_blue_y;
93
png_uint_16 mastering_white_x;
94
png_uint_16 mastering_white_y;
95
png_uint_32 mastering_maxDL; /* cd/m2 (nits) * 10,000 */
96
png_uint_32 mastering_minDL;
97
#endif
98
99
#ifdef PNG_TEXT_SUPPORTED
100
/* The tEXt, and zTXt chunks contain human-readable textual data in
101
* uncompressed, compressed, and optionally compressed forms, respectively.
102
* The data in "text" is an array of pointers to uncompressed,
103
* null-terminated C strings. Each chunk has a keyword that describes the
104
* textual data contained in that chunk. Keywords are not required to be
105
* unique, and the text string may be empty. Any number of text chunks may
106
* be in an image.
107
*/
108
int num_text; /* number of comments read or comments to write */
109
int max_text; /* current size of text array */
110
png_textp text; /* array of comments read or comments to write */
111
#endif /* TEXT */
112
113
#ifdef PNG_tIME_SUPPORTED
114
/* The tIME chunk holds the last time the displayed image data was
115
* modified. See the png_time struct for the contents of this struct.
116
*/
117
png_time mod_time;
118
#endif
119
120
#ifdef PNG_sBIT_SUPPORTED
121
/* The sBIT chunk specifies the number of significant high-order bits
122
* in the pixel data. Values are in the range [1, bit_depth], and are
123
* only specified for the channels in the pixel data. The contents of
124
* the low-order bits is not specified. Data is valid if
125
* (valid & PNG_INFO_sBIT) is non-zero.
126
*/
127
png_color_8 sig_bit; /* significant bits in color channels */
128
#endif
129
130
#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \
131
defined(PNG_READ_BACKGROUND_SUPPORTED)
132
/* The tRNS chunk supplies transparency data for paletted images and
133
* other image types that don't need a full alpha channel. There are
134
* "num_trans" transparency values for a paletted image, stored in the
135
* same order as the palette colors, starting from index 0. Values
136
* for the data are in the range [0, 255], ranging from fully transparent
137
* to fully opaque, respectively. For non-paletted images, there is a
138
* single color specified that should be treated as fully transparent.
139
* Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
140
*/
141
png_bytep trans_alpha; /* alpha values for paletted image */
142
png_color_16 trans_color; /* transparent color for non-palette image */
143
#endif
144
145
#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
146
/* The bKGD chunk gives the suggested image background color if the
147
* display program does not have its own background color and the image
148
* is needs to composited onto a background before display. The colors
149
* in "background" are normally in the same color space/depth as the
150
* pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
151
*/
152
png_color_16 background;
153
#endif
154
155
#ifdef PNG_oFFs_SUPPORTED
156
/* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
157
* and downwards from the top-left corner of the display, page, or other
158
* application-specific co-ordinate space. See the PNG_OFFSET_ defines
159
* below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.
160
*/
161
png_int_32 x_offset; /* x offset on page */
162
png_int_32 y_offset; /* y offset on page */
163
png_byte offset_unit_type; /* offset units type */
164
#endif
165
166
#ifdef PNG_pHYs_SUPPORTED
167
/* The pHYs chunk gives the physical pixel density of the image for
168
* display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
169
* defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
170
*/
171
png_uint_32 x_pixels_per_unit; /* horizontal pixel density */
172
png_uint_32 y_pixels_per_unit; /* vertical pixel density */
173
png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
174
#endif
175
176
#ifdef PNG_eXIf_SUPPORTED
177
png_uint_32 num_exif; /* Added at libpng-1.6.31 */
178
png_bytep exif;
179
#endif
180
181
#ifdef PNG_hIST_SUPPORTED
182
/* The hIST chunk contains the relative frequency or importance of the
183
* various palette entries, so that a viewer can intelligently select a
184
* reduced-color palette, if required. Data is an array of "num_palette"
185
* values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
186
* is non-zero.
187
*/
188
png_uint_16p hist;
189
#endif
190
191
#ifdef PNG_pCAL_SUPPORTED
192
/* The pCAL chunk describes a transformation between the stored pixel
193
* values and original physical data values used to create the image.
194
* The integer range [0, 2^bit_depth - 1] maps to the floating-point
195
* range given by [pcal_X0, pcal_X1], and are further transformed by a
196
* (possibly non-linear) transformation function given by "pcal_type"
197
* and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_
198
* defines below, and the PNG-Group's PNG extensions document for a
199
* complete description of the transformations and how they should be
200
* implemented, and for a description of the ASCII parameter strings.
201
* Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
202
*/
203
png_charp pcal_purpose; /* pCAL chunk description string */
204
png_int_32 pcal_X0; /* minimum value */
205
png_int_32 pcal_X1; /* maximum value */
206
png_charp pcal_units; /* Latin-1 string giving physical units */
207
png_charpp pcal_params; /* ASCII strings containing parameter values */
208
png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */
209
png_byte pcal_nparams; /* number of parameters given in pcal_params */
210
#endif
211
212
/* New members added in libpng-1.0.6 */
213
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
214
215
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
216
/* Storage for unknown chunks that the library doesn't recognize. */
217
png_unknown_chunkp unknown_chunks;
218
219
/* The type of this field is limited by the type of
220
* png_struct::user_chunk_cache_max, else overflow can occur.
221
*/
222
int unknown_chunks_num;
223
#endif
224
225
#ifdef PNG_sPLT_SUPPORTED
226
/* Data on sPLT chunks (there may be more than one). */
227
png_sPLT_tp splt_palettes;
228
int splt_palettes_num; /* Match type returned by png_get API */
229
#endif
230
231
#ifdef PNG_sCAL_SUPPORTED
232
/* The sCAL chunk describes the actual physical dimensions of the
233
* subject matter of the graphic. The chunk contains a unit specification
234
* a byte value, and two ASCII strings representing floating-point
235
* values. The values are width and height corresponding to one pixel
236
* in the image. Data values are valid if (valid & PNG_INFO_sCAL) is
237
* non-zero.
238
*/
239
png_byte scal_unit; /* unit of physical scale */
240
png_charp scal_s_width; /* string containing height */
241
png_charp scal_s_height; /* string containing width */
242
#endif
243
244
#ifdef PNG_INFO_IMAGE_SUPPORTED
245
/* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)
246
non-zero */
247
/* Data valid if (valid & PNG_INFO_IDAT) non-zero */
248
png_bytepp row_pointers; /* the image bits */
249
#endif
250
251
#ifdef PNG_cHRM_SUPPORTED
252
png_xy cHRM;
253
#endif
254
255
#ifdef PNG_gAMA_SUPPORTED
256
png_fixed_point gamma;
257
#endif
258
259
#ifdef PNG_sRGB_SUPPORTED
260
int rendering_intent;
261
#endif
262
};
263
#endif /* PNGINFO_H */
264
265