/* pnginfo.h - internal structures for libpng1*2* Copyright (c) 2018-2025 Cosmin Truta3* Copyright (c) 1998-2002,2004,2006-2013,2018 Glenn Randers-Pehrson4* Copyright (c) 1996-1997 Andreas Dilger5* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.6*7* This code is released under the libpng license.8* For conditions of distribution and use, see the disclaimer9* and license in png.h10*/1112#ifndef PNGPRIV_H13# error This file must not be included by applications; please include <png.h>14#endif1516/* INTERNAL, PRIVATE definition of a PNG.17*18* png_info is a modifiable description of a PNG datastream. The fields inside19* this structure are accessed through png_get_<CHUNK>() functions and modified20* using png_set_<CHUNK>() functions.21*22* Some functions in libpng do directly access members of png_info. However,23* this should be avoided. png_struct objects contain members which hold24* caches, sometimes optimised, of the values from png_info objects, and25* png_info is not passed to the functions which read and write image data.26*/27#ifndef PNGINFO_H28#define PNGINFO_H2930struct png_info_def31{32/* The following are necessary for every PNG file */33png_uint_32 width; /* width of image in pixels (from IHDR) */34png_uint_32 height; /* height of image in pixels (from IHDR) */35png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */36size_t rowbytes; /* bytes needed to hold an untransformed row */37png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */38png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */39png_uint_16 num_trans; /* number of transparent palette color (tRNS) */40png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */41png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */42/* The following three should have been named *_method not *_type */43png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */44png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */45png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */4647/* The following are set by png_set_IHDR, called from the application on48* write, but the are never actually used by the write code.49*/50png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */51png_byte pixel_depth; /* number of bits per pixel */52png_byte spare_byte; /* to align the data, and for future use */5354#ifdef PNG_READ_SUPPORTED55/* This is never set during write */56png_byte signature[8]; /* magic bytes read by libpng from start of file */57#endif5859/* The rest of the data is optional. If you are reading, check the60* valid field to see if the information in these are valid. If you61* are writing, set the valid field to those chunks you want written,62* and initialize the appropriate fields below.63*/6465#ifdef PNG_cICP_SUPPORTED66/* cICP chunk data */67png_byte cicp_colour_primaries;68png_byte cicp_transfer_function;69png_byte cicp_matrix_coefficients;70png_byte cicp_video_full_range_flag;71#endif7273#ifdef PNG_iCCP_SUPPORTED74/* iCCP chunk data. */75png_charp iccp_name; /* profile name */76png_bytep iccp_profile; /* International Color Consortium profile data */77png_uint_32 iccp_proflen; /* ICC profile data length */78#endif7980#ifdef PNG_cLLI_SUPPORTED81png_uint_32 maxCLL; /* cd/m2 (nits) * 10,000 */82png_uint_32 maxFALL;83#endif8485#ifdef PNG_mDCV_SUPPORTED86png_uint_16 mastering_red_x; /* CIE (xy) x * 50,000 */87png_uint_16 mastering_red_y;88png_uint_16 mastering_green_x;89png_uint_16 mastering_green_y;90png_uint_16 mastering_blue_x;91png_uint_16 mastering_blue_y;92png_uint_16 mastering_white_x;93png_uint_16 mastering_white_y;94png_uint_32 mastering_maxDL; /* cd/m2 (nits) * 10,000 */95png_uint_32 mastering_minDL;96#endif9798#ifdef PNG_TEXT_SUPPORTED99/* The tEXt, and zTXt chunks contain human-readable textual data in100* uncompressed, compressed, and optionally compressed forms, respectively.101* The data in "text" is an array of pointers to uncompressed,102* null-terminated C strings. Each chunk has a keyword that describes the103* textual data contained in that chunk. Keywords are not required to be104* unique, and the text string may be empty. Any number of text chunks may105* be in an image.106*/107int num_text; /* number of comments read or comments to write */108int max_text; /* current size of text array */109png_textp text; /* array of comments read or comments to write */110#endif /* TEXT */111112#ifdef PNG_tIME_SUPPORTED113/* The tIME chunk holds the last time the displayed image data was114* modified. See the png_time struct for the contents of this struct.115*/116png_time mod_time;117#endif118119#ifdef PNG_sBIT_SUPPORTED120/* The sBIT chunk specifies the number of significant high-order bits121* in the pixel data. Values are in the range [1, bit_depth], and are122* only specified for the channels in the pixel data. The contents of123* the low-order bits is not specified. Data is valid if124* (valid & PNG_INFO_sBIT) is non-zero.125*/126png_color_8 sig_bit; /* significant bits in color channels */127#endif128129#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \130defined(PNG_READ_BACKGROUND_SUPPORTED)131/* The tRNS chunk supplies transparency data for paletted images and132* other image types that don't need a full alpha channel. There are133* "num_trans" transparency values for a paletted image, stored in the134* same order as the palette colors, starting from index 0. Values135* for the data are in the range [0, 255], ranging from fully transparent136* to fully opaque, respectively. For non-paletted images, there is a137* single color specified that should be treated as fully transparent.138* Data is valid if (valid & PNG_INFO_tRNS) is non-zero.139*/140png_bytep trans_alpha; /* alpha values for paletted image */141png_color_16 trans_color; /* transparent color for non-palette image */142#endif143144#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)145/* The bKGD chunk gives the suggested image background color if the146* display program does not have its own background color and the image147* is needs to composited onto a background before display. The colors148* in "background" are normally in the same color space/depth as the149* pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero.150*/151png_color_16 background;152#endif153154#ifdef PNG_oFFs_SUPPORTED155/* The oFFs chunk gives the offset in "offset_unit_type" units rightwards156* and downwards from the top-left corner of the display, page, or other157* application-specific co-ordinate space. See the PNG_OFFSET_ defines158* below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.159*/160png_int_32 x_offset; /* x offset on page */161png_int_32 y_offset; /* y offset on page */162png_byte offset_unit_type; /* offset units type */163#endif164165#ifdef PNG_pHYs_SUPPORTED166/* The pHYs chunk gives the physical pixel density of the image for167* display or printing in "phys_unit_type" units (see PNG_RESOLUTION_168* defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero.169*/170png_uint_32 x_pixels_per_unit; /* horizontal pixel density */171png_uint_32 y_pixels_per_unit; /* vertical pixel density */172png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */173#endif174175#ifdef PNG_eXIf_SUPPORTED176png_uint_32 num_exif; /* Added at libpng-1.6.31 */177png_bytep exif;178#endif179180#ifdef PNG_hIST_SUPPORTED181/* The hIST chunk contains the relative frequency or importance of the182* various palette entries, so that a viewer can intelligently select a183* 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*/187png_uint_16p hist;188#endif189190#ifdef PNG_pCAL_SUPPORTED191/* The pCAL chunk describes a transformation between the stored pixel192* values and original physical data values used to create the image.193* The integer range [0, 2^bit_depth - 1] maps to the floating-point194* range given by [pcal_X0, pcal_X1], and are further transformed by a195* (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 a198* complete description of the transformations and how they should be199* implemented, and for a description of the ASCII parameter strings.200* Data values are valid if (valid & PNG_INFO_pCAL) non-zero.201*/202png_charp pcal_purpose; /* pCAL chunk description string */203png_int_32 pcal_X0; /* minimum value */204png_int_32 pcal_X1; /* maximum value */205png_charp pcal_units; /* Latin-1 string giving physical units */206png_charpp pcal_params; /* ASCII strings containing parameter values */207png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */208png_byte pcal_nparams; /* number of parameters given in pcal_params */209#endif210211/* New members added in libpng-1.0.6 */212png_uint_32 free_me; /* flags items libpng is responsible for freeing */213214#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED215/* Storage for unknown chunks that the library doesn't recognize. */216png_unknown_chunkp unknown_chunks;217218/* The type of this field is limited by the type of219* png_struct::user_chunk_cache_max, else overflow can occur.220*/221int unknown_chunks_num;222#endif223224#ifdef PNG_sPLT_SUPPORTED225/* Data on sPLT chunks (there may be more than one). */226png_sPLT_tp splt_palettes;227int splt_palettes_num; /* Match type returned by png_get API */228#endif229230#ifdef PNG_sCAL_SUPPORTED231/* The sCAL chunk describes the actual physical dimensions of the232* subject matter of the graphic. The chunk contains a unit specification233* a byte value, and two ASCII strings representing floating-point234* values. The values are width and height corresponding to one pixel235* in the image. Data values are valid if (valid & PNG_INFO_sCAL) is236* non-zero.237*/238png_byte scal_unit; /* unit of physical scale */239png_charp scal_s_width; /* string containing height */240png_charp scal_s_height; /* string containing width */241#endif242243#ifdef PNG_INFO_IMAGE_SUPPORTED244/* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)245non-zero */246/* Data valid if (valid & PNG_INFO_IDAT) non-zero */247png_bytepp row_pointers; /* the image bits */248#endif249250#ifdef PNG_cHRM_SUPPORTED251png_xy cHRM;252#endif253254#ifdef PNG_gAMA_SUPPORTED255png_fixed_point gamma;256#endif257258#ifdef PNG_sRGB_SUPPORTED259int rendering_intent;260#endif261};262#endif /* PNGINFO_H */263264265