/thirdparty/libpng/png.h

http://crashrpt.googlecode.com/ · C++ Header · 3361 lines · 1991 code · 449 blank · 921 comment · 64 complexity · e0a27785c50bd7a2bee6b814a9522388 MD5 · raw file

Large files are truncated click here to view the full file

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