PageRenderTime 53ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/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
  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_infop info_ptr));
  1015. extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr,
  1016. png_infop info_ptr));
  1017. /* read the information before the actual image data. */
  1018. extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr,
  1019. png_infop info_ptr));
  1020. #if defined(PNG_TIME_RFC1123_SUPPORTED)
  1021. extern PNG_EXPORT(png_charp,png_convert_to_rfc1123)
  1022. PNGARG((png_structp png_ptr, png_timep ptime));
  1023. #endif
  1024. #if defined(PNG_WRITE_tIME_SUPPORTED)
  1025. /* convert from a struct tm to png_time */
  1026. extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime,
  1027. struct tm FAR * ttime));
  1028. /* convert from time_t to png_time. Uses gmtime() */
  1029. extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime,
  1030. time_t ttime));
  1031. #endif /* PNG_WRITE_tIME_SUPPORTED */
  1032. #if defined(PNG_READ_EXPAND_SUPPORTED)
  1033. /* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
  1034. extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr));
  1035. extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr));
  1036. extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr));
  1037. extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr));
  1038. #endif
  1039. #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
  1040. /* Use blue, green, red order for pixels. */
  1041. extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr));
  1042. #endif
  1043. #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
  1044. /* Expand the grayscale to 24-bit RGB if necessary. */
  1045. extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr));
  1046. #endif
  1047. #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
  1048. /* Reduce RGB to grayscale. */
  1049. #ifdef PNG_FLOATING_POINT_SUPPORTED
  1050. extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr,
  1051. int error_action, double red, double green ));
  1052. #endif
  1053. extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr,
  1054. int error_action, png_fixed_point red, png_fixed_point green ));
  1055. extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp
  1056. png_ptr));
  1057. #endif
  1058. extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth,
  1059. png_colorp palette));
  1060. #if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
  1061. extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr));
  1062. #endif
  1063. #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
  1064. defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
  1065. extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr));
  1066. #endif
  1067. #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
  1068. defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
  1069. extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr));
  1070. #endif
  1071. #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
  1072. /* Add a filler byte to 24-bit RGB images. */
  1073. extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr,
  1074. png_uint_32 filler, int flags));
  1075. /* The values of the PNG_FILLER_ defines should NOT be changed */
  1076. #define PNG_FILLER_BEFORE 0
  1077. #define PNG_FILLER_AFTER 1
  1078. #endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */
  1079. #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
  1080. /* Swap bytes in 16-bit depth files. */
  1081. extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr));
  1082. #endif
  1083. #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
  1084. /* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */
  1085. extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr));
  1086. #endif
  1087. #if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
  1088. /* Swap packing order of pixels in bytes. */
  1089. extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr));
  1090. #endif
  1091. #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
  1092. /* Converts files to legal bit depths. */
  1093. extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr,
  1094. png_color_8p true_bits));
  1095. #endif
  1096. #if defined(PNG_READ_INTERLACING_SUPPORTED) || \
  1097. defined(PNG_WRITE_INTERLACING_SUPPORTED)
  1098. /* Have the code handle the interlacing. Returns the number of passes. */
  1099. extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr));
  1100. #endif
  1101. #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
  1102. /* Invert monocrome files */
  1103. extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr));
  1104. #endif
  1105. #if defined(PNG_READ_BACKGROUND_SUPPORTED)
  1106. /* Handle alpha and tRNS by replacing with a background color. */
  1107. #ifdef PNG_FLOATING_POINT_SUPPORTED
  1108. extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr,
  1109. png_color_16p background_color, int background_gamma_code,
  1110. int need_expand, double background_gamma));
  1111. #endif
  1112. #define PNG_BACKGROUND_GAMMA_UNKNOWN 0
  1113. #define PNG_BACKGROUND_GAMMA_SCREEN 1
  1114. #define PNG_BACKGROUND_GAMMA_FILE 2
  1115. #define PNG_BACKGROUND_GAMMA_UNIQUE 3
  1116. #endif
  1117. #if defined(PNG_READ_16_TO_8_SUPPORTED)
  1118. /* strip the second byte of information from a 16-bit depth file. */
  1119. extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr));
  1120. #endif
  1121. #if defined(PNG_READ_DITHER_SUPPORTED)
  1122. /* Turn on dithering, and reduce the palette to the number of colors available. */
  1123. extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr,
  1124. png_colorp palette, int num_palette, int maximum_colors,
  1125. png_uint_16p histogram, int full_dither));
  1126. #endif
  1127. #if defined(PNG_READ_GAMMA_SUPPORTED)
  1128. /* Handle gamma correction. Screen_gamma=(display_exponent) */
  1129. #ifdef PNG_FLOATING_POINT_SUPPORTED
  1130. extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr,
  1131. double screen_gamma, double default_file_gamma));
  1132. #endif
  1133. #endif
  1134. #if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
  1135. defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
  1136. /* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */
  1137. extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr,
  1138. int empty_plte_permitted));
  1139. #endif
  1140. #if defined(PNG_WRITE_FLUSH_SUPPORTED)
  1141. /* Set how many lines between output flushes - 0 for no flushing */
  1142. extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows));
  1143. /* Flush the current PNG output buffer */
  1144. extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr));
  1145. #endif
  1146. /* optional update palette with requested transformations */
  1147. extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr));
  1148. /* optional call to update the users info structure */
  1149. extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr,
  1150. png_infop info_ptr));
  1151. /* read a one or more rows of image data.*/
  1152. extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr,
  1153. png_bytepp row, png_bytepp display_row, png_uint_32 num_rows));
  1154. /* read a row of data.*/
  1155. extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr,
  1156. png_bytep row,
  1157. png_bytep display_row));
  1158. /* read the whole image into memory at once. */
  1159. extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr,
  1160. png_bytepp image));
  1161. /* write a row of image data */
  1162. extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr,
  1163. png_bytep row));
  1164. /* write a few rows of image data */
  1165. extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr,
  1166. png_bytepp row, png_uint_32 num_rows));
  1167. /* write the image data */
  1168. extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr,
  1169. png_bytepp image));
  1170. /* writes the end of the PNG file. */
  1171. extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr,
  1172. png_infop info_ptr));
  1173. /* read the end of the PNG file. */
  1174. extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr,
  1175. png_infop info_ptr));
  1176. /* free any memory associated with the png_info_struct */
  1177. extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr,
  1178. png_infopp info_ptr_ptr));
  1179. /* free any memory associated with the png_struct and the png_info_structs */
  1180. extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp
  1181. png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));
  1182. /* free all memory used by the read (old method - NOT DLL EXPORTED) */
  1183. extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
  1184. png_infop end_info_ptr));
  1185. /* free any memory associated with the png_struct and the png_info_structs */
  1186. extern PNG_EXPORT(void,png_destroy_write_struct)
  1187. PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr));
  1188. /* free any memory used in info_ptr struct (old method - NOT DLL EXPORTED) */
  1189. extern void png_write_destroy_info PNGARG((png_infop info_ptr));
  1190. /* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
  1191. extern void png_write_destroy PNGARG((png_structp png_ptr));
  1192. /* set the libpng method of handling chunk CRC errors */
  1193. extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr,
  1194. int crit_action, int ancil_action));
  1195. /* Values for png_set_crc_action() to say how to handle CRC errors in
  1196. * ancillary and critical chunks, and whether to use the data contained
  1197. * therein. Note that it is impossible to "discard" data in a critical
  1198. * chunk. For versions prior to 0.90, the action was always error/quit,
  1199. * whereas in version 0.90 and later, the action for CRC errors in ancillary
  1200. * chunks is warn/discard. These values should NOT be changed.
  1201. *
  1202. * value action:critical action:ancillary
  1203. */
  1204. #define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */
  1205. #define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */
  1206. #define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */
  1207. #define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */
  1208. #define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */
  1209. #define PNG_CRC_NO_CHANGE 5 /* use current value use current value */
  1210. /* These functions give the user control over the scan-line filtering in
  1211. * libpng and the compression methods used by zlib. These functions are
  1212. * mainly useful for testing, as the defaults should work with most users.
  1213. * Those users who are tight on memory or want faster performance at the
  1214. * expense of compression can modify them. See the compression library
  1215. * header file (zlib.h) for an explination of the compression functions.
  1216. */
  1217. /* set the filtering method(s) used by libpng. Currently, the only valid
  1218. * value for "method" is 0.
  1219. */
  1220. extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method,
  1221. int filters));
  1222. /* Flags for png_set_filter() to say which filters to use. The flags
  1223. * are chosen so that they don't conflict with real filter types
  1224. * below, in case they are supplied instead of the #defined constants.
  1225. * These values should NOT be changed.
  1226. */
  1227. #define PNG_NO_FILTERS 0x00
  1228. #define PNG_FILTER_NONE 0x08
  1229. #define PNG_FILTER_SUB 0x10
  1230. #define PNG_FILTER_UP 0x20
  1231. #define PNG_FILTER_AVG 0x40
  1232. #define PNG_FILTER_PAETH 0x80
  1233. #define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
  1234. PNG_FILTER_AVG | PNG_FILTER_PAETH)
  1235. /* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
  1236. * These defines should NOT be changed.
  1237. */
  1238. #define PNG_FILTER_VALUE_NONE 0
  1239. #define PNG_FILTER_VALUE_SUB 1
  1240. #define PNG_FILTER_VALUE_UP 2
  1241. #define PNG_FILTER_VALUE_AVG 3
  1242. #define PNG_FILTER_VALUE_PAETH 4
  1243. #define PNG_FILTER_VALUE_LAST 5
  1244. #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */
  1245. /* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_
  1246. * defines, either the default (minimum-sum-of-absolute-differences), or
  1247. * the experimental method (weighted-minimum-sum-of-absolute-differences).
  1248. *
  1249. * Weights are factors >= 1.0, indicating how important it is to keep the
  1250. * filter type consistent between rows. Larger numbers mean the current
  1251. * filter is that many times as likely to be the same as the "num_weights"
  1252. * previous filters. This is cumulative for each previous row with a weight.
  1253. * There needs to be "num_weights" values in "filter_weights", or it can be
  1254. * NULL if the weights aren't being specified. Weights have no influence on
  1255. * the selection of the first row filter. Well chosen weights can (in theory)
  1256. * improve the compression for a given image.
  1257. *
  1258. * Costs are factors >= 1.0 indicating the relative decoding costs of a
  1259. * filter type. Higher costs indicate more decoding expense, and are
  1260. * therefore less likely to be selected over a filter with lower computational
  1261. * costs. There needs to be a value in "filter_costs" for each valid filter
  1262. * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't
  1263. * setting the costs. Costs try to improve the speed of decompression without
  1264. * unduly increasing the compressed image size.
  1265. *
  1266. * A negative weight or cost indicates the default value is to be used, and
  1267. * values in the range [0.0, 1.0) indicate the value is to remain unchanged.
  1268. * The default values for both weights and costs are currently 1.0, but may
  1269. * change if good general weighting/cost heuristics can be found. If both
  1270. * the weights and costs are set to 1.0, this degenerates the WEIGHTED method
  1271. * to the UNWEIGHTED method, but with added encoding time/computation.
  1272. */
  1273. #ifdef PNG_FLOATING_POINT_SUPPORTED
  1274. extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr,
  1275. int heuristic_method, int num_weights, png_doublep filter_weights,
  1276. png_doublep filter_costs));
  1277. #endif
  1278. #endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
  1279. /* Heuristic used for row filter selection. These defines should NOT be
  1280. * changed.
  1281. */
  1282. #define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */
  1283. #define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */
  1284. #define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */
  1285. #define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */
  1286. /* Set the library compression level. Currently, valid values range from
  1287. * 0 - 9, corresponding directly to the zlib compression levels 0 - 9
  1288. * (0 - no compression, 9 - "maximal" compression). Note that tests have
  1289. * shown that zlib compression levels 3-6 usually perform as well as level 9
  1290. * for PNG images, and do considerably fewer caclulations. In the future,
  1291. * these values may not correspond directly to the zlib compression levels.
  1292. */
  1293. extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr,
  1294. int level));
  1295. extern PNG_EXPORT(void,png_set_compression_mem_level)
  1296. PNGARG((png_structp png_ptr, int mem_level));
  1297. extern PNG_EXPORT(void,png_set_compression_strategy)
  1298. PNGARG((png_structp png_ptr, int strategy));
  1299. extern PNG_EXPORT(void,png_set_compression_window_bits)
  1300. PNGARG((png_structp png_ptr, int window_bits));
  1301. extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr,
  1302. int method));
  1303. /* These next functions are called for input/output, memory, and error
  1304. * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c,
  1305. * and call standard C I/O routines such as fread(), fwrite(), and
  1306. * fprintf(). These functions can be made to use other I/O routines
  1307. * at run time for those applications that need to handle I/O in a
  1308. * different manner by calling png_set_???_fn(). See libpng.txt for
  1309. * more information.
  1310. */
  1311. #if !defined(PNG_NO_STDIO)
  1312. /* Initialize the input/output for the PNG file to the default functions. */
  1313. extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, FILE *fp));
  1314. #endif
  1315. /* Replace the (error and abort), and warning functions with user
  1316. * supplied functions. If no messages are to be printed you must still
  1317. * write and use replacement functions. The replacement error_fn should
  1318. * still do a longjmp to the last setjmp location if you are using this
  1319. * method of error handling. If error_fn or warning_fn is NULL, the
  1320. * default function will be used.
  1321. */
  1322. extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr,
  1323. png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));
  1324. /* Return the user pointer associated with the error functions */
  1325. extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr));
  1326. /* Replace the default data output functions with a user supplied one(s).
  1327. * If buffered output is not used, then output_flush_fn can be set to NULL.
  1328. * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time
  1329. * output_flush_fn will be ignored (and thus can be NULL).
  1330. */
  1331. extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr,
  1332. png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));
  1333. /* Replace the default data input function with a user supplied one. */
  1334. extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr,
  1335. png_voidp io_ptr, png_rw_ptr read_data_fn));
  1336. /* Return the user pointer associated with the I/O functions */
  1337. extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr));
  1338. extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr,
  1339. png_read_status_ptr read_row_fn));
  1340. extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr,
  1341. png_write_status_ptr write_row_fn));
  1342. #ifdef PNG_USER_MEM_SUPPORTED
  1343. /* Replace the default memory allocation functions with user supplied one(s). */
  1344. extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr,
  1345. png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn));
  1346. /* Return the user pointer associated with the memory functions */
  1347. extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr));
  1348. #endif
  1349. #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
  1350. extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp
  1351. png_ptr, png_user_transform_ptr read_user_transform_fn));
  1352. #endif
  1353. #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
  1354. extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp
  1355. png_ptr, png_user_transform_ptr write_user_transform_fn));
  1356. #endif
  1357. #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
  1358. defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
  1359. extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp
  1360. png_ptr, png_voidp user_transform_ptr, int user_transform_depth,
  1361. int user_transform_channels));
  1362. /* Return the user pointer associated with the user transform functions */
  1363. extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr)
  1364. PNGARG((png_structp png_ptr));
  1365. #endif
  1366. #ifdef PNG_READ_USER_CHUNKS_SUPPORTED
  1367. extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr,
  1368. png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));
  1369. extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp
  1370. png_ptr));
  1371. #endif
  1372. #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
  1373. /* Sets the function callbacks for the push reader, and a pointer to a
  1374. * user-defined structure available to the callback functions.
  1375. */
  1376. extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr,
  1377. png_voidp progressive_ptr,
  1378. png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
  1379. png_progressive_end_ptr end_fn));
  1380. /* returns the user pointer associated with the push read functions */
  1381. extern PNG_EXPORT(png_voidp,png_get_progressive_ptr)
  1382. PNGARG((png_structp png_ptr));
  1383. /* function to be called when data becomes available */
  1384. extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr,
  1385. png_infop info_ptr, png_bytep buffer, png_size_t buffer_size));
  1386. /* function that combines rows. Not very much different than the
  1387. * png_combine_row() call. Is this even used?????
  1388. */
  1389. extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr,
  1390. png_bytep old_row, png_bytep new_row));
  1391. #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
  1392. extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr,
  1393. png_uint_32 size));
  1394. /* frees a pointer allocated by png_malloc() */
  1395. extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
  1396. /* free data that was allocated internally */
  1397. extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr,
  1398. png_infop info_ptr, png_uint_32 free_me, int num));
  1399. /* flags for png_ptr->free_me and info_ptr->free_me */
  1400. #define PNG_FREE_PLTE 0x0001
  1401. #define PNG_FREE_TRNS 0x0002
  1402. #define PNG_FREE_TEXT 0x0004
  1403. #define PNG_FREE_HIST 0x0008
  1404. #define PNG_FREE_ICCP 0x0010
  1405. #define PNG_FREE_SPLT 0x0020
  1406. #define PNG_FREE_ROWS 0x0040
  1407. #define PNG_FREE_PCAL 0x0080
  1408. #define PNG_FREE_SCAL 0x0100
  1409. #define PNG_FREE_UNKN 0x0200
  1410. #define PNG_FREE_LIST 0x0400
  1411. #define PNG_FREE_ALL 0x07ff
  1412. #ifdef PNG_USER_MEM_SUPPORTED
  1413. extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr,
  1414. png_uint_32 size));
  1415. extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr,
  1416. png_voidp ptr));
  1417. #endif
  1418. extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr,
  1419. png_voidp s1, png_voidp s2, png_uint_32 size));
  1420. extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr,
  1421. png_voidp s1, int value, png_uint_32 size));
  1422. #if defined(USE_FAR_KEYWORD) /* memory model conversion function */
  1423. extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
  1424. int check));
  1425. #endif /* USE_FAR_KEYWORD */
  1426. /* Fatal error in PNG image of libpng - can't continue */
  1427. extern PNG_EXPORT(void,png_org_error) PNGARG((png_structp png_ptr,
  1428. png_const_charp error));
  1429. #define png_error(s,e) png_org_error(s,"")
  1430. /* The same, but the chunk name is prepended to the error string. */
  1431. extern PNG_EXPORT(void,png_org_chunk_error) PNGARG((png_structp png_ptr,
  1432. png_const_charp error));
  1433. #define png_chunk_error(s,e) png_org_chunk_error(s,"")
  1434. /* Non-fatal error in libpng. Can continue, but may have a problem. */
  1435. extern PNG_EXPORT(void,png_org_warning) PNGARG((png_structp png_ptr,
  1436. png_const_charp message));
  1437. #define png_warning(s,e) png_org_warning(s,"")
  1438. /* Non-fatal error in libpng, chunk name is prepended to message. */
  1439. extern PNG_EXPORT(void,png_org_chunk_warning) PNGARG((png_structp png_ptr,
  1440. png_const_charp message));
  1441. #define png_chunk_warning(s,e) png_org_chunk_warning(s,"")
  1442. /* The png_set_<chunk> functions are for storing values in the png_info_struct.
  1443. * Similarly, the png_get_<chunk> calls are used to read values from the
  1444. * png_info_struct, either storing the parameters in the passed variables, or
  1445. * setting pointers into the png_info_struct where the data is stored. The
  1446. * png_get_<chunk> functions return a non-zero value if the data was available
  1447. * in info_ptr, or return zero and do not change any of the parameters if the
  1448. * data was not available.
  1449. *
  1450. * These functions should be used instead of directly accessing png_info
  1451. * to avoid problems with future changes in the size and internal layout of
  1452. * png_info_struct.
  1453. */
  1454. /* Returns "flag" if chunk data is valid in info_ptr. */
  1455. extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr,
  1456. png_infop info_ptr, png_uint_32 flag));
  1457. /* Returns number of bytes needed to hold a transformed row. */
  1458. extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr,
  1459. png_infop info_ptr));
  1460. #if defined(PNG_INFO_IMAGE_SUPPORTED)
  1461. /* Returns row_pointers, which is an array of pointers to scanlines that was
  1462. returned from png_read_png(). */
  1463. extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr,
  1464. png_infop info_ptr));
  1465. /* Set row_pointers, which is an array of pointers to scanlines for use
  1466. by png_write_png(). */
  1467. extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr,
  1468. png_infop info_ptr, png_bytepp row_pointers));
  1469. #endif
  1470. /* Returns number of color channels in image. */
  1471. extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr,
  1472. png_infop info_ptr));
  1473. #ifdef PNG_EASY_ACCESS_SUPPORTED
  1474. /* Returns image width in pixels. */
  1475. extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp
  1476. png_ptr, png_infop info_ptr));
  1477. /* Returns image height in pixels. */
  1478. extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp
  1479. png_ptr, png_infop info_ptr));
  1480. /* Returns image bit_depth. */
  1481. extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp
  1482. png_ptr, png_infop info_ptr));
  1483. /* Returns image color_type. */
  1484. extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp
  1485. png_ptr, png_infop info_ptr));
  1486. /* Returns image filter_type. */
  1487. extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp
  1488. png_ptr, png_infop info_ptr));
  1489. /* Returns image interlace_type. */
  1490. extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp
  1491. png_ptr, png_infop info_ptr));
  1492. /* Returns image compression_type. */
  1493. extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp
  1494. png_ptr, png_infop info_ptr));
  1495. /* Returns image resolution in pixels per meter, from pHYs chunk data. */
  1496. extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp
  1497. png_ptr, png_infop info_ptr));
  1498. extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp
  1499. png_ptr, png_infop info_ptr));
  1500. extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp
  1501. png_ptr, png_infop info_ptr));
  1502. /* Returns pixel aspect ratio, computed from pHYs chunk data. */
  1503. #ifdef PNG_FLOATING_POINT_SUPPORTED
  1504. extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp
  1505. png_ptr, png_infop info_ptr));
  1506. #endif
  1507. /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
  1508. extern PNG_EXPORT(png_uint_32, png_get_x_offset_pixels) PNGARG((png_structp
  1509. png_ptr, png_infop info_ptr));
  1510. extern PNG_EXPORT(png_uint_32, png_get_y_offset_pixels) PNGARG((png_structp
  1511. png_ptr, png_infop info_ptr));
  1512. extern PNG_EXPORT(png_uint_32, png_get_x_offset_microns) PNGARG((png_structp
  1513. png_ptr, png_infop info_ptr));
  1514. extern PNG_EXPORT(png_uint_32, png_get_y_offset_microns) PNGARG((png_structp
  1515. png_ptr, png_infop info_ptr));
  1516. #endif /* PNG_EASY_ACCESS_SUPPORTED */
  1517. /* Returns pointer to signature string read from PNG header */
  1518. extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr,
  1519. png_infop info_ptr));
  1520. #if defined(PNG_READ_bKGD_SUPPORTED)
  1521. extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr,
  1522. png_infop info_ptr, png_color_16p *background));
  1523. #endif
  1524. #if defined(PNG_bKGD_SUPPORTED)
  1525. extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr,
  1526. png_infop info_ptr, png_color_16p background));
  1527. #endif
  1528. #if defined(PNG_READ_cHRM_SUPPORTED)
  1529. #ifdef PNG_FLOATING_POINT_SUPPORTED
  1530. extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr,
  1531. png_infop info_ptr, double *white_x, double *white_y, double *red_x,
  1532. double *red_y, double *green_x, double *green_y, double *blue_x,
  1533. double *blue_y));
  1534. #endif
  1535. #ifdef PNG_FIXED_POINT_SUPPORTED
  1536. extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr,
  1537. png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point
  1538. *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y,
  1539. png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point
  1540. *int_blue_x, png_fixed_point *int_blue_y));
  1541. #endif
  1542. #endif
  1543. #if defined(PNG_cHRM_SUPPORTED)
  1544. #ifdef PNG_FLOATING_POINT_SUPPORTED
  1545. extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr,
  1546. png_infop info_ptr, double white_x, double white_y, double red_x,
  1547. double red_y, double green_x, double green_y, double blue_x, double blue_y));
  1548. #endif
  1549. #ifdef PNG_FIXED_POINT_SUPPORTED
  1550. extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr,
  1551. png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y,
  1552. png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
  1553. int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
  1554. png_fixed_point int_blue_y));
  1555. #endif
  1556. #endif
  1557. #if defined(PNG_READ_gAMA_SUPPORTED)
  1558. #ifdef PNG_FLOATING_POINT_SUPPORTED
  1559. extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr,
  1560. png_infop info_ptr, double *file_gamma));
  1561. #endif
  1562. extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr,
  1563. png_infop info_ptr, png_fixed_point *int_file_gamma));
  1564. #endif
  1565. #if defined(PNG_gAMA_SUPPORTED)
  1566. #ifdef PNG_FLOATING_POINT_SUPPORTED
  1567. extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr,
  1568. png_infop info_ptr, double file_gamma));
  1569. #endif
  1570. extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr,
  1571. png_infop info_ptr, png_fixed_point int_file_gamma));
  1572. #endif
  1573. #if defined(PNG_READ_hIST_SUPPORTED)
  1574. extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr,
  1575. png_infop info_ptr, png_uint_16p *hist));
  1576. #endif
  1577. #if defined(PNG_hIST_SUPPORTED)
  1578. extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr,
  1579. png_infop info_ptr, png_uint_16p hist));
  1580. #endif
  1581. extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr,
  1582. png_infop info_ptr, png_uint_32 *width, png_uint_32 *height,
  1583. int *bit_depth, int *color_type, int *interlace_type,
  1584. int *compression_type, int *filter_type));
  1585. extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr,
  1586. png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,
  1587. int color_type, int interlace_type, int compression_type, int filter_type));
  1588. #if defined(PNG_READ_oFFs_SUPPORTED)
  1589. extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr,
  1590. png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y,
  1591. int *unit_type));
  1592. #endif
  1593. #if defined(PNG_oFFs_SUPPORTED)
  1594. extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr,
  1595. png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y,
  1596. int unit_type));
  1597. #endif
  1598. #if defined(PNG_READ_pCAL_SUPPORTED)
  1599. extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr,
  1600. png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1,
  1601. int *type, int *nparams, png_charp *units, png_charpp *params));
  1602. #endif
  1603. #if defined(PNG_pCAL_SUPPORTED)
  1604. extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr,
  1605. png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1,
  1606. int type, int nparams, png_charp units, png_charpp params));
  1607. #endif
  1608. #if defined(PNG_READ_pHYs_SUPPORTED)
  1609. extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr,
  1610. png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
  1611. #endif
  1612. #if defined(PNG_pHYs_SUPPORTED)
  1613. extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr,
  1614. png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));
  1615. #endif
  1616. extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr,
  1617. png_infop info_ptr, png_colorp *palette, int *num_palette));
  1618. extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr,
  1619. png_infop info_ptr, png_colorp palette, int num_palette));
  1620. #if defined(PNG_READ_sBIT_SUPPORTED)
  1621. extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr,
  1622. png_infop info_ptr, png_color_8p *sig_bit));
  1623. #endif
  1624. #if defined(PNG_sBIT_SUPPORTED)
  1625. extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr,
  1626. png_infop info_ptr, png_color_8p sig_bit));
  1627. #endif
  1628. #if defined(PNG_READ_sRGB_SUPPORTED)
  1629. extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr,
  1630. png_infop info_ptr, int *intent));
  1631. #endif
  1632. #if defined(PNG_sRGB_SUPPORTED)
  1633. extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr,
  1634. png_infop info_ptr, int intent));
  1635. extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr,
  1636. png_infop info_ptr, int intent));
  1637. #endif
  1638. #if defined(PNG_READ_iCCP_SUPPORTED)
  1639. extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr,
  1640. png_infop info_ptr, png_charpp name, int *compression_type,
  1641. png_charpp profile, png_uint_32 *proflen));
  1642. #endif
  1643. #if defined(PNG_iCCP_SUPPORTED)
  1644. extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr,
  1645. png_infop info_ptr, png_charp name, int compression_type,
  1646. png_charp profile, png_uint_32 proflen));
  1647. #endif
  1648. #if defined(PNG_READ_sPLT_SUPPORTED)
  1649. extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr,
  1650. png_infop info_ptr, png_sPLT_tpp entries));
  1651. #endif
  1652. #if defined(PNG_sPLT_SUPPORTED)
  1653. extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr,
  1654. png_infop info_ptr, png_sPLT_tp entries, int nentries));
  1655. #endif
  1656. #if defined(PNG_TEXT_SUPPORTED)
  1657. extern PNG_EXPORT(void,png_set_itxt) PNGARG((png_structp png_ptr,
  1658. png_infop info_ptr, png_textp text_ptr, int num_text));
  1659. #endif
  1660. #if defined(PNG_READ_TEXT_SUPPORTED)
  1661. /* Old interface; apps should use png_get_itxt instead */
  1662. /* png_get_text also returns the number of text chunks in *num_text */
  1663. extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr,
  1664. png_infop info_ptr, png_textp *text_ptr, int *num_text));
  1665. #endif
  1666. #if defined(PNG_TEXT_SUPPORTED)
  1667. extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr,
  1668. png_infop info_ptr, png_textp text_ptr, int num_text));
  1669. #endif
  1670. #if defined(PNG_READ_tIME_SUPPORTED)
  1671. extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr,
  1672. png_infop info_ptr, png_timep *mod_time));
  1673. #endif
  1674. #if defined(PNG_tIME_SUPPORTED)
  1675. extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr,
  1676. png_infop info_ptr, png_timep mod_time));
  1677. #endif
  1678. #if defined(PNG_READ_tRNS_SUPPORTED)
  1679. extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr,
  1680. png_infop info_ptr, png_bytep *trans, int *num_trans,
  1681. png_color_16p *trans_values));
  1682. #endif
  1683. #if defined(PNG_tRNS_SUPPORTED)
  1684. extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
  1685. png_infop info_ptr, png_bytep trans, int num_trans,
  1686. png_color_16p trans_values));
  1687. #endif
  1688. #if defined(PNG_tRNS_SUPPORTED)
  1689. #endif
  1690. #if defined(PNG_READ_sCAL_SUPPORTED)
  1691. #ifdef PNG_FLOATING_POINT_SUPPORTED
  1692. extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr,
  1693. png_infop info_ptr, int *unit, double *width, double *height));
  1694. #else
  1695. #ifdef PNG_FIXED_POINT_SUPPORTED
  1696. extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr,
  1697. png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight));
  1698. #endif
  1699. #endif
  1700. #endif /* PNG_READ_sCAL_SUPPORTED */
  1701. #if defined(PNG_sCAL_SUPPORTED)
  1702. #ifdef PNG_FLOATING_POINT_SUPPORTED
  1703. extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr,
  1704. png_infop info_ptr, int unit, double width, double height));
  1705. #endif
  1706. #ifdef PNG_FIXED_POINT_SUPPORTED
  1707. extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr,
  1708. png_infop info_ptr, int unit, png_charp swidth, png_charp sheight));
  1709. #endif
  1710. #endif /* PNG_READ_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */
  1711. #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
  1712. /* provide a list of chunks and how they are to be handled, if the built-in
  1713. handling or default unknown chunk handling is not desired. Any chunks not
  1714. listed will be handled in the default manner. The IHDR and IEND chunks
  1715. must not be listed.
  1716. keep = 0: follow default behavour
  1717. = 1: do not keep
  1718. = 2: keep only if safe-to-copy
  1719. = 3: keep even if unsafe-to-copy
  1720. */
  1721. extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp
  1722. png_ptr, int keep, png_bytep chunk_list, int num_chunks));
  1723. extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr,
  1724. png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns));
  1725. extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp
  1726. png_ptr, png_infop info_ptr, png_unknown_chunkpp entries));
  1727. #endif
  1728. #if defined(PNG_INFO_IMAGE_SUPPORTED)
  1729. extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr,
  1730. png_infop info_ptr,
  1731. int transforms,
  1732. voidp params));
  1733. extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr,
  1734. png_infop info_ptr,
  1735. int transforms,
  1736. voidp params));
  1737. #endif
  1738. /* Define PNG_DEBUG at compile time for debugging information. Higher
  1739. * numbers for PNG_DEBUG mean more debugging information. This has
  1740. * only been added since version 0.95 so it is not implemented throughout
  1741. * libpng yet, but more support will be added as needed.
  1742. */
  1743. #ifdef PNG_DEBUG
  1744. #if (PNG_DEBUG > 0)
  1745. #ifndef PNG_DEBUG_FILE
  1746. #define PNG_DEBUG_FILE stderr
  1747. #endif /* PNG_DEBUG_FILE */
  1748. #define png_debug(l,m) if (PNG_DEBUG > l) \
  1749. fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \
  1750. (l==2 ? "\t\t":(l>2 ? "\t\t\t":""))))
  1751. #define png_debug1(l,m,p1) if (PNG_DEBUG > l) \
  1752. fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \
  1753. (l==2 ? "\t\t":(l>2 ? "\t\t\t":""))),p1)
  1754. #define png_debug2(l,m,p1,p2) if (PNG_DEBUG > l) \
  1755. fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \
  1756. (l==2 ? "\t\t":(l>2 ? "\t\t\t":""))),p1,p2)
  1757. #endif /* (PNG_DEBUG > 0) */
  1758. #endif /* PNG_DEBUG */
  1759. #ifndef png_debug
  1760. #define png_debug(l, m)
  1761. #endif
  1762. #ifndef png_debug1
  1763. #define png_debug1(l, m, p1)
  1764. #endif
  1765. #ifndef png_debug2
  1766. #define png_debug2(l, m, p1, p2)
  1767. #endif
  1768. extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void));
  1769. extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr));
  1770. extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr));
  1771. extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr));
  1772. extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
  1773. #define PNG_HEADER_VERSION_STRING \
  1774. " libpng version 1.0.6 - March 21, 2000 (header)\n"
  1775. #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
  1776. /* With these routines we avoid an integer divide, which will be slower on
  1777. * most machines. However, it does take more operations than the corresponding
  1778. * divide method, so it may be slower on a few RISC systems. There are two
  1779. * shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
  1780. *
  1781. * Note that the rounding factors are NOT supposed to be the same! 128 and
  1782. * 32768 are correct for the NODIV code; 127 and 32767 are correct for the
  1783. * standard method.
  1784. *
  1785. * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
  1786. */
  1787. /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
  1788. # define png_composite(composite, fg, alpha, bg) \
  1789. { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \
  1790. + (png_uint_16)(bg)*(png_uint_16)(255 - \
  1791. (png_uint_16)(alpha)) + (png_uint_16)128); \
  1792. (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
  1793. # define png_composite_16(composite, fg, alpha, bg) \
  1794. { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \
  1795. + (png_uint_32)(bg)*(png_uint_32)(65535L - \
  1796. (png_uint_32)(alpha)) + (png_uint_32)32768L); \
  1797. (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
  1798. #else /* standard method using integer division */
  1799. # define png_composite(composite, fg, alpha, bg) \
  1800. (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \
  1801. (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
  1802. (png_uint_16)127) / 255)
  1803. # define png_composite_16(composite, fg, alpha, bg) \
  1804. (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
  1805. (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \
  1806. (png_uint_32)32767) / (png_uint_32)65535L)
  1807. #endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
  1808. /* These next functions are used internally in the code. They generally
  1809. * shouldn't be used unless you are writing code to add or replace some
  1810. * functionality in libpng. More information about most functions can
  1811. * be found in the files where the functions are located.
  1812. */
  1813. #if defined(PNG_INTERNAL)
  1814. /* Various modes of operation. Note that after an init, mode is set to
  1815. * zero automatically when the structure is created.
  1816. */
  1817. #define PNG_HAVE_IHDR 0x01
  1818. #define PNG_HAVE_PLTE 0x02
  1819. #define PNG_HAVE_IDAT 0x04
  1820. #define PNG_AFTER_IDAT 0x08
  1821. #define PNG_HAVE_IEND 0x10
  1822. #define PNG_HAVE_gAMA 0x20
  1823. #define PNG_HAVE_cHRM 0x40
  1824. #define PNG_HAVE_sRGB 0x80
  1825. #define PNG_HAVE_CHUNK_HEADER 0x100
  1826. #define PNG_WROTE_tIME 0x200
  1827. #define PNG_WROTE_INFO_BEFORE_PLTE 0x400
  1828. #define PNG_BACKGROUND_IS_GRAY 0x800
  1829. /* flags for the transformations the PNG library does on the image data */
  1830. #define PNG_BGR 0x0001
  1831. #define PNG_INTERLACE 0x0002
  1832. #define PNG_PACK 0x0004
  1833. #define PNG_SHIFT 0x0008
  1834. #define PNG_SWAP_BYTES 0x0010
  1835. #define PNG_INVERT_MONO 0x0020
  1836. #define PNG_DITHER 0x0040
  1837. #define PNG_BACKGROUND 0x0080
  1838. #define PNG_BACKGROUND_EXPAND 0x0100
  1839. /* 0x0200 unused */
  1840. #define PNG_16_TO_8 0x0400
  1841. #define PNG_RGBA 0x0800
  1842. #define PNG_EXPAND 0x1000
  1843. #define PNG_GAMMA 0x2000
  1844. #define PNG_GRAY_TO_RGB 0x4000
  1845. #define PNG_FILLER 0x8000L
  1846. #define PNG_PACKSWAP 0x10000L
  1847. #define PNG_SWAP_ALPHA 0x20000L
  1848. #define PNG_STRIP_ALPHA 0x40000L
  1849. #define PNG_INVERT_ALPHA 0x80000L
  1850. #define PNG_USER_TRANSFORM 0x100000L
  1851. #define PNG_RGB_TO_GRAY_ERR 0x200000L
  1852. #define PNG_RGB_TO_GRAY_WARN 0x400000L
  1853. #define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */
  1854. /* flags for png_create_struct */
  1855. #define PNG_STRUCT_PNG 0x0001
  1856. #define PNG_STRUCT_INFO 0x0002
  1857. /* Scaling factor for filter heuristic weighting calculations */
  1858. #define PNG_WEIGHT_SHIFT 8
  1859. #define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))
  1860. #define PNG_COST_SHIFT 3
  1861. #define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))
  1862. /* flags for the png_ptr->flags rather than declaring a byte for each one */
  1863. #define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001
  1864. #define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002
  1865. #define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004
  1866. #define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008
  1867. #define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010
  1868. #define PNG_FLAG_ZLIB_FINISHED 0x0020
  1869. #define PNG_FLAG_ROW_INIT 0x0040
  1870. #define PNG_FLAG_FILLER_AFTER 0x0080
  1871. #define PNG_FLAG_CRC_ANCILLARY_USE 0x0100
  1872. #define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200
  1873. #define PNG_FLAG_CRC_CRITICAL_USE 0x0400
  1874. #define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800
  1875. #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x1000
  1876. #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x2000
  1877. /* For use in png_set_keep_unknown, png_handle_as_unknown */
  1878. #define HANDLE_CHUNK_AS_DEFAULT 0
  1879. #define HANDLE_CHUNK_NEVER 1
  1880. #define HANDLE_CHUNK_IF_SAFE 2
  1881. #define HANDLE_CHUNK_ALWAYS 3
  1882. #define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
  1883. PNG_FLAG_CRC_ANCILLARY_NOWARN)
  1884. #define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \
  1885. PNG_FLAG_CRC_CRITICAL_IGNORE)
  1886. #define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \
  1887. PNG_FLAG_CRC_CRITICAL_MASK)
  1888. /* save typing and make code easier to understand */
  1889. #define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \
  1890. abs((int)((c1).green) - (int)((c2).green)) + \
  1891. abs((int)((c1).blue) - (int)((c2).blue)))
  1892. /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
  1893. #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
  1894. /* place to hold the signature string for a PNG file. */
  1895. #ifdef PNG_USE_GLOBAL_ARRAYS
  1896. PNG_EXPORT_VAR (png_byte FARDATA) png_sig[8];
  1897. #else
  1898. #define png_sig png_sig_bytes(NULL)
  1899. #endif
  1900. #endif /* PNG_NO_EXTERN */
  1901. /* Constant strings for known chunk types. If you need to add a chunk,
  1902. * define the name here, and add an invocation of the macro in png.c and
  1903. * wherever it's needed.
  1904. */
  1905. #define PNG_IHDR const png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'}
  1906. #define PNG_IDAT const png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'}
  1907. #define PNG_IEND const png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'}
  1908. #define PNG_PLTE const png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'}
  1909. #define PNG_bKGD const png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'}
  1910. #define PNG_cHRM const png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'}
  1911. #define PNG_gAMA const png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'}
  1912. #define PNG_hIST const png_byte png_hIST[5] = {104, 73, 83, 84, '\0'}
  1913. #define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'}
  1914. #define PNG_iTXt const png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'}
  1915. #define PNG_oFFs const png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'}
  1916. #define PNG_pCAL const png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'}
  1917. #define PNG_sCAL const png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'}
  1918. #define PNG_pHYs const png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'}
  1919. #define PNG_sBIT const png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'}
  1920. #define PNG_sPLT const png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'}
  1921. #define PNG_sRGB const png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'}
  1922. #define PNG_tEXt const png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'}
  1923. #define PNG_tIME const png_byte png_tIME[5] = {116, 73, 77, 69, '\0'}
  1924. #define PNG_tRNS const png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'}
  1925. #define PNG_zTXt const png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'}
  1926. #ifdef PNG_USE_GLOBAL_ARRAYS
  1927. PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5];
  1928. PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5];
  1929. PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5];
  1930. PNG_EXPORT_VAR (const png_byte FARDATA) png_PLTE[5];
  1931. PNG_EXPORT_VAR (const png_byte FARDATA) png_bKGD[5];
  1932. PNG_EXPORT_VAR (const png_byte FARDATA) png_cHRM[5];
  1933. PNG_EXPORT_VAR (const png_byte FARDATA) png_gAMA[5];
  1934. PNG_EXPORT_VAR (const png_byte FARDATA) png_hIST[5];
  1935. PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5];
  1936. PNG_EXPORT_VAR (const png_byte FARDATA) png_iTXt[5];
  1937. PNG_EXPORT_VAR (const png_byte FARDATA) png_oFFs[5];
  1938. PNG_EXPORT_VAR (const png_byte FARDATA) png_pCAL[5];
  1939. PNG_EXPORT_VAR (const png_byte FARDATA) png_sCAL[5];
  1940. PNG_EXPORT_VAR (const png_byte FARDATA) png_pHYs[5];
  1941. PNG_EXPORT_VAR (const png_byte FARDATA) png_sBIT[5];
  1942. PNG_EXPORT_VAR (const png_byte FARDATA) png_sPLT[5];
  1943. PNG_EXPORT_VAR (const png_byte FARDATA) png_sRGB[5];
  1944. PNG_EXPORT_VAR (const png_byte FARDATA) png_tEXt[5];
  1945. PNG_EXPORT_VAR (const png_byte FARDATA) png_tIME[5];
  1946. PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5];
  1947. PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5];
  1948. #endif /* PNG_USE_GLOBAL_ARRAYS */
  1949. /* Inline macros to do direct reads of bytes from the input buffer. These
  1950. * require that you are using an architecture that uses PNG byte ordering
  1951. * (MSB first) and supports unaligned data storage. I think that PowerPC
  1952. * in big-endian mode and 680x0 are the only ones that will support this.
  1953. * The x86 line of processors definitely do not. The png_get_int_32()
  1954. * routine also assumes we are using two's complement format for negative
  1955. * values, which is almost certainly true.
  1956. */
  1957. #if defined(PNG_READ_BIG_ENDIAN_SUPPORTED)
  1958. # if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_READ_oFFs_SUPPORTED)
  1959. # define png_get_int_32(buf) ( *((png_int_32p) (buf)))
  1960. # endif
  1961. # define png_get_uint_32(buf) ( *((png_uint_32p) (buf)))
  1962. # define png_get_uint_16(buf) ( *((png_uint_16p) (buf)))
  1963. #else
  1964. # if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_READ_oFFs_SUPPORTED)
  1965. PNG_EXTERN png_int_32 png_get_int_32 PNGARG((png_bytep buf));
  1966. # endif
  1967. PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf));
  1968. PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf));
  1969. #endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */
  1970. /* Initialize png_ptr struct for reading, and allocate any other memory.
  1971. * (old interface - NOT DLL EXPORTED).
  1972. */
  1973. extern void png_read_init PNGARG((png_structp png_ptr));
  1974. /* Initialize png_ptr struct for writing, and allocate any other memory.
  1975. * (old interface - NOT DLL EXPORTED).
  1976. */
  1977. extern void png_write_init PNGARG((png_structp png_ptr));
  1978. /* Allocate memory for an internal libpng struct */
  1979. PNG_EXTERN png_voidp png_create_struct PNGARG((int type));
  1980. /* Free memory from internal libpng struct */
  1981. PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr));
  1982. PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr
  1983. malloc_fn));
  1984. PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr,
  1985. png_free_ptr free_fn));
  1986. /* Free any memory that info_ptr points to and reset struct. */
  1987. PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,
  1988. png_infop info_ptr));
  1989. /* Function to allocate memory for zlib. */
  1990. PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size));
  1991. /* Function to free memory for zlib */
  1992. PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr));
  1993. /* Reset the CRC variable */
  1994. PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
  1995. /* Write the "data" buffer to whatever output you are using. */
  1996. PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
  1997. png_size_t length));
  1998. /* Read data from whatever input you are using into the "data" buffer */
  1999. PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data,
  2000. png_size_t length));
  2001. /* Read bytes into buf, and update png_ptr->crc */
  2002. PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf,
  2003. png_size_t length));
  2004. /* Decompress data in a chunk that uses compression */
  2005. #if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \
  2006. defined(PNG_READ_iCCP_SUPPORTED) || defined(PNG_READ_sPLT_SUPPORTED)
  2007. PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr,
  2008. int comp_type, png_charp chunkdata, png_size_t chunklength,
  2009. png_size_t prefix_size, png_size_t *data_size));
  2010. #endif
  2011. /* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
  2012. PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip));
  2013. /* Read the CRC from the file and compare it to the libpng calculated CRC */
  2014. PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr));
  2015. /* Calculate the CRC over a section of data. Note that we are only
  2016. * passing a maximum of 64K on systems that have this as a memory limit,
  2017. * since this is the maximum buffer size we can specify.
  2018. */
  2019. PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr,
  2020. png_size_t length));
  2021. #if defined(PNG_WRITE_FLUSH_SUPPORTED)
  2022. PNG_EXTERN void png_flush PNGARG((png_structp png_ptr));
  2023. #endif
  2024. /* Place a 32-bit number into a buffer in PNG byte order (big-endian).
  2025. * The only currently known PNG chunks that use signed numbers are
  2026. * the ancillary extension chunks, oFFs and pCAL.
  2027. */
  2028. PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i));
  2029. #if defined(PNG_WRITE_pCAL_SUPPORTED)
  2030. PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i));
  2031. #endif
  2032. /* Place a 16-bit number into a buffer in PNG byte order.
  2033. * The parameter is declared unsigned int, not png_uint_16,
  2034. * just to avoid potential problems on pre-ANSI C compilers.
  2035. */
  2036. PNG_EXTERN void png_save_uint_16 PNGARG((png_bytep buf, unsigned int i));
  2037. /* simple function to write the signature */
  2038. PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr));
  2039. /* write various chunks */
  2040. /* Write the IHDR chunk, and update the png_struct with the necessary
  2041. * information.
  2042. */
  2043. PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width,
  2044. png_uint_32 height,
  2045. int bit_depth, int color_type, int compression_type, int filter_type,
  2046. int interlace_type));
  2047. PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette,
  2048. png_uint_32 num_pal));
  2049. PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data,
  2050. png_size_t length));
  2051. PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr));
  2052. #if defined(PNG_WRITE_gAMA_SUPPORTED)
  2053. #ifdef PNG_FLOATING_POINT_SUPPORTED
  2054. PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma));
  2055. #endif
  2056. #ifdef PNG_FIXED_POINT_SUPPORTED
  2057. PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point
  2058. file_gamma));
  2059. #endif
  2060. #endif
  2061. #if defined(PNG_WRITE_sBIT_SUPPORTED)
  2062. PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit,
  2063. int color_type));
  2064. #endif
  2065. #if defined(PNG_WRITE_cHRM_SUPPORTED)
  2066. #ifdef PNG_FLOATING_POINT_SUPPORTED
  2067. PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr,
  2068. double white_x, double white_y,
  2069. double red_x, double red_y, double green_x, double green_y,
  2070. double blue_x, double blue_y));
  2071. #endif
  2072. #ifdef PNG_FIXED_POINT_SUPPORTED
  2073. PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr,
  2074. png_fixed_point int_white_x, png_fixed_point int_white_y,
  2075. png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
  2076. int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
  2077. png_fixed_point int_blue_y));
  2078. #endif
  2079. #endif
  2080. #if defined(PNG_WRITE_sRGB_SUPPORTED)
  2081. PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,
  2082. int intent));
  2083. #endif
  2084. #if defined(PNG_WRITE_iCCP_SUPPORTED)
  2085. PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr,
  2086. png_charp name, int compression_type,
  2087. png_charp profile, int proflen));
  2088. #endif
  2089. #if defined(PNG_WRITE_sPLT_SUPPORTED)
  2090. PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr,
  2091. png_sPLT_tp palette));
  2092. #endif
  2093. #if defined(PNG_WRITE_tRNS_SUPPORTED)
  2094. PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans,
  2095. png_color_16p values, int number, int color_type));
  2096. #endif
  2097. #if defined(PNG_WRITE_bKGD_SUPPORTED)
  2098. PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr,
  2099. png_color_16p values, int color_type));
  2100. #endif
  2101. #if defined(PNG_WRITE_hIST_SUPPORTED)
  2102. PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist,
  2103. int num_hist));
  2104. #endif
  2105. #if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \
  2106. defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
  2107. PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr,
  2108. png_charp key, png_charpp new_key));
  2109. #endif
  2110. #if defined(PNG_WRITE_tEXt_SUPPORTED)
  2111. PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key,
  2112. png_charp text, png_size_t text_len));
  2113. #endif
  2114. #if defined(PNG_WRITE_zTXt_SUPPORTED)
  2115. PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key,
  2116. png_charp text, png_size_t text_len, int compression));
  2117. #endif
  2118. #if defined(PNG_WRITE_iTXt_SUPPORTED)
  2119. PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr,
  2120. int compression, png_charp key, png_charp lang, png_charp lang_key,
  2121. png_charp text));
  2122. #endif
  2123. #if defined(PNG_WRITE_oFFs_SUPPORTED)
  2124. PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr,
  2125. png_uint_32 x_offset, png_uint_32 y_offset, int unit_type));
  2126. #endif
  2127. #if defined(PNG_WRITE_pCAL_SUPPORTED)
  2128. PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose,
  2129. png_int_32 X0, png_int_32 X1, int type, int nparams,
  2130. png_charp units, png_charpp params));
  2131. #endif
  2132. #if defined(PNG_WRITE_pHYs_SUPPORTED)
  2133. PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr,
  2134. png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,
  2135. int unit_type));
  2136. #endif
  2137. #if defined(PNG_WRITE_tIME_SUPPORTED)
  2138. PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr,
  2139. png_timep mod_time));
  2140. #endif
  2141. #if defined(PNG_WRITE_sCAL_SUPPORTED)
  2142. #if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO)
  2143. PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr,
  2144. int unit, double width, double height));
  2145. #else
  2146. #ifdef PNG_FIXED_POINT_SUPPORTED
  2147. PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr,
  2148. int unit, png_charp width, png_charp height));
  2149. #endif
  2150. #endif
  2151. #endif
  2152. /* Called when finished processing a row of data */
  2153. PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));
  2154. /* Internal use only. Called before first row of data */
  2155. PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr));
  2156. #if defined(PNG_READ_GAMMA_SUPPORTED)
  2157. PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr));
  2158. #endif
  2159. /* combine a row of data, dealing with alpha, etc. if requested */
  2160. PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row,
  2161. int mask));
  2162. #if defined(PNG_READ_INTERLACING_SUPPORTED)
  2163. /* expand an interlaced row */
  2164. PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info,
  2165. png_bytep row, int pass, png_uint_32 transformations));
  2166. #endif
  2167. #if defined(PNG_WRITE_INTERLACING_SUPPORTED)
  2168. /* grab pixels out of a row for an interlaced pass */
  2169. PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info,
  2170. png_bytep row, int pass));
  2171. #endif
  2172. /* unfilter a row */
  2173. PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr,
  2174. png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter));
  2175. /* Choose the best filter to use and filter the row data */
  2176. PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr,
  2177. png_row_infop row_info));
  2178. /* Write out the filtered row. */
  2179. PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr,
  2180. png_bytep filtered_row));
  2181. /* finish a row while reading, dealing with interlacing passes, etc. */
  2182. PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr));
  2183. /* initialize the row buffers, etc. */
  2184. PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr));
  2185. /* optional call to update the users info structure */
  2186. PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,
  2187. png_infop info_ptr));
  2188. /* these are the functions that do the transformations */
  2189. #if defined(PNG_READ_FILLER_SUPPORTED)
  2190. PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info,
  2191. png_bytep row, png_uint_32 filler, png_uint_32 flags));
  2192. #endif
  2193. #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
  2194. PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info,
  2195. png_bytep row));
  2196. #endif
  2197. #if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
  2198. PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info,
  2199. png_bytep row));
  2200. #endif
  2201. #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
  2202. PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info,
  2203. png_bytep row));
  2204. #endif
  2205. #if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
  2206. PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info,
  2207. png_bytep row));
  2208. #endif
  2209. #if defined(PNG_WRITE_FILLER_SUPPORTED) || \
  2210. defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
  2211. PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
  2212. png_bytep row, png_uint_32 flags));
  2213. #endif
  2214. #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
  2215. PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row));
  2216. #endif
  2217. #if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
  2218. PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row));
  2219. #endif
  2220. #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
  2221. PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop
  2222. row_info, png_bytep row));
  2223. #endif
  2224. #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
  2225. PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info,
  2226. png_bytep row));
  2227. #endif
  2228. #if defined(PNG_READ_PACK_SUPPORTED)
  2229. PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row));
  2230. #endif
  2231. #if defined(PNG_READ_SHIFT_SUPPORTED)
  2232. PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row,
  2233. png_color_8p sig_bits));
  2234. #endif
  2235. #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
  2236. PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row));
  2237. #endif
  2238. #if defined(PNG_READ_16_TO_8_SUPPORTED)
  2239. PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row));
  2240. #endif
  2241. #if defined(PNG_READ_DITHER_SUPPORTED)
  2242. PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info,
  2243. png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup));
  2244. # if defined(PNG_CORRECT_PALETTE_SUPPORTED)
  2245. PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr,
  2246. png_colorp palette, int num_palette));
  2247. # endif
  2248. #endif
  2249. #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
  2250. PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row));
  2251. #endif
  2252. #if defined(PNG_WRITE_PACK_SUPPORTED)
  2253. PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info,
  2254. png_bytep row, png_uint_32 bit_depth));
  2255. #endif
  2256. #if defined(PNG_WRITE_SHIFT_SUPPORTED)
  2257. PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row,
  2258. png_color_8p bit_depth));
  2259. #endif
  2260. #if defined(PNG_READ_BACKGROUND_SUPPORTED)
  2261. PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
  2262. png_color_16p trans_values, png_color_16p background,
  2263. png_color_16p background_1,
  2264. png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1,
  2265. png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1,
  2266. png_uint_16pp gamma_16_to_1, int gamma_shift));
  2267. #endif
  2268. #if defined(PNG_READ_GAMMA_SUPPORTED)
  2269. PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row,
  2270. png_bytep gamma_table, png_uint_16pp gamma_16_table,
  2271. int gamma_shift));
  2272. #endif
  2273. #if defined(PNG_READ_EXPAND_SUPPORTED)
  2274. PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info,
  2275. png_bytep row, png_colorp palette, png_bytep trans, int num_trans));
  2276. PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info,
  2277. png_bytep row, png_color_16p trans_value));
  2278. #endif
  2279. /* The following decodes the appropriate chunks, and does error correction,
  2280. * then calls the appropriate callback for the chunk if it is valid.
  2281. */
  2282. /* decode the IHDR chunk */
  2283. PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr,
  2284. png_uint_32 length));
  2285. PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr,
  2286. png_uint_32 length));
  2287. PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr,
  2288. png_uint_32 length));
  2289. #if defined(PNG_READ_bKGD_SUPPORTED)
  2290. PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr,
  2291. png_uint_32 length));
  2292. #endif
  2293. #if defined(PNG_READ_cHRM_SUPPORTED)
  2294. PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr,
  2295. png_uint_32 length));
  2296. #endif
  2297. #if defined(PNG_READ_gAMA_SUPPORTED)
  2298. PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr,
  2299. png_uint_32 length));
  2300. #endif
  2301. #if defined(PNG_READ_hIST_SUPPORTED)
  2302. PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,
  2303. png_uint_32 length));
  2304. #endif
  2305. #if defined(PNG_READ_iCCP_SUPPORTED)
  2306. extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
  2307. png_uint_32 length));
  2308. #endif /* PNG_READ_iCCP_SUPPORTED */
  2309. #if defined(PNG_READ_iTXt_SUPPORTED)
  2310. PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
  2311. png_uint_32 length));
  2312. #endif
  2313. #if defined(PNG_READ_oFFs_SUPPORTED)
  2314. PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr,
  2315. png_uint_32 length));
  2316. #endif
  2317. #if defined(PNG_READ_pCAL_SUPPORTED)
  2318. PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
  2319. png_uint_32 length));
  2320. #endif
  2321. #if defined(PNG_READ_pHYs_SUPPORTED)
  2322. PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr,
  2323. png_uint_32 length));
  2324. #endif
  2325. #if defined(PNG_READ_sBIT_SUPPORTED)
  2326. PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr,
  2327. png_uint_32 length));
  2328. #endif
  2329. #if defined(PNG_READ_sCAL_SUPPORTED)
  2330. PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
  2331. png_uint_32 length));
  2332. #endif
  2333. #if defined(PNG_READ_sPLT_SUPPORTED)
  2334. extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
  2335. png_uint_32 length));
  2336. #endif /* PNG_READ_sPLT_SUPPORTED */
  2337. #if defined(PNG_READ_sRGB_SUPPORTED)
  2338. PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr,
  2339. png_uint_32 length));
  2340. #endif
  2341. #if defined(PNG_READ_tEXt_SUPPORTED)
  2342. PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr,
  2343. png_uint_32 length));
  2344. #endif
  2345. #if defined(PNG_READ_tIME_SUPPORTED)
  2346. PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr,
  2347. png_uint_32 length));
  2348. #endif
  2349. #if defined(PNG_READ_tRNS_SUPPORTED)
  2350. PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr,
  2351. png_uint_32 length));
  2352. #endif
  2353. #if defined(PNG_READ_zTXt_SUPPORTED)
  2354. PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
  2355. png_uint_32 length));
  2356. #endif
  2357. #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
  2358. PNG_EXTERN int png_handle_as_unknown PNGARG((png_structp png_ptr, png_bytep
  2359. chunk_name));
  2360. #endif
  2361. PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
  2362. png_infop info_ptr, png_uint_32 length));
  2363. PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr,
  2364. png_bytep chunk_name));
  2365. /* handle the transformations for reading and writing */
  2366. PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr));
  2367. PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr));
  2368. PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr));
  2369. #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
  2370. PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr,
  2371. png_infop info_ptr));
  2372. PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr,
  2373. png_infop info_ptr));
  2374. PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr));
  2375. PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr,
  2376. png_uint_32 length));
  2377. PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr));
  2378. PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr,
  2379. png_bytep buffer, png_size_t length));
  2380. PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr));
  2381. PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr,
  2382. png_bytep buffer, png_size_t buffer_length));
  2383. PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr));
  2384. PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr,
  2385. png_bytep buffer, png_size_t buffer_length));
  2386. PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr));
  2387. PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr,
  2388. png_infop info_ptr, png_uint_32 length));
  2389. PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr,
  2390. png_infop info_ptr));
  2391. PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr,
  2392. png_infop info_ptr));
  2393. PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row));
  2394. PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr,
  2395. png_infop info_ptr));
  2396. PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr,
  2397. png_infop info_ptr));
  2398. PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr));
  2399. #if defined(PNG_READ_tEXt_SUPPORTED)
  2400. PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr,
  2401. png_infop info_ptr, png_uint_32 length));
  2402. PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr,
  2403. png_infop info_ptr));
  2404. #endif
  2405. #if defined(PNG_READ_zTXt_SUPPORTED)
  2406. PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr,
  2407. png_infop info_ptr, png_uint_32 length));
  2408. PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr,
  2409. png_infop info_ptr));
  2410. #endif
  2411. #if defined(PNG_READ_iTXt_SUPPORTED)
  2412. PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr,
  2413. png_infop info_ptr, png_uint_32 length));
  2414. PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr,
  2415. png_infop info_ptr));
  2416. #endif
  2417. #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
  2418. #endif /* PNG_INTERNAL */
  2419. #ifdef __cplusplus
  2420. }
  2421. #endif
  2422. /* do not put anything past this line */
  2423. #endif /* _PNG_H */