Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

268 lines
12KB

  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. /* png_info is a structure that holds the information in a PNG file so
  13. * that the application can find out the characteristics of the image.
  14. * If you are reading the file, this structure will tell you what is
  15. * in the PNG file. If you are writing the file, fill in the information
  16. * you want to put into the PNG file, using png_set_*() functions, then
  17. * call png_write_info().
  18. *
  19. * The names chosen should be very close to the PNG specification, so
  20. * consult that document for information about the meaning of each field.
  21. *
  22. * With libpng < 0.95, it was only possible to directly set and read the
  23. * the values in the png_info_struct, which meant that the contents and
  24. * order of the values had to remain fixed. With libpng 0.95 and later,
  25. * however, there are now functions that abstract the contents of
  26. * png_info_struct from the application, so this makes it easier to use
  27. * libpng with dynamic libraries, and even makes it possible to use
  28. * libraries that don't have all of the libpng ancillary chunk-handing
  29. * functionality. In libpng-1.5.0 this was moved into a separate private
  30. * file that is not visible to applications.
  31. *
  32. * The following members may have allocated storage attached that should be
  33. * cleaned up before the structure is discarded: palette, trans, text,
  34. * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
  35. * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these
  36. * are automatically freed when the info structure is deallocated, if they were
  37. * allocated internally by libpng. This behavior can be changed by means
  38. * of the png_data_freer() function.
  39. *
  40. * More allocation details: all the chunk-reading functions that
  41. * change these members go through the corresponding png_set_*
  42. * functions. A function to clear these members is available: see
  43. * png_free_data(). The png_set_* functions do not depend on being
  44. * able to point info structure members to any of the storage they are
  45. * passed (they make their own copies), EXCEPT that the png_set_text
  46. * functions use the same storage passed to them in the text_ptr or
  47. * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
  48. * functions do not make their own copies.
  49. */
  50. #ifndef PNGINFO_H
  51. #define PNGINFO_H
  52. struct png_info_def
  53. {
  54. /* The following are necessary for every PNG file */
  55. png_uint_32 width; /* width of image in pixels (from IHDR) */
  56. png_uint_32 height; /* height of image in pixels (from IHDR) */
  57. png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
  58. size_t rowbytes; /* bytes needed to hold an untransformed row */
  59. png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */
  60. png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
  61. png_uint_16 num_trans; /* number of transparent palette color (tRNS) */
  62. png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
  63. png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */
  64. /* The following three should have been named *_method not *_type */
  65. png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
  66. png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
  67. png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
  68. /* The following are set by png_set_IHDR, called from the application on
  69. * write, but the are never actually used by the write code.
  70. */
  71. png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */
  72. png_byte pixel_depth; /* number of bits per pixel */
  73. png_byte spare_byte; /* to align the data, and for future use */
  74. #ifdef PNG_READ_SUPPORTED
  75. /* This is never set during write */
  76. png_byte signature[8]; /* magic bytes read by libpng from start of file */
  77. #endif
  78. /* The rest of the data is optional. If you are reading, check the
  79. * valid field to see if the information in these are valid. If you
  80. * are writing, set the valid field to those chunks you want written,
  81. * and initialize the appropriate fields below.
  82. */
  83. #if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
  84. /* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are
  85. * defined. When COLORSPACE is switched on all the colorspace-defining
  86. * chunks should be enabled, when GAMMA is switched on all the gamma-defining
  87. * chunks should be enabled. If this is not done it becomes possible to read
  88. * inconsistent PNG files and assign a probably incorrect interpretation to
  89. * the information. (In other words, by carefully choosing which chunks to
  90. * recognize the system configuration can select an interpretation for PNG
  91. * files containing ambiguous data and this will result in inconsistent
  92. * behavior between different libpng builds!)
  93. */
  94. png_colorspace colorspace;
  95. #endif
  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. png_uint_32 iccp_proflen; /* ICC profile data length */
  101. #endif
  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. #ifdef PNG_tIME_SUPPORTED
  116. /* The tIME chunk holds the last time the displayed image data was
  117. * modified. See the png_time struct for the contents of this struct.
  118. */
  119. png_time mod_time;
  120. #endif
  121. #ifdef PNG_sBIT_SUPPORTED
  122. /* The sBIT chunk specifies the number of significant high-order bits
  123. * in the pixel data. Values are in the range [1, bit_depth], and are
  124. * only specified for the channels in the pixel data. The contents of
  125. * the low-order bits is not specified. Data is valid if
  126. * (valid & PNG_INFO_sBIT) is non-zero.
  127. */
  128. png_color_8 sig_bit; /* significant bits in color channels */
  129. #endif
  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. #if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
  145. /* The bKGD chunk gives the suggested image background color if the
  146. * display program does not have its own background color and the image
  147. * is needs to composited onto a background before display. The colors
  148. * in "background" are normally in the same color space/depth as the
  149. * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
  150. */
  151. png_color_16 background;
  152. #endif
  153. #ifdef PNG_oFFs_SUPPORTED
  154. /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
  155. * and downwards from the top-left corner of the display, page, or other
  156. * application-specific co-ordinate space. See the PNG_OFFSET_ defines
  157. * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.
  158. */
  159. png_int_32 x_offset; /* x offset on page */
  160. png_int_32 y_offset; /* y offset on page */
  161. png_byte offset_unit_type; /* offset units type */
  162. #endif
  163. #ifdef PNG_pHYs_SUPPORTED
  164. /* The pHYs chunk gives the physical pixel density of the image for
  165. * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
  166. * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
  167. */
  168. png_uint_32 x_pixels_per_unit; /* horizontal pixel density */
  169. png_uint_32 y_pixels_per_unit; /* vertical pixel density */
  170. png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
  171. #endif
  172. #ifdef PNG_eXIf_SUPPORTED
  173. int num_exif; /* Added at libpng-1.6.31 */
  174. png_bytep exif;
  175. # ifdef PNG_READ_eXIf_SUPPORTED
  176. png_bytep eXIf_buf; /* Added at libpng-1.6.32 */
  177. # endif
  178. #endif
  179. #ifdef PNG_hIST_SUPPORTED
  180. /* The hIST chunk contains the relative frequency or importance of the
  181. * various palette entries, so that a viewer can intelligently select a
  182. * reduced-color palette, if required. Data is an array of "num_palette"
  183. * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
  184. * is non-zero.
  185. */
  186. png_uint_16p hist;
  187. #endif
  188. #ifdef PNG_pCAL_SUPPORTED
  189. /* The pCAL chunk describes a transformation between the stored pixel
  190. * values and original physical data values used to create the image.
  191. * The integer range [0, 2^bit_depth - 1] maps to the floating-point
  192. * range given by [pcal_X0, pcal_X1], and are further transformed by a
  193. * (possibly non-linear) transformation function given by "pcal_type"
  194. * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_
  195. * defines below, and the PNG-Group's PNG extensions document for a
  196. * complete description of the transformations and how they should be
  197. * implemented, and for a description of the ASCII parameter strings.
  198. * Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
  199. */
  200. png_charp pcal_purpose; /* pCAL chunk description string */
  201. png_int_32 pcal_X0; /* minimum value */
  202. png_int_32 pcal_X1; /* maximum value */
  203. png_charp pcal_units; /* Latin-1 string giving physical units */
  204. png_charpp pcal_params; /* ASCII strings containing parameter values */
  205. png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */
  206. png_byte pcal_nparams; /* number of parameters given in pcal_params */
  207. #endif
  208. /* New members added in libpng-1.0.6 */
  209. png_uint_32 free_me; /* flags items libpng is responsible for freeing */
  210. #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
  211. /* Storage for unknown chunks that the library doesn't recognize. */
  212. png_unknown_chunkp unknown_chunks;
  213. /* The type of this field is limited by the type of
  214. * png_struct::user_chunk_cache_max, else overflow can occur.
  215. */
  216. int unknown_chunks_num;
  217. #endif
  218. #ifdef PNG_sPLT_SUPPORTED
  219. /* Data on sPLT chunks (there may be more than one). */
  220. png_sPLT_tp splt_palettes;
  221. int splt_palettes_num; /* Match type returned by png_get API */
  222. #endif
  223. #ifdef PNG_sCAL_SUPPORTED
  224. /* The sCAL chunk describes the actual physical dimensions of the
  225. * subject matter of the graphic. The chunk contains a unit specification
  226. * a byte value, and two ASCII strings representing floating-point
  227. * values. The values are width and height corresponding to one pixel
  228. * in the image. Data values are valid if (valid & PNG_INFO_sCAL) is
  229. * non-zero.
  230. */
  231. png_byte scal_unit; /* unit of physical scale */
  232. png_charp scal_s_width; /* string containing height */
  233. png_charp scal_s_height; /* string containing width */
  234. #endif
  235. #ifdef PNG_INFO_IMAGE_SUPPORTED
  236. /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)
  237. non-zero */
  238. /* Data valid if (valid & PNG_INFO_IDAT) non-zero */
  239. png_bytepp row_pointers; /* the image bits */
  240. #endif
  241. };
  242. #endif /* PNGINFO_H */