PageRenderTime 208ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 1ms

/src/core/environ/win32/bcb2006/include/libpng/PNG.H

http://tvpcn.codeplex.com
C++ Header | 2816 lines | 1694 code | 393 blank | 729 comment | 55 complexity | 52966f4a3da0ae9b32d8c20ca9f16d62 MD5 | raw file
Possible License(s): LGPL-3.0, MIT, LGPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. /* png.h - header file for PNG reference library
  2. *
  3. * libpng version 1.0.6 - March 21, 2000
  4. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  5. * Copyright (c) 1996, 1997 Andreas Dilger
  6. * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
  7. *
  8. * Authors and maintainers:
  9. * libpng versions 0.71, May 1995, through 0.89c, May 1996: Guy Schalnat
  10. * libpng versions 0.90, December 1996, through 0.96, May 1997: Andreas Dilger
  11. * libpng versions 0.97, January 1998, through 1.0.6 - March 21, 2000: Glenn
  12. * See also "Contributing Authors", below.
  13. *
  14. * Note about libpng version numbers:
  15. *
  16. * Due to various miscommunications, unforeseen code incompatibilities
  17. * and occasional factors outside the authors' control, version numbering
  18. * on the library has not always been consistent and straightforward.
  19. * The following table summarizes matters since version 0.89c, which was
  20. * the first widely used release:
  21. *
  22. * source png.h png.h shared-lib
  23. * version string int version
  24. * ------- ------ ----- ----------
  25. * 0.89c ("1.0 beta 3") 0.89 89 1.0.89
  26. * 0.90 ("1.0 beta 4") 0.90 90 0.90 [should have been 2.0.90]
  27. * 0.95 ("1.0 beta 5") 0.95 95 0.95 [should have been 2.0.95]
  28. * 0.96 ("1.0 beta 6") 0.96 96 0.96 [should have been 2.0.96]
  29. * 0.97b ("1.00.97 beta 7") 1.00.97 97 1.0.1 [should have been 2.0.97]
  30. * 0.97c 0.97 97 2.0.97
  31. * 0.98 0.98 98 2.0.98
  32. * 0.99 0.99 98 2.0.99
  33. * 0.99a-m 0.99 99 2.0.99
  34. * 1.00 1.00 100 2.1.0 [100 should be 10000]
  35. * 1.0.0 1.0.0 100 2.1.0 [100 should be 10000]
  36. * 1.0.1 1.0.1 10001 2.1.0
  37. * 1.0.1a-e 1.0.1a-e 10002 2.1.0.1a-e
  38. * 1.0.2 1.0.2 10002 2.1.0.2
  39. * 1.0.2a-b 1.0.2a-b 10003 2.1.0.2a-b
  40. * 1.0.3 1.0.3 10003 2.1.0.3
  41. * 1.0.3a-d 1.0.3a-d 10004 2.1.0.3a-d
  42. * 1.0.4 1.0.4 10004 2.1.0.4
  43. * 1.0.4a-f 1.0.4a-f 10005 2.1.0.4a-f
  44. * 1.0.5 1.0.5 10005 2.1.0.5
  45. * 1.0.5a-d 1.0.5a-d 10006 2.1.0.5a-d
  46. * 1.0.5e-r 1.0.5e-r 10100 2.1.0.5e-r (not compatible)
  47. * 1.0.5s-v 1.0.5s-v 10006 2.1.0.5s-w (compatible)
  48. * 1.0.6 1.0.6 10006 2.1.0.6
  49. * 1.3.0 1.3.0 10300 3.1.3.0
  50. *
  51. * Henceforth the source version will match the shared-library minor
  52. * and patch numbers; the shared-library major version number will be
  53. * used for changes in backward compatibility, as it is intended. The
  54. * PNG_PNGLIB_VER macro, which is not used within libpng but is available
  55. * for applications, is an unsigned integer of the form xyyzz corresponding
  56. * to the source version x.y.z (leading zeros in y and z). Internal
  57. * png-group beta versions (x.y.z[a-z]) will be given the next higher
  58. * number.
  59. *
  60. * See libpng.txt or libpng.3 for more information. The PNG specification
  61. * is available as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/>
  62. * and as a W3C Recommendation <http://www.w3.org/TR/REC.png.html>
  63. */
  64. /*
  65. * COPYRIGHT NOTICE:
  66. *
  67. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  68. * (libpng versions 0.5, May 1995, through 0.89c, May 1996)
  69. * Copyright (c) 1996, 1997 Andreas Dilger
  70. * (libpng versions 0.90, December 1996, through 0.96, May 1997)
  71. * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
  72. * (libpng versions 0.97, January 1998, through 1.0.6, March 21, 2000)
  73. *
  74. * For the purposes of this copyright and license, "Contributing Authors"
  75. * is defined as the following set of individuals:
  76. *
  77. * John Bowler
  78. * Kevin Bracey
  79. * Sam Bushell
  80. * Andreas Dilger
  81. * Magnus Holmgren
  82. * Tom Lane
  83. * Dave Martindale
  84. * Glenn Randers-Pehrson
  85. * Eric S. Raymond
  86. * Greg Roelofs
  87. * Guy Eric Schalnat
  88. * Paul Schmidt
  89. * Tom Tanner
  90. * Willem van Schaik
  91. * Tim Wegner
  92. *
  93. * The PNG Reference Library is supplied "AS IS". The Contributing Authors
  94. * and Group 42, Inc. disclaim all warranties, expressed or implied,
  95. * including, without limitation, the warranties of merchantability and of
  96. * fitness for any purpose. The Contributing Authors and Group 42, Inc.
  97. * assume no liability for direct, indirect, incidental, special, exemplary,
  98. * or consequential damages, which may result from the use of the PNG
  99. * Reference Library, even if advised of the possibility of such damage.
  100. *
  101. * Permission is hereby granted to use, copy, modify, and distribute this
  102. * source code, or portions hereof, for any purpose, without fee, subject
  103. * to the following restrictions:
  104. *
  105. * 1. The origin of this source code must not be misrepresented.
  106. *
  107. * 2. Altered versions must be plainly marked as such and must not
  108. * be misrepresented as being the original source.
  109. *
  110. * 3. This Copyright notice may not be removed or altered from any
  111. * source or altered source distribution.
  112. *
  113. * The Contributing Authors and Group 42, Inc. specifically permit, without
  114. * fee, and encourage the use of this source code as a component to
  115. * supporting the PNG file format in commercial products. If you use this
  116. * source code in a product, acknowledgment is not required but would be
  117. * appreciated.
  118. */
  119. /*
  120. * A "png_get_copyright" function is available, for convenient use in "about"
  121. * boxes and the like:
  122. *
  123. * printf("%s",png_get_copyright(NULL));
  124. *
  125. * Also, the PNG logo (in PNG format, of course) is supplied in the
  126. * file "pngnow.png".
  127. */
  128. /*
  129. * Libpng is OSI Certified Open Source Software. OSI Certified is a
  130. * certification mark of the Open Source Initiative.
  131. */
  132. /*
  133. * The contributing authors would like to thank all those who helped
  134. * with testing, bug fixes, and patience. This wouldn't have been
  135. * possible without all of you.
  136. *
  137. * Thanks to Frank J. T. Wojcik for helping with the documentation.
  138. */
  139. /*
  140. * Y2K compliance in libpng:
  141. * =========================
  142. *
  143. * March 21, 2000
  144. *
  145. * Since the PNG Development group is an ad-hoc body, we can't make
  146. * an official declaration.
  147. *
  148. * This is your unofficial assurance that libpng from version 0.71 and
  149. * upward through 1.0.6 are Y2K compliant. It is my belief that earlier
  150. * versions were also Y2K compliant.
  151. *
  152. * Libpng only has three year fields. One is a 2-byte unsigned integer
  153. * that will hold years up to 65535. The other two hold the date in text
  154. * format, and will hold years up to 9999.
  155. *
  156. * The integer is
  157. * "png_uint_16 year" in png_time_struct.
  158. *
  159. * The strings are
  160. * "png_charp time_buffer" in png_struct and
  161. * "near_time_buffer", which is a local character string in png.c.
  162. *
  163. * There are seven time-related functions:
  164. * png.c: png_convert_to_rfc_1123() in png.c
  165. * (formerly png_convert_to_rfc_1152() in error)
  166. * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
  167. * png_convert_from_time_t() in pngwrite.c
  168. * png_get_tIME() in pngget.c
  169. * png_handle_tIME() in pngrutil.c, called in pngread.c
  170. * png_set_tIME() in pngset.c
  171. * png_write_tIME() in pngwutil.c, called in pngwrite.c
  172. *
  173. * All handle dates properly in a Y2K environment. The
  174. * png_convert_from_time_t() function calls gmtime() to convert from system
  175. * clock time, which returns (year - 1900), which we properly convert to
  176. * the full 4-digit year. There is a possibility that applications using
  177. * libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
  178. * function, or that they are incorrectly passing only a 2-digit year
  179. * instead of "year - 1900" into the png_convert_from_struct_tm() function,
  180. * but this is not under our control. The libpng documentation has always
  181. * stated that it works with 4-digit years, and the APIs have been
  182. * documented as such.
  183. *
  184. * The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
  185. * integer to hold the year, and can hold years as large as 65535.
  186. *
  187. * zlib, upon which libpng depends, is also Y2K compliant. It contains
  188. * no date-related code.
  189. *
  190. * Glenn Randers-Pehrson
  191. * libpng maintainer
  192. * PNG Development Group
  193. */
  194. #ifndef _PNG_H
  195. #define _PNG_H
  196. /* This is not the place to learn how to use libpng. The file libpng.txt
  197. * describes how to use libpng, and the file example.c summarizes it
  198. * with some code on which to build. This file is useful for looking
  199. * at the actual function definitions and structure components.
  200. */
  201. /* include the compression library's header */
  202. #include <zlib/zlib.h>
  203. /* include all user configurable info */
  204. #include "pngconf.h"
  205. /* macros for optional assembler routines */
  206. #if defined(PNG_INTERNAL) && defined(PNG_ASSEMBLER_CODE_SUPPORTED)
  207. # include "pngasmrd.h"
  208. #endif
  209. /* Inhibit C++ name-mangling for libpng functions but not for system calls. */
  210. #ifdef __cplusplus
  211. extern "C" {
  212. #endif /* __cplusplus */
  213. /* This file is arranged in several sections. The first section contains
  214. * structure and type definitions. The second section contains the external
  215. * library functions, while the third has the internal library functions,
  216. * which applications aren't expected to use directly.
  217. */
  218. /* Version information for png.h - this should match the version in png.c */
  219. #define PNG_LIBPNG_VER_STRING "1.0.6"
  220. /* Careful here. At one time, Guy wanted to use 082, but that would be octal.
  221. * We must not include leading zeros.
  222. * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
  223. * version 1.0.0 was mis-numbered 100 instead of 10000). From
  224. * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=bugfix */
  225. #define PNG_LIBPNG_VER 10006 /* 1.0.6 */
  226. /* Note to maintainer: update this number in scripts/pngdef.pas as well */
  227. /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
  228. #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
  229. /* Version information for C files, stored in png.c. This had better match
  230. * the version above.
  231. */
  232. #ifdef PNG_USE_GLOBAL_ARRAYS
  233. PNG_EXPORT_VAR (char) png_libpng_ver[12]; /* need room for 99.99.99aa */
  234. #else
  235. #define png_libpng_ver png_get_header_ver(NULL)
  236. #endif
  237. #ifdef PNG_USE_GLOBAL_ARRAYS
  238. /* This was removed in version 1.0.5c */
  239. /* Structures to facilitate easy interlacing. See png.c for more details */
  240. PNG_EXPORT_VAR (int FARDATA) png_pass_start[7];
  241. PNG_EXPORT_VAR (int FARDATA) png_pass_inc[7];
  242. PNG_EXPORT_VAR (int FARDATA) png_pass_ystart[7];
  243. PNG_EXPORT_VAR (int FARDATA) png_pass_yinc[7];
  244. PNG_EXPORT_VAR (int FARDATA) png_pass_mask[7];
  245. PNG_EXPORT_VAR (int FARDATA) png_pass_dsp_mask[7];
  246. #ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
  247. extern int FARDATA png_pass_width[7]; /* now used in pngvcrd.c, pnggccrd.c */
  248. #endif
  249. /* This isn't currently used. If you need it, see png.c for more details.
  250. extern int FARDATA png_pass_height[7];
  251. */
  252. #endif
  253. #endif /* PNG_NO_EXTERN */
  254. /* Three color definitions. The order of the red, green, and blue, (and the
  255. * exact size) is not important, although the size of the fields need to
  256. * be png_byte or png_uint_16 (as defined below).
  257. */
  258. typedef struct png_color_struct
  259. {
  260. png_byte red;
  261. png_byte green;
  262. png_byte blue;
  263. } png_color;
  264. typedef png_color FAR * png_colorp;
  265. typedef png_color FAR * FAR * png_colorpp;
  266. typedef struct png_color_16_struct
  267. {
  268. png_byte index; /* used for palette files */
  269. png_uint_16 red; /* for use in red green blue files */
  270. png_uint_16 green;
  271. png_uint_16 blue;
  272. png_uint_16 gray; /* for use in grayscale files */
  273. } png_color_16;
  274. typedef png_color_16 FAR * png_color_16p;
  275. typedef png_color_16 FAR * FAR * png_color_16pp;
  276. typedef struct png_color_8_struct
  277. {
  278. png_byte red; /* for use in red green blue files */
  279. png_byte green;
  280. png_byte blue;
  281. png_byte gray; /* for use in grayscale files */
  282. png_byte alpha; /* for alpha channel files */
  283. } png_color_8;
  284. typedef png_color_8 FAR * png_color_8p;
  285. typedef png_color_8 FAR * FAR * png_color_8pp;
  286. /*
  287. * The following two structures are used for the in-core representation
  288. * of sPLT chunks.
  289. */
  290. typedef struct png_sPLT_entry_struct
  291. {
  292. png_uint_16 red;
  293. png_uint_16 green;
  294. png_uint_16 blue;
  295. png_uint_16 alpha;
  296. png_uint_16 frequency;
  297. } png_sPLT_entry;
  298. typedef png_sPLT_entry FAR * png_sPLT_entryp;
  299. typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp;
  300. typedef struct png_sPLT_struct
  301. {
  302. png_charp name; /* palette name */
  303. png_byte depth; /* depth of palette samples */
  304. png_sPLT_entryp entries; /* palette entries */
  305. png_int_32 nentries; /* number of palette entries */
  306. } png_sPLT_t;
  307. typedef png_sPLT_t FAR * png_sPLT_tp;
  308. typedef png_sPLT_t FAR * FAR * png_sPLT_tpp;
  309. #ifdef PNG_TEXT_SUPPORTED
  310. /* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,
  311. * and whether that contents is compressed or not. The "key" field
  312. * points to a regular C string. */
  313. typedef struct png_text_struct
  314. {
  315. int compression; /* compression value:
  316. -1: tEXt, none
  317. 0: zTXt, deflate
  318. 1: iTXt, none
  319. 2: iTXt, deflate */
  320. png_charp key; /* keyword, 1-79 character description of "text" */
  321. png_charp text; /* comment, may be an empty string (ie "") */
  322. png_size_t text_length; /* length of the text string */
  323. png_size_t itxt_length; /* length of the itxt string */
  324. png_charp lang; /* language code, 1-79 characters */
  325. png_charp lang_key; /* keyword translated UTF-8 string, 0 or more
  326. chars */
  327. } png_text;
  328. typedef png_text FAR * png_textp;
  329. typedef png_text FAR * FAR * png_textpp;
  330. #endif
  331. /* Supported compression types for text in PNG files (tEXt, and zTXt).
  332. * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */
  333. #define PNG_TEXT_COMPRESSION_NONE_WR -3
  334. #define PNG_TEXT_COMPRESSION_zTXt_WR -2
  335. #define PNG_TEXT_COMPRESSION_NONE -1
  336. #define PNG_TEXT_COMPRESSION_zTXt 0
  337. #define PNG_ITXT_COMPRESSION_NONE 1
  338. #define PNG_ITXT_COMPRESSION_zTXt 2
  339. #define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */
  340. /* png_time is a way to hold the time in an machine independent way.
  341. * Two conversions are provided, both from time_t and struct tm. There
  342. * is no portable way to convert to either of these structures, as far
  343. * as I know. If you know of a portable way, send it to me. As a side
  344. * note - PNG is Year 2000 compliant!
  345. */
  346. typedef struct png_time_struct
  347. {
  348. png_uint_16 year; /* full year, as in, 1995 */
  349. png_byte month; /* month of year, 1 - 12 */
  350. png_byte day; /* day of month, 1 - 31 */
  351. png_byte hour; /* hour of day, 0 - 23 */
  352. png_byte minute; /* minute of hour, 0 - 59 */
  353. png_byte second; /* second of minute, 0 - 60 (for leap seconds) */
  354. } png_time;
  355. typedef png_time FAR * png_timep;
  356. typedef png_time FAR * FAR * png_timepp;
  357. #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
  358. /* png_unknown_chunk is a structure to hold queued chunks for which there is
  359. * no specific support. The idea is that we can use this to queue
  360. * up private chunks for output even though the library doesn't actually
  361. * know about their semantics.
  362. */
  363. typedef struct png_unknown_chunk_t
  364. {
  365. png_byte name[5];
  366. png_byte *data;
  367. png_size_t size;
  368. /* libpng-using applications should NOT directly modify this byte. */
  369. png_byte location; /* mode of operation at read time */
  370. }
  371. png_unknown_chunk;
  372. typedef png_unknown_chunk FAR * png_unknown_chunkp;
  373. typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;
  374. #endif
  375. /* png_info is a structure that holds the information in a PNG file so
  376. * that the application can find out the characteristics of the image.
  377. * If you are reading the file, this structure will tell you what is
  378. * in the PNG file. If you are writing the file, fill in the information
  379. * you want to put into the PNG file, then call png_write_info().
  380. * The names chosen should be very close to the PNG specification, so
  381. * consult that document for information about the meaning of each field.
  382. *
  383. * With libpng < 0.95, it was only possible to directly set and read the
  384. * the values in the png_info_struct, which meant that the contents and
  385. * order of the values had to remain fixed. With libpng 0.95 and later,
  386. * however, there are now functions that abstract the contents of
  387. * png_info_struct from the application, so this makes it easier to use
  388. * libpng with dynamic libraries, and even makes it possible to use
  389. * libraries that don't have all of the libpng ancillary chunk-handing
  390. * functionality.
  391. *
  392. * In any case, the order of the parameters in png_info_struct should NOT
  393. * be changed for as long as possible to keep compatibility with applications
  394. * that use the old direct-access method with png_info_struct.
  395. *
  396. * The following members may have allocated storage attached that should be
  397. * cleaned up before the structure is discarded: palette, trans, text,
  398. * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
  399. * splt_palettes, scal_unit, and row_pointers. These are automatically
  400. * freed when the info structure is deallocated.
  401. *
  402. * More allocation details: all the chunk-reading functions that change these
  403. * members go through the corresponding png_set_* functions. Functions to
  404. * clear these members are available: see png_free_*. The png_set_* functions
  405. * do not depend on being able to point info structure members to any of the
  406. * storage they are passed (they make their own copies), EXCEPT that the
  407. * png_set_text function uses the same storage passed to them
  408. * in the text_ptr or itxt_ptr structure argument.
  409. */
  410. typedef struct png_info_struct
  411. {
  412. /* the following are necessary for every PNG file */
  413. png_uint_32 width; /* width of image in pixels (from IHDR) */
  414. png_uint_32 height; /* height of image in pixels (from IHDR) */
  415. png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
  416. png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */
  417. png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */
  418. png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
  419. png_uint_16 num_trans; /* number of transparent palette color (tRNS) */
  420. png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
  421. png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */
  422. png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
  423. png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
  424. png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
  425. /* The following is informational only on read, and not used on writes. */
  426. png_byte channels; /* number of data channels per pixel (1, 2, 3, 4)*/
  427. png_byte pixel_depth; /* number of bits per pixel */
  428. png_byte spare_byte; /* to align the data, and for future use */
  429. png_byte signature[8]; /* magic bytes read by libpng from start of file */
  430. /* The rest of the data is optional. If you are reading, check the
  431. * valid field to see if the information in these are valid. If you
  432. * are writing, set the valid field to those chunks you want written,
  433. * and initialize the appropriate fields below.
  434. */
  435. png_uint_32 free_me; /* flags items libpng is responsible for freeing */
  436. #if defined(PNG_gAMA_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED)
  437. /* The gAMA chunk describes the gamma characteristics of the system
  438. * on which the image was created, normally in the range [1.0, 2.5].
  439. * Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
  440. */
  441. #ifdef PNG_FLOATING_POINT_SUPPORTED
  442. float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */
  443. #endif
  444. png_fixed_point int_gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */
  445. #endif
  446. #if defined(PNG_sRGB_SUPPORTED)
  447. /* GR-P, 0.96a */
  448. /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
  449. png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */
  450. #endif
  451. #if defined(PNG_TEXT_SUPPORTED)
  452. /* The tEXt, and zTXt chunks contain human-readable textual data in
  453. * uncompressed, compressed, and optionally compressed forms, respectively.
  454. * The data in "text" is an array of pointers to uncompressed,
  455. * null-terminated C strings. Each chunk has a keyword that describes the
  456. * textual data contained in that chunk. Keywords are not required to be
  457. * unique, and the text string may be empty. Any number of text chunks may
  458. * be in an image.
  459. */
  460. int num_text; /* number of comments read/to write */
  461. int max_text; /* current size of text array */
  462. png_textp text; /* array of comments read/to write */
  463. int num_text_old; /* number of comments read/to write */
  464. png_textp text_old; /* array of comments read/to write, backward
  465. compatible with libpng-1.0.5 and earlier */
  466. #endif /* PNG_TEXT_SUPPORTED */
  467. #if defined(PNG_tIME_SUPPORTED)
  468. /* The tIME chunk holds the last time the displayed image data was
  469. * modified. See the png_time struct for the contents of this struct.
  470. */
  471. png_time mod_time;
  472. #endif
  473. #if defined(PNG_sBIT_SUPPORTED)
  474. /* The sBIT chunk specifies the number of significant high-order bits
  475. * in the pixel data. Values are in the range [1, bit_depth], and are
  476. * only specified for the channels in the pixel data. The contents of
  477. * the low-order bits is not specified. Data is valid if
  478. * (valid & PNG_INFO_sBIT) is non-zero.
  479. */
  480. png_color_8 sig_bit; /* significant bits in color channels */
  481. #endif
  482. #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \
  483. defined(PNG_READ_BACKGROUND_SUPPORTED)
  484. /* The tRNS chunk supplies transparency data for paletted images and
  485. * other image types that don't need a full alpha channel. There are
  486. * "num_trans" transparency values for a paletted image, stored in the
  487. * same order as the palette colors, starting from index 0. Values
  488. * for the data are in the range [0, 255], ranging from fully transparent
  489. * to fully opaque, respectively. For non-paletted images, there is a
  490. * single color specified that should be treated as fully transparent.
  491. * Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
  492. */
  493. png_bytep trans; /* transparent values for paletted image */
  494. png_color_16 trans_values; /* transparent color for non-palette image */
  495. #endif
  496. #if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
  497. /* The bKGD chunk gives the suggested image background color if the
  498. * display program does not have its own background color and the image
  499. * is needs to composited onto a background before display. The colors
  500. * in "background" are normally in the same color space/depth as the
  501. * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
  502. */
  503. png_color_16 background;
  504. #endif
  505. #if defined(PNG_oFFs_SUPPORTED)
  506. /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
  507. * and downwards from the top-left corner of the display, page, or other
  508. * application-specific co-ordinate space. See the PNG_OFFSET_ defines
  509. * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.
  510. */
  511. png_int_32 x_offset; /* x offset on page */
  512. png_int_32 y_offset; /* y offset on page */
  513. png_byte offset_unit_type; /* offset units type */
  514. #endif
  515. #if defined(PNG_pHYs_SUPPORTED)
  516. /* The pHYs chunk gives the physical pixel density of the image for
  517. * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
  518. * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
  519. */
  520. png_uint_32 x_pixels_per_unit; /* horizontal pixel density */
  521. png_uint_32 y_pixels_per_unit; /* vertical pixel density */
  522. png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
  523. #endif
  524. #if defined(PNG_hIST_SUPPORTED)
  525. /* The hIST chunk contains the relative frequency or importance of the
  526. * various palette entries, so that a viewer can intelligently select a
  527. * reduced-color palette, if required. Data is an array of "num_palette"
  528. * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
  529. * is non-zero.
  530. */
  531. png_uint_16p hist;
  532. #endif
  533. #if defined(PNG_cHRM_SUPPORTED)
  534. /* The cHRM chunk describes the CIE color characteristics of the monitor
  535. * on which the PNG was created. This data allows the viewer to do gamut
  536. * mapping of the input image to ensure that the viewer sees the same
  537. * colors in the image as the creator. Values are in the range
  538. * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero.
  539. */
  540. #ifdef PNG_FLOATING_POINT_SUPPORTED
  541. float x_white;
  542. float y_white;
  543. float x_red;
  544. float y_red;
  545. float x_green;
  546. float y_green;
  547. float x_blue;
  548. float y_blue;
  549. #endif
  550. #ifdef PNG_FIXED_POINT_SUPPORTED
  551. png_fixed_point int_x_white;
  552. png_fixed_point int_y_white;
  553. png_fixed_point int_x_red;
  554. png_fixed_point int_y_red;
  555. png_fixed_point int_x_green;
  556. png_fixed_point int_y_green;
  557. png_fixed_point int_x_blue;
  558. png_fixed_point int_y_blue;
  559. #endif
  560. #endif
  561. #if defined(PNG_pCAL_SUPPORTED)
  562. /* The pCAL chunk describes a transformation between the stored pixel
  563. * values and original physical data values used to create the image.
  564. * The integer range [0, 2^bit_depth - 1] maps to the floating-point
  565. * range given by [pcal_X0, pcal_X1], and are further transformed by a
  566. * (possibly non-linear) transformation function given by "pcal_type"
  567. * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_
  568. * defines below, and the PNG-Group's Scientific Visualization extension
  569. * chunks document png-scivis-19970203 for a complete description of the
  570. * transformations and how they should be implemented, as well as the
  571. * png-extensions document for a description of the ASCII parameter
  572. * strings. Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
  573. */
  574. png_charp pcal_purpose; /* pCAL chunk description string */
  575. png_int_32 pcal_X0; /* minimum value */
  576. png_int_32 pcal_X1; /* maximum value */
  577. png_charp pcal_units; /* Latin-1 string giving physical units */
  578. png_charpp pcal_params; /* ASCII strings containing parameter values */
  579. png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */
  580. png_byte pcal_nparams; /* number of parameters given in pcal_params */
  581. #endif
  582. #if defined(PNG_iCCP_SUPPORTED)
  583. /* iCCP chunk data. */
  584. png_charp iccp_name; /* profile name */
  585. png_charp iccp_profile; /* International Color Consortium profile data */
  586. png_uint_32 iccp_proflen; /* ICC profile data length */
  587. png_byte iccp_compression; /* Always zero */
  588. #endif
  589. #if defined(PNG_sPLT_SUPPORTED)
  590. /* data on sPLT chunks (there may be more than one). */
  591. png_sPLT_tp splt_palettes;
  592. png_uint_32 splt_palettes_num;
  593. #endif
  594. #if defined(PNG_sCAL_SUPPORTED)
  595. /* The sCAL chunk describes the actual physical dimensions of the
  596. * subject matter of the graphic. The chunk contains a unit specification
  597. * a byte value, and two ASCII strings representing floating-point
  598. * values. The values are width and height corresponsing to one pixel
  599. * in the image. This external representation is converted to double
  600. * here. Data values are valid if (valid & PNG_INFO_sCAL) is non-zero.
  601. */
  602. png_byte scal_unit; /* unit of physical scale */
  603. #ifdef PNG_FLOATING_POINT_SUPPORTED
  604. double scal_pixel_width; /* width of one pixel */
  605. double scal_pixel_height; /* height of one pixel */
  606. #endif
  607. #ifdef PNG_FIXED_POINT_SUPPORTED
  608. png_charp scal_s_width; /* string containing height */
  609. png_charp scal_s_height; /* string containing width */
  610. #endif
  611. #endif
  612. #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
  613. /* storage for unknown chunks that the library doesn't recognize. */
  614. png_unknown_chunkp unknown_chunks;
  615. png_size_t unknown_chunks_num;
  616. #endif
  617. #if defined(PNG_INFO_IMAGE_SUPPORTED)
  618. /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */
  619. /* Data valid if (valid & PNG_INFO_IDAT) non-zero */
  620. png_bytepp row_pointers; /* the image bits */
  621. #endif
  622. } png_info;
  623. typedef png_info FAR * png_infop;
  624. typedef png_info FAR * FAR * png_infopp;
  625. /* Maximum positive integer used in PNG is (2^31)-1 */
  626. #define PNG_MAX_UINT ((png_uint_32)0x7fffffffL)
  627. /* These describe the color_type field in png_info. */
  628. /* color type masks */
  629. #define PNG_COLOR_MASK_PALETTE 1
  630. #define PNG_COLOR_MASK_COLOR 2
  631. #define PNG_COLOR_MASK_ALPHA 4
  632. /* color types. Note that not all combinations are legal */
  633. #define PNG_COLOR_TYPE_GRAY 0
  634. #define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
  635. #define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR)
  636. #define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  637. #define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
  638. /* This is for compression type. PNG 1.0-1.2 only define the single type. */
  639. #define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */
  640. #define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE
  641. /* This is for filter type. PNG 1.0-1.2 only define the single type. */
  642. #define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */
  643. #define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE
  644. /* These are for the interlacing type. These values should NOT be changed. */
  645. #define PNG_INTERLACE_NONE 0 /* Non-interlaced image */
  646. #define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */
  647. #define PNG_INTERLACE_LAST 2 /* Not a valid value */
  648. /* These are for the oFFs chunk. These values should NOT be changed. */
  649. #define PNG_OFFSET_PIXEL 0 /* Offset in pixels */
  650. #define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */
  651. #define PNG_OFFSET_LAST 2 /* Not a valid value */
  652. /* These are for the pCAL chunk. These values should NOT be changed. */
  653. #define PNG_EQUATION_LINEAR 0 /* Linear transformation */
  654. #define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */
  655. #define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */
  656. #define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */
  657. #define PNG_EQUATION_LAST 4 /* Not a valid value */
  658. /* These are for the sCAL chunk. These values should NOT be changed. */
  659. #define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */
  660. #define PNG_SCALE_METER 1 /* meters per pixel */
  661. #define PNG_SCALE_RADIAN 2 /* radians per pixel */
  662. #define PNG_SCALE_LAST 3 /* Not a valid value */
  663. /* These are for the pHYs chunk. These values should NOT be changed. */
  664. #define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */
  665. #define PNG_RESOLUTION_METER 1 /* pixels/meter */
  666. #define PNG_RESOLUTION_LAST 2 /* Not a valid value */
  667. /* These are for the sRGB chunk. These values should NOT be changed. */
  668. #define PNG_sRGB_INTENT_PERCEPTUAL 0
  669. #define PNG_sRGB_INTENT_RELATIVE 1
  670. #define PNG_sRGB_INTENT_SATURATION 2
  671. #define PNG_sRGB_INTENT_ABSOLUTE 3
  672. #define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */
  673. /* This is for text chunks */
  674. #define PNG_KEYWORD_MAX_LENGTH 79
  675. /* These determine if an ancillary chunk's data has been successfully read
  676. * from the PNG header, or if the application has filled in the corresponding
  677. * data in the info_struct to be written into the output file. The values
  678. * of the PNG_INFO_<chunk> defines should NOT be changed.
  679. */
  680. #define PNG_INFO_gAMA 0x0001
  681. #define PNG_INFO_sBIT 0x0002
  682. #define PNG_INFO_cHRM 0x0004
  683. #define PNG_INFO_PLTE 0x0008
  684. #define PNG_INFO_tRNS 0x0010
  685. #define PNG_INFO_bKGD 0x0020
  686. #define PNG_INFO_hIST 0x0040
  687. #define PNG_INFO_pHYs 0x0080
  688. #define PNG_INFO_oFFs 0x0100
  689. #define PNG_INFO_tIME 0x0200
  690. #define PNG_INFO_pCAL 0x0400
  691. #define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */
  692. #define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */
  693. #define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */
  694. #define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */
  695. #define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */
  696. /* This is used for the transformation routines, as some of them
  697. * change these values for the row. It also should enable using
  698. * the routines for other purposes.
  699. */
  700. typedef struct png_row_info_struct
  701. {
  702. png_uint_32 width; /* width of row */
  703. png_uint_32 rowbytes; /* number of bytes in row */
  704. png_byte color_type; /* color type of row */
  705. png_byte bit_depth; /* bit depth of row */
  706. png_byte channels; /* number of channels (1, 2, 3, or 4) */
  707. png_byte pixel_depth; /* bits per pixel (depth * channels) */
  708. } png_row_info;
  709. typedef png_row_info FAR * png_row_infop;
  710. typedef png_row_info FAR * FAR * png_row_infopp;
  711. /* These are the function types for the I/O functions and for the functions
  712. * that allow the user to override the default I/O functions with his or her
  713. * own. The png_error_ptr type should match that of user-supplied warning
  714. * and error functions, while the png_rw_ptr type should match that of the
  715. * user read/write data functions.
  716. */
  717. typedef struct png_struct_def png_struct;
  718. typedef png_struct FAR * png_structp;
  719. typedef void (*png_error_ptr) PNGARG((png_structp, png_const_charp));
  720. typedef void (*png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t));
  721. typedef void (*png_flush_ptr) PNGARG((png_structp));
  722. typedef void (*png_read_status_ptr) PNGARG((png_structp, png_uint_32, int));
  723. typedef void (*png_write_status_ptr) PNGARG((png_structp, png_uint_32, int));
  724. #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
  725. typedef void (*png_progressive_info_ptr) PNGARG((png_structp, png_infop));
  726. typedef void (*png_progressive_end_ptr) PNGARG((png_structp, png_infop));
  727. typedef void (*png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
  728. png_uint_32, int));
  729. #endif
  730. #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
  731. defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
  732. typedef void (*png_user_transform_ptr) PNGARG((png_structp,
  733. png_row_infop, png_bytep));
  734. #endif
  735. #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
  736. typedef int (*png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp));
  737. #endif
  738. #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
  739. typedef void (*png_unknown_chunk_ptr) PNGARG((png_structp));
  740. #endif
  741. /* Transform masks for the high-level interface */
  742. #define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */
  743. #define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */
  744. #define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */
  745. #define PNG_TRANSFORM_PACKING 0x0004 /* read and write */
  746. #define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */
  747. #define PNG_TRANSFORM_EXPAND 0x0010 /* read only */
  748. #define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */
  749. #define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */
  750. #define PNG_TRANSFORM_BGR 0x0080 /* read and write */
  751. #define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */
  752. #define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */
  753. #define PNG_TRANSFORM_INVERT_ALPHA 0x0200 /* read and write */
  754. #define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */
  755. typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t));
  756. typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp));
  757. /* The structure that holds the information to read and write PNG files.
  758. * The only people who need to care about what is inside of this are the
  759. * people who will be modifying the library for their own special needs.
  760. * It should NOT be accessed directly by an application, except to store
  761. * the jmp_buf.
  762. */
  763. struct png_struct_def
  764. {
  765. #ifdef PNG_SETJMP_SUPPORTED
  766. jmp_buf jmpbuf; /* used in png_error */
  767. #endif
  768. png_error_ptr error_fn; /* function for printing errors and aborting */
  769. png_error_ptr warning_fn; /* function for printing warnings */
  770. png_voidp error_ptr; /* user supplied struct for error functions */
  771. png_rw_ptr write_data_fn; /* function for writing output data */
  772. png_rw_ptr read_data_fn; /* function for reading input data */
  773. png_voidp io_ptr; /* ptr to application struct for I/O functions*/
  774. #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
  775. png_user_transform_ptr read_user_transform_fn; /* user read transform */
  776. #endif
  777. #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
  778. png_user_transform_ptr write_user_transform_fn; /* user write transform */
  779. #endif
  780. #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
  781. defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
  782. png_voidp user_transform_ptr; /* user supplied struct for user transform */
  783. png_byte user_transform_depth; /* bit depth of user transformed pixels */
  784. png_byte user_transform_channels; /* channels in user transformed pixels */
  785. #endif
  786. #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
  787. png_voidp user_chunk_ptr;
  788. png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
  789. #endif
  790. png_uint_32 mode; /* tells us where we are in the PNG file */
  791. png_uint_32 flags; /* flags indicating various things to libpng */
  792. png_uint_32 free_me; /* flags items libpng is responsible for freeing */
  793. png_uint_32 transformations; /* which transformations to perform */
  794. z_stream zstream; /* pointer to decompression structure (below) */
  795. png_bytep zbuf; /* buffer for zlib */
  796. png_size_t zbuf_size; /* size of zbuf */
  797. int zlib_level; /* holds zlib compression level */
  798. int zlib_method; /* holds zlib compression method */
  799. int zlib_window_bits; /* holds zlib compression window bits */
  800. int zlib_mem_level; /* holds zlib compression memory level */
  801. int zlib_strategy; /* holds zlib compression strategy */
  802. png_uint_32 width; /* width of image in pixels */
  803. png_uint_32 height; /* height of image in pixels */
  804. png_uint_32 num_rows; /* number of rows in current pass */
  805. png_uint_32 usr_width; /* width of row at start of write */
  806. png_uint_32 rowbytes; /* size of row in bytes */
  807. png_uint_32 irowbytes; /* size of current interlaced row in bytes */
  808. png_uint_32 iwidth; /* width of current interlaced row in pixels */
  809. png_uint_32 row_number; /* current row in interlace pass */
  810. png_bytep prev_row; /* buffer to save previous (unfiltered) row */
  811. png_bytep row_buf; /* buffer to save current (unfiltered) row */
  812. png_bytep sub_row; /* buffer to save "sub" row when filtering */
  813. png_bytep up_row; /* buffer to save "up" row when filtering */
  814. png_bytep avg_row; /* buffer to save "avg" row when filtering */
  815. png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
  816. png_row_info row_info; /* used for transformation routines */
  817. png_uint_32 idat_size; /* current IDAT size for read */
  818. png_uint_32 crc; /* current chunk CRC value */
  819. png_colorp palette; /* palette from the input file */
  820. png_uint_16 num_palette; /* number of color entries in palette */
  821. png_uint_16 num_trans; /* number of transparency values */
  822. png_byte chunk_name[5]; /* null-terminated name of current chunk */
  823. png_byte compression; /* file compression type (always 0) */
  824. png_byte filter; /* file filter type (always 0) */
  825. png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
  826. png_byte pass; /* current interlace pass (0 - 6) */
  827. png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */
  828. png_byte color_type; /* color type of file */
  829. png_byte bit_depth; /* bit depth of file */
  830. png_byte usr_bit_depth; /* bit depth of users row */
  831. png_byte pixel_depth; /* number of bits per pixel */
  832. png_byte channels; /* number of channels in file */
  833. png_byte usr_channels; /* channels at start of write */
  834. png_byte sig_bytes; /* magic bytes read/written from start of file */
  835. #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
  836. png_uint_16 filler; /* filler bytes for pixel expansion */
  837. #endif
  838. #if defined(PNG_READ_bKGD_SUPPORTED)
  839. png_byte background_gamma_type;
  840. #ifdef PNG_FLOATING_POINT_SUPPORTED
  841. float background_gamma;
  842. #endif
  843. png_color_16 background; /* background color in screen gamma space */
  844. # if defined(PNG_READ_GAMMA_SUPPORTED)
  845. png_color_16 background_1; /* background normalized to gamma 1.0 */
  846. # endif /* PNG_READ_GAMMA && PNG_READ_bKGD_SUPPORTED */
  847. #endif /* PNG_READ_bKGD_SUPPORTED */
  848. #if defined(PNG_WRITE_FLUSH_SUPPORTED)
  849. png_flush_ptr output_flush_fn;/* Function for flushing output */
  850. png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */
  851. png_uint_32 flush_rows; /* number of rows written since last flush */
  852. #endif
  853. #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
  854. int gamma_shift; /* number of "insignificant" bits 16-bit gamma */
  855. #ifdef PNG_FLOATING_POINT_SUPPORTED
  856. float gamma; /* file gamma value */
  857. float screen_gamma; /* screen gamma value (display_exponent) */
  858. #endif
  859. png_fixed_point int_gamma;
  860. #endif
  861. #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
  862. png_bytep gamma_table; /* gamma table for 8-bit depth files */
  863. png_bytep gamma_from_1; /* converts from 1.0 to screen */
  864. png_bytep gamma_to_1; /* converts from file to 1.0 */
  865. png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
  866. png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
  867. png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
  868. #endif
  869. #if defined(PNG_READ_GAMMA_SUPPORTED) || defined (PNG_READ_sBIT_SUPPORTED)
  870. png_color_8 sig_bit; /* significant bits in each available channel */
  871. #endif
  872. #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
  873. png_color_8 shift; /* shift for significant bit tranformation */
  874. #endif
  875. #if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
  876. || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
  877. png_bytep trans; /* transparency values for paletted files */
  878. png_color_16 trans_values; /* transparency values for non-paletted files */
  879. #endif
  880. png_read_status_ptr read_row_fn; /* called after each row is decoded */
  881. png_write_status_ptr write_row_fn; /* called after each row is encoded */
  882. #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
  883. png_progressive_info_ptr info_fn; /* called after header data fully read */
  884. png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */
  885. png_progressive_end_ptr end_fn; /* called after image is complete */
  886. png_bytep save_buffer_ptr; /* current location in save_buffer */
  887. png_bytep save_buffer; /* buffer for previously read data */
  888. png_bytep current_buffer_ptr; /* current location in current_buffer */
  889. png_bytep current_buffer; /* buffer for recently used data */
  890. png_uint_32 push_length; /* size of current input chunk */
  891. png_uint_32 skip_length; /* bytes to skip in input data */
  892. png_size_t save_buffer_size; /* amount of data now in save_buffer */
  893. png_size_t save_buffer_max; /* total size of save_buffer */
  894. png_size_t buffer_size; /* total amount of available input data */
  895. png_size_t current_buffer_size; /* amount of data now in current_buffer */
  896. int process_mode; /* what push library is currently doing */
  897. int cur_palette; /* current push library palette index */
  898. # if defined(PNG_READ_TEXT_SUPPORTED)
  899. png_size_t current_text_size; /* current size of text input data */
  900. png_size_t current_text_left; /* how much text left to read in input */
  901. png_charp current_text; /* current text chunk buffer */
  902. png_charp current_text_ptr; /* current location in current_text */
  903. # endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_READ_TEXT_SUPPORTED */
  904. #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
  905. #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
  906. /* for the Borland special 64K segment handler */
  907. png_bytepp offset_table_ptr;
  908. png_bytep offset_table;
  909. png_uint_16 offset_table_number;
  910. png_uint_16 offset_table_count;
  911. png_uint_16 offset_table_count_free;
  912. #endif
  913. #if defined(PNG_READ_DITHER_SUPPORTED)
  914. png_bytep palette_lookup; /* lookup table for dithering */
  915. png_bytep dither_index; /* index translation for palette files */
  916. #endif
  917. #if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_READ_hIST_SUPPORTED)
  918. png_uint_16p hist; /* histogram */
  919. #endif
  920. #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
  921. png_byte heuristic_method; /* heuristic for row filter selection */
  922. png_byte num_prev_filters; /* number of weights for previous rows */
  923. png_bytep prev_filters; /* filter type(s) of previous row(s) */
  924. png_uint_16p filter_weights; /* weight(s) for previous line(s) */
  925. png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */
  926. png_uint_16p filter_costs; /* relative filter calculation cost */
  927. png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
  928. #endif
  929. #if defined(PNG_TIME_RFC1123_SUPPORTED)
  930. png_charp time_buffer; /* String to hold RFC 1123 time text */
  931. #endif
  932. #ifdef PNG_USER_MEM_SUPPORTED
  933. png_voidp mem_ptr; /* user supplied struct for mem functions */
  934. png_malloc_ptr malloc_fn; /* function for allocating memory */
  935. png_free_ptr free_fn; /* function for freeing memory */
  936. #endif
  937. #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
  938. png_byte rgb_to_gray_status;
  939. png_uint_16 rgb_to_gray_red_coeff;
  940. png_uint_16 rgb_to_gray_green_coeff;
  941. png_uint_16 rgb_to_gray_blue_coeff;
  942. #endif
  943. #if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
  944. defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
  945. png_byte empty_plte_permitted;
  946. #endif
  947. #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
  948. int num_chunk_list;
  949. png_bytep chunk_list;
  950. #endif
  951. };
  952. /* This prevents a compiler error in png_get_copyright() in png.c if png.c
  953. and png.h are both at * version 1.0.6
  954. */
  955. typedef png_structp version_1_0_6;
  956. typedef png_struct FAR * FAR * png_structpp;
  957. /* Here are the function definitions most commonly used. This is not
  958. * the place to find out how to use libpng. See libpng.txt for the
  959. * full explanation, see example.c for the summary. This just provides
  960. * a simple one line description of the use of each function.
  961. */
  962. /* Tell lib we have already handled the first <num_bytes> magic bytes.
  963. * Handling more than 8 bytes from the beginning of the file is an error.
  964. */
  965. extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr,
  966. int num_bytes));
  967. /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a
  968. * PNG file. Returns zero if the supplied bytes match the 8-byte PNG
  969. * signature, and non-zero otherwise. Having num_to_check == 0 or
  970. * start > 7 will always fail (ie return non-zero).
  971. */
  972. extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start,
  973. png_size_t num_to_check));
  974. /* Simple signature checking function. This is the same as calling
  975. * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
  976. */
  977. extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num));
  978. /* Allocate and initialize png_ptr struct for reading, and any other memory. */
  979. extern PNG_EXPORT(png_structp,png_create_read_struct)
  980. PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
  981. png_error_ptr error_fn, png_error_ptr warn_fn));
  982. /* Allocate and initialize png_ptr struct for writing, and any other memory */
  983. extern PNG_EXPORT(png_structp,png_create_write_struct)
  984. PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
  985. png_error_ptr error_fn, png_error_ptr warn_fn));
  986. #ifdef PNG_USER_MEM_SUPPORTED
  987. extern PNG_EXPORT(png_structp,png_create_read_struct_2)
  988. PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
  989. png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
  990. png_malloc_ptr malloc_fn, png_free_ptr free_fn));
  991. extern PNG_EXPORT(png_structp,png_create_write_struct_2)
  992. PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
  993. png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
  994. png_malloc_ptr malloc_fn, png_free_ptr free_fn));
  995. #endif
  996. /* Write a PNG chunk - size, type, (optional) data, CRC. */
  997. extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr,
  998. png_bytep chunk_name, png_bytep data, png_size_t length));
  999. /* Write the start of a PNG chunk - length and chunk name. */
  1000. extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr,
  1001. png_bytep chunk_name, png_uint_32 length));
  1002. /* Write the data of a PNG chunk started with png_write_chunk_start(). */
  1003. extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr,
  1004. png_bytep data, png_size_t length));
  1005. /* Finish a chunk started with png_write_chunk_start() (includes CRC). */
  1006. extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr));
  1007. /* Allocate and initialize the info structure */
  1008. extern PNG_EXPORT(png_infop,png_create_info_struct)
  1009. PNGARG((png_structp png_ptr));
  1010. /* Initialize the info structure (old interface - NOT DLL EXPORTED) */
  1011. extern void png_info_init PNGARG((png_infop info_ptr));
  1012. /* Writes all the PNG information before the image. */
  1013. extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr,
  1014. png_info

Large files files are truncated, but you can click here to view the full file