media/libpng/pnginfo.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial