PageRenderTime 58ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/libpng/png.h

https://code.google.com/p/xee/
C++ Header | 1498 lines | 728 code | 155 blank | 615 comment | 30 complexity | 9e2333260347f3842dbc85e48a1dd53d MD5 | raw file
  1. /* png.h - header file for PNG reference library
  2. *
  3. * libpng version 1.2.8 - December 3, 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.8 - December 3, 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. * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5
  110. * 1.0.18rc1-5 10 10018 12.so.0.1.0.18rc1-5
  111. * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5
  112. * 1.0.18 10 10018 12.so.0.1.0.18
  113. * 1.2.8 13 10208 12.so.0.1.2.8
  114. *
  115. * Henceforth the source version will match the shared-library major
  116. * and minor numbers; the shared-library major version number will be
  117. * used for changes in backward compatibility, as it is intended. The
  118. * PNG_LIBPNG_VER macro, which is not used within libpng but is available
  119. * for applications, is an unsigned integer of the form xyyzz corresponding
  120. * to the source version x.y.z (leading zeros in y and z). Beta versions
  121. * were given the previous public release number plus a letter, until
  122. * version 1.0.6j; from then on they were given the upcoming public
  123. * release number plus "betaNN" or "rcN".
  124. *
  125. * Binary incompatibility exists only when applications make direct access
  126. * to the info_ptr or png_ptr members through png.h, and the compiled
  127. * application is loaded with a different version of the library.
  128. *
  129. * DLLNUM will change each time there are forward or backward changes
  130. * in binary compatibility (e.g., when a new feature is added).
  131. *
  132. * See libpng.txt or libpng.3 for more information. The PNG specification
  133. * is available as a W3C Recommendation and as an ISO Specification,
  134. * <http://www.w3.org/TR/2003/REC-PNG-20031110/
  135. */
  136. /*
  137. * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
  138. *
  139. * If you modify libpng you may insert additional notices immediately following
  140. * this sentence.
  141. *
  142. * libpng versions 1.2.6, August 15, 2004, through 1.2.8, December 3, 2004, are
  143. * Copyright (c) 2004 Glenn Randers-Pehrson, and are
  144. * distributed according to the same disclaimer and license as libpng-1.2.5
  145. * with the following individual added to the list of Contributing Authors:
  146. *
  147. * Cosmin Truta
  148. *
  149. * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are
  150. * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
  151. * distributed according to the same disclaimer and license as libpng-1.0.6
  152. * with the following individuals added to the list of Contributing Authors:
  153. *
  154. * Simon-Pierre Cadieux
  155. * Eric S. Raymond
  156. * Gilles Vollant
  157. *
  158. * and with the following additions to the disclaimer:
  159. *
  160. * There is no warranty against interference with your enjoyment of the
  161. * library or against infringement. There is no warranty that our
  162. * efforts or the library will fulfill any of your particular purposes
  163. * or needs. This library is provided with all faults, and the entire
  164. * risk of satisfactory quality, performance, accuracy, and effort is with
  165. * the user.
  166. *
  167. * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
  168. * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are
  169. * distributed according to the same disclaimer and license as libpng-0.96,
  170. * with the following individuals added to the list of Contributing Authors:
  171. *
  172. * Tom Lane
  173. * Glenn Randers-Pehrson
  174. * Willem van Schaik
  175. *
  176. * libpng versions 0.89, June 1996, through 0.96, May 1997, are
  177. * Copyright (c) 1996, 1997 Andreas Dilger
  178. * Distributed according to the same disclaimer and license as libpng-0.88,
  179. * with the following individuals added to the list of Contributing Authors:
  180. *
  181. * John Bowler
  182. * Kevin Bracey
  183. * Sam Bushell
  184. * Magnus Holmgren
  185. * Greg Roelofs
  186. * Tom Tanner
  187. *
  188. * libpng versions 0.5, May 1995, through 0.88, January 1996, are
  189. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  190. *
  191. * For the purposes of this copyright and license, "Contributing Authors"
  192. * is defined as the following set of individuals:
  193. *
  194. * Andreas Dilger
  195. * Dave Martindale
  196. * Guy Eric Schalnat
  197. * Paul Schmidt
  198. * Tim Wegner
  199. *
  200. * The PNG Reference Library is supplied "AS IS". The Contributing Authors
  201. * and Group 42, Inc. disclaim all warranties, expressed or implied,
  202. * including, without limitation, the warranties of merchantability and of
  203. * fitness for any purpose. The Contributing Authors and Group 42, Inc.
  204. * assume no liability for direct, indirect, incidental, special, exemplary,
  205. * or consequential damages, which may result from the use of the PNG
  206. * Reference Library, even if advised of the possibility of such damage.
  207. *
  208. * Permission is hereby granted to use, copy, modify, and distribute this
  209. * source code, or portions hereof, for any purpose, without fee, subject
  210. * to the following restrictions:
  211. *
  212. * 1. The origin of this source code must not be misrepresented.
  213. *
  214. * 2. Altered versions must be plainly marked as such and
  215. * must not be misrepresented as being the original source.
  216. *
  217. * 3. This Copyright notice may not be removed or altered from
  218. * any source or altered source distribution.
  219. *
  220. * The Contributing Authors and Group 42, Inc. specifically permit, without
  221. * fee, and encourage the use of this source code as a component to
  222. * supporting the PNG file format in commercial products. If you use this
  223. * source code in a product, acknowledgment is not required but would be
  224. * appreciated.
  225. */
  226. /*
  227. * A "png_get_copyright" function is available, for convenient use in "about"
  228. * boxes and the like:
  229. *
  230. * printf("%s",png_get_copyright(NULL));
  231. *
  232. * Also, the PNG logo (in PNG format, of course) is supplied in the
  233. * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
  234. */
  235. /*
  236. * Libpng is OSI Certified Open Source Software. OSI Certified is a
  237. * certification mark of the Open Source Initiative.
  238. */
  239. /*
  240. * The contributing authors would like to thank all those who helped
  241. * with testing, bug fixes, and patience. This wouldn't have been
  242. * possible without all of you.
  243. *
  244. * Thanks to Frank J. T. Wojcik for helping with the documentation.
  245. */
  246. /*
  247. * Y2K compliance in libpng:
  248. * =========================
  249. *
  250. * December 3, 2004
  251. *
  252. * Since the PNG Development group is an ad-hoc body, we can't make
  253. * an official declaration.
  254. *
  255. * This is your unofficial assurance that libpng from version 0.71 and
  256. * upward through 1.2.8 are Y2K compliant. It is my belief that earlier
  257. * versions were also Y2K compliant.
  258. *
  259. * Libpng only has three year fields. One is a 2-byte unsigned integer
  260. * that will hold years up to 65535. The other two hold the date in text
  261. * format, and will hold years up to 9999.
  262. *
  263. * The integer is
  264. * "png_uint_16 year" in png_time_struct.
  265. *
  266. * The strings are
  267. * "png_charp time_buffer" in png_struct and
  268. * "near_time_buffer", which is a local character string in png.c.
  269. *
  270. * There are seven time-related functions:
  271. * png.c: png_convert_to_rfc_1123() in png.c
  272. * (formerly png_convert_to_rfc_1152() in error)
  273. * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
  274. * png_convert_from_time_t() in pngwrite.c
  275. * png_get_tIME() in pngget.c
  276. * png_handle_tIME() in pngrutil.c, called in pngread.c
  277. * png_set_tIME() in pngset.c
  278. * png_write_tIME() in pngwutil.c, called in pngwrite.c
  279. *
  280. * All handle dates properly in a Y2K environment. The
  281. * png_convert_from_time_t() function calls gmtime() to convert from system
  282. * clock time, which returns (year - 1900), which we properly convert to
  283. * the full 4-digit year. There is a possibility that applications using
  284. * libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
  285. * function, or that they are incorrectly passing only a 2-digit year
  286. * instead of "year - 1900" into the png_convert_from_struct_tm() function,
  287. * but this is not under our control. The libpng documentation has always
  288. * stated that it works with 4-digit years, and the APIs have been
  289. * documented as such.
  290. *
  291. * The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
  292. * integer to hold the year, and can hold years as large as 65535.
  293. *
  294. * zlib, upon which libpng depends, is also Y2K compliant. It contains
  295. * no date-related code.
  296. *
  297. * Glenn Randers-Pehrson
  298. * libpng maintainer
  299. * PNG Development Group
  300. */
  301. #ifndef PNG_H
  302. #define PNG_H
  303. /* This is not the place to learn how to use libpng. The file libpng.txt
  304. * describes how to use libpng, and the file example.c summarizes it
  305. * with some code on which to build. This file is useful for looking
  306. * at the actual function definitions and structure components.
  307. */
  308. /* Version information for png.h - this should match the version in png.c */
  309. #define PNG_LIBPNG_VER_STRING "1.2.8"
  310. #define PNG_HEADER_VERSION_STRING \
  311. " libpng version 1.2.8 - December 3, 2004 (header)\n"
  312. #define PNG_LIBPNG_VER_SONUM 0
  313. #define PNG_LIBPNG_VER_DLLNUM 13
  314. /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
  315. #define PNG_LIBPNG_VER_MAJOR 1
  316. #define PNG_LIBPNG_VER_MINOR 2
  317. #define PNG_LIBPNG_VER_RELEASE 8
  318. /* This should match the numeric part of the final component of
  319. * PNG_LIBPNG_VER_STRING, omitting any leading zero: */
  320. #define PNG_LIBPNG_VER_BUILD 0
  321. /* Release Status */
  322. #define PNG_LIBPNG_BUILD_ALPHA 1
  323. #define PNG_LIBPNG_BUILD_BETA 2
  324. #define PNG_LIBPNG_BUILD_RC 3
  325. #define PNG_LIBPNG_BUILD_STABLE 4
  326. #define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7
  327. /* Release-Specific Flags */
  328. #define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with
  329. PNG_LIBPNG_BUILD_STABLE only */
  330. #define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with
  331. PNG_LIBPNG_BUILD_SPECIAL */
  332. #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
  333. PNG_LIBPNG_BUILD_PRIVATE */
  334. #define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
  335. /* Careful here. At one time, Guy wanted to use 082, but that would be octal.
  336. * We must not include leading zeros.
  337. * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
  338. * version 1.0.0 was mis-numbered 100 instead of 10000). From
  339. * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */
  340. #define PNG_LIBPNG_VER 10208 /* 1.2.8 */
  341. #ifndef PNG_VERSION_INFO_ONLY
  342. /* include the compression library's header */
  343. #include "zlib.h"
  344. #endif
  345. /* include all user configurable info, including optional assembler routines */
  346. #include "pngconf.h"
  347. /*
  348. * Added at libpng-1.2.8 */
  349. /* Ref MSDN: Private as priority over Special
  350. * VS_FF_PRIVATEBUILD File *was not* built using standard release
  351. * procedures. If this value is given, the StringFileInfo block must
  352. * contain a PrivateBuild string.
  353. *
  354. * VS_FF_SPECIALBUILD File *was* built by the original company using
  355. * standard release procedures but is a variation of the standard
  356. * file of the same version number. If this value is given, the
  357. * StringFileInfo block must contain a SpecialBuild string.
  358. */
  359. #if defined(PNG_USER_PRIVATEBUILD)
  360. # define PNG_LIBPNG_BUILD_TYPE PNG_LIBPNG_BUILD_BASE_TYPE | \
  361. PNG_LIBPNG_BUILD_PRIVATE
  362. #else
  363. # if defined(PNG_LIBPNG_SPECIALBUILD)
  364. # define PNG_LIBPNG_BUILD_TYPE PNG_LIBPNG_BUILD_BASE_TYPE | \
  365. PNG_LIBPNG_BUILD_SPECIAL
  366. # else
  367. # define PNG_LIBPNG_BUILD_TYPE PNG_LIBPNG_BUILD_BASE_TYPE
  368. # endif
  369. #endif
  370. #ifndef PNG_VERSION_INFO_ONLY
  371. /* Inhibit C++ name-mangling for libpng functions but not for system calls. */
  372. #ifdef __cplusplus
  373. extern "C" {
  374. #endif /* __cplusplus */
  375. /* This file is arranged in several sections. The first section contains
  376. * structure and type definitions. The second section contains the external
  377. * library functions, while the third has the internal library functions,
  378. * which applications aren't expected to use directly.
  379. */
  380. #ifndef PNG_NO_TYPECAST_NULL
  381. #define int_p_NULL (int *)NULL
  382. #define png_bytep_NULL (png_bytep)NULL
  383. #define png_bytepp_NULL (png_bytepp)NULL
  384. #define png_doublep_NULL (png_doublep)NULL
  385. #define png_error_ptr_NULL (png_error_ptr)NULL
  386. #define png_flush_ptr_NULL (png_flush_ptr)NULL
  387. #define png_free_ptr_NULL (png_free_ptr)NULL
  388. #define png_infopp_NULL (png_infopp)NULL
  389. #define png_malloc_ptr_NULL (png_malloc_ptr)NULL
  390. #define png_read_status_ptr_NULL (png_read_status_ptr)NULL
  391. #define png_rw_ptr_NULL (png_rw_ptr)NULL
  392. #define png_structp_NULL (png_structp)NULL
  393. #define png_uint_16p_NULL (png_uint_16p)NULL
  394. #define png_voidp_NULL (png_voidp)NULL
  395. #define png_write_status_ptr_NULL (png_write_status_ptr)NULL
  396. #else
  397. #define int_p_NULL NULL
  398. #define png_bytep_NULL NULL
  399. #define png_bytepp_NULL NULL
  400. #define png_doublep_NULL NULL
  401. #define png_error_ptr_NULL NULL
  402. #define png_flush_ptr_NULL NULL
  403. #define png_free_ptr_NULL NULL
  404. #define png_infopp_NULL NULL
  405. #define png_malloc_ptr_NULL NULL
  406. #define png_read_status_ptr_NULL NULL
  407. #define png_rw_ptr_NULL NULL
  408. #define png_structp_NULL NULL
  409. #define png_uint_16p_NULL NULL
  410. #define png_voidp_NULL NULL
  411. #define png_write_status_ptr_NULL NULL
  412. #endif
  413. /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
  414. #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
  415. /* Version information for C files, stored in png.c. This had better match
  416. * the version above.
  417. */
  418. #ifdef PNG_USE_GLOBAL_ARRAYS
  419. PNG_EXPORT_VAR (const char) png_libpng_ver[18];
  420. /* need room for 99.99.99beta99z */
  421. #else
  422. #define png_libpng_ver png_get_header_ver(NULL)
  423. #endif
  424. #ifdef PNG_USE_GLOBAL_ARRAYS
  425. /* This was removed in version 1.0.5c */
  426. /* Structures to facilitate easy interlacing. See png.c for more details */
  427. PNG_EXPORT_VAR (const int FARDATA) png_pass_start[7];
  428. PNG_EXPORT_VAR (const int FARDATA) png_pass_inc[7];
  429. PNG_EXPORT_VAR (const int FARDATA) png_pass_ystart[7];
  430. PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7];
  431. PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7];
  432. PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7];
  433. #ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
  434. PNG_EXPORT_VAR (const int FARDATA) png_pass_width[7];
  435. #endif
  436. /* This isn't currently used. If you need it, see png.c for more details.
  437. PNG_EXPORT_VAR (const int FARDATA) png_pass_height[7];
  438. */
  439. #endif
  440. #endif /* PNG_NO_EXTERN */
  441. /* Three color definitions. The order of the red, green, and blue, (and the
  442. * exact size) is not important, although the size of the fields need to
  443. * be png_byte or png_uint_16 (as defined below).
  444. */
  445. typedef struct png_color_struct
  446. {
  447. png_byte red;
  448. png_byte green;
  449. png_byte blue;
  450. } png_color;
  451. typedef png_color FAR * png_colorp;
  452. typedef png_color FAR * FAR * png_colorpp;
  453. typedef struct png_color_16_struct
  454. {
  455. png_byte index; /* used for palette files */
  456. png_uint_16 red; /* for use in red green blue files */
  457. png_uint_16 green;
  458. png_uint_16 blue;
  459. png_uint_16 gray; /* for use in grayscale files */
  460. } png_color_16;
  461. typedef png_color_16 FAR * png_color_16p;
  462. typedef png_color_16 FAR * FAR * png_color_16pp;
  463. typedef struct png_color_8_struct
  464. {
  465. png_byte red; /* for use in red green blue files */
  466. png_byte green;
  467. png_byte blue;
  468. png_byte gray; /* for use in grayscale files */
  469. png_byte alpha; /* for alpha channel files */
  470. } png_color_8;
  471. typedef png_color_8 FAR * png_color_8p;
  472. typedef png_color_8 FAR * FAR * png_color_8pp;
  473. /*
  474. * The following two structures are used for the in-core representation
  475. * of sPLT chunks.
  476. */
  477. typedef struct png_sPLT_entry_struct
  478. {
  479. png_uint_16 red;
  480. png_uint_16 green;
  481. png_uint_16 blue;
  482. png_uint_16 alpha;
  483. png_uint_16 frequency;
  484. } png_sPLT_entry;
  485. typedef png_sPLT_entry FAR * png_sPLT_entryp;
  486. typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp;
  487. /* When the depth of the sPLT palette is 8 bits, the color and alpha samples
  488. * occupy the LSB of their respective members, and the MSB of each member
  489. * is zero-filled. The frequency member always occupies the full 16 bits.
  490. */
  491. typedef struct png_sPLT_struct
  492. {
  493. png_charp name; /* palette name */
  494. png_byte depth; /* depth of palette samples */
  495. png_sPLT_entryp entries; /* palette entries */
  496. png_int_32 nentries; /* number of palette entries */
  497. } png_sPLT_t;
  498. typedef png_sPLT_t FAR * png_sPLT_tp;
  499. typedef png_sPLT_t FAR * FAR * png_sPLT_tpp;
  500. #ifdef PNG_TEXT_SUPPORTED
  501. /* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,
  502. * and whether that contents is compressed or not. The "key" field
  503. * points to a regular zero-terminated C string. The "text", "lang", and
  504. * "lang_key" fields can be regular C strings, empty strings, or NULL pointers.
  505. * However, the * structure returned by png_get_text() will always contain
  506. * regular zero-terminated C strings (possibly empty), never NULL pointers,
  507. * so they can be safely used in printf() and other string-handling functions.
  508. */
  509. typedef struct png_text_struct
  510. {
  511. int compression; /* compression value:
  512. -1: tEXt, none
  513. 0: zTXt, deflate
  514. 1: iTXt, none
  515. 2: iTXt, deflate */
  516. png_charp key; /* keyword, 1-79 character description of "text" */
  517. png_charp text; /* comment, may be an empty string (ie "")
  518. or a NULL pointer */
  519. png_size_t text_length; /* length of the text string */
  520. #ifdef PNG_iTXt_SUPPORTED
  521. png_size_t itxt_length; /* length of the itxt string */
  522. png_charp lang; /* language code, 0-79 characters
  523. or a NULL pointer */
  524. png_charp lang_key; /* keyword translated UTF-8 string, 0 or more
  525. chars or a NULL pointer */
  526. #endif
  527. } png_text;
  528. typedef png_text FAR * png_textp;
  529. typedef png_text FAR * FAR * png_textpp;
  530. #endif
  531. /* Supported compression types for text in PNG files (tEXt, and zTXt).
  532. * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */
  533. #define PNG_TEXT_COMPRESSION_NONE_WR -3
  534. #define PNG_TEXT_COMPRESSION_zTXt_WR -2
  535. #define PNG_TEXT_COMPRESSION_NONE -1
  536. #define PNG_TEXT_COMPRESSION_zTXt 0
  537. #define PNG_ITXT_COMPRESSION_NONE 1
  538. #define PNG_ITXT_COMPRESSION_zTXt 2
  539. #define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */
  540. /* png_time is a way to hold the time in an machine independent way.
  541. * Two conversions are provided, both from time_t and struct tm. There
  542. * is no portable way to convert to either of these structures, as far
  543. * as I know. If you know of a portable way, send it to me. As a side
  544. * note - PNG has always been Year 2000 compliant!
  545. */
  546. typedef struct png_time_struct
  547. {
  548. png_uint_16 year; /* full year, as in, 1995 */
  549. png_byte month; /* month of year, 1 - 12 */
  550. png_byte day; /* day of month, 1 - 31 */
  551. png_byte hour; /* hour of day, 0 - 23 */
  552. png_byte minute; /* minute of hour, 0 - 59 */
  553. png_byte second; /* second of minute, 0 - 60 (for leap seconds) */
  554. } png_time;
  555. typedef png_time FAR * png_timep;
  556. typedef png_time FAR * FAR * png_timepp;
  557. #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
  558. /* png_unknown_chunk is a structure to hold queued chunks for which there is
  559. * no specific support. The idea is that we can use this to queue
  560. * up private chunks for output even though the library doesn't actually
  561. * know about their semantics.
  562. */
  563. typedef struct png_unknown_chunk_t
  564. {
  565. png_byte name[5];
  566. png_byte *data;
  567. png_size_t size;
  568. /* libpng-using applications should NOT directly modify this byte. */
  569. png_byte location; /* mode of operation at read time */
  570. }
  571. png_unknown_chunk;
  572. typedef png_unknown_chunk FAR * png_unknown_chunkp;
  573. typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;
  574. #endif
  575. /* png_info is a structure that holds the information in a PNG file so
  576. * that the application can find out the characteristics of the image.
  577. * If you are reading the file, this structure will tell you what is
  578. * in the PNG file. If you are writing the file, fill in the information
  579. * you want to put into the PNG file, then call png_write_info().
  580. * The names chosen should be very close to the PNG specification, so
  581. * consult that document for information about the meaning of each field.
  582. *
  583. * With libpng < 0.95, it was only possible to directly set and read the
  584. * the values in the png_info_struct, which meant that the contents and
  585. * order of the values had to remain fixed. With libpng 0.95 and later,
  586. * however, there are now functions that abstract the contents of
  587. * png_info_struct from the application, so this makes it easier to use
  588. * libpng with dynamic libraries, and even makes it possible to use
  589. * libraries that don't have all of the libpng ancillary chunk-handing
  590. * functionality.
  591. *
  592. * In any case, the order of the parameters in png_info_struct should NOT
  593. * be changed for as long as possible to keep compatibility with applications
  594. * that use the old direct-access method with png_info_struct.
  595. *
  596. * The following members may have allocated storage attached that should be
  597. * cleaned up before the structure is discarded: palette, trans, text,
  598. * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
  599. * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these
  600. * are automatically freed when the info structure is deallocated, if they were
  601. * allocated internally by libpng. This behavior can be changed by means
  602. * of the png_data_freer() function.
  603. *
  604. * More allocation details: all the chunk-reading functions that
  605. * change these members go through the corresponding png_set_*
  606. * functions. A function to clear these members is available: see
  607. * png_free_data(). The png_set_* functions do not depend on being
  608. * able to point info structure members to any of the storage they are
  609. * passed (they make their own copies), EXCEPT that the png_set_text
  610. * functions use the same storage passed to them in the text_ptr or
  611. * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
  612. * functions do not make their own copies.
  613. */
  614. typedef struct png_info_struct
  615. {
  616. /* the following are necessary for every PNG file */
  617. png_uint_32 width; /* width of image in pixels (from IHDR) */
  618. png_uint_32 height; /* height of image in pixels (from IHDR) */
  619. png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
  620. png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */
  621. png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */
  622. png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
  623. png_uint_16 num_trans; /* number of transparent palette color (tRNS) */
  624. png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
  625. png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */
  626. /* The following three should have been named *_method not *_type */
  627. png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
  628. png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
  629. png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
  630. /* The following is informational only on read, and not used on writes. */
  631. png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */
  632. png_byte pixel_depth; /* number of bits per pixel */
  633. png_byte spare_byte; /* to align the data, and for future use */
  634. png_byte signature[8]; /* magic bytes read by libpng from start of file */
  635. /* The rest of the data is optional. If you are reading, check the
  636. * valid field to see if the information in these are valid. If you
  637. * are writing, set the valid field to those chunks you want written,
  638. * and initialize the appropriate fields below.
  639. */
  640. #if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
  641. /* The gAMA chunk describes the gamma characteristics of the system
  642. * on which the image was created, normally in the range [1.0, 2.5].
  643. * Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
  644. */
  645. float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */
  646. #endif
  647. #if defined(PNG_sRGB_SUPPORTED)
  648. /* GR-P, 0.96a */
  649. /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
  650. png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */
  651. #endif
  652. #if defined(PNG_TEXT_SUPPORTED)
  653. /* The tEXt, and zTXt chunks contain human-readable textual data in
  654. * uncompressed, compressed, and optionally compressed forms, respectively.
  655. * The data in "text" is an array of pointers to uncompressed,
  656. * null-terminated C strings. Each chunk has a keyword that describes the
  657. * textual data contained in that chunk. Keywords are not required to be
  658. * unique, and the text string may be empty. Any number of text chunks may
  659. * be in an image.
  660. */
  661. int num_text; /* number of comments read/to write */
  662. int max_text; /* current size of text array */
  663. png_textp text; /* array of comments read/to write */
  664. #endif /* PNG_TEXT_SUPPORTED */
  665. #if defined(PNG_tIME_SUPPORTED)
  666. /* The tIME chunk holds the last time the displayed image data was
  667. * modified. See the png_time struct for the contents of this struct.
  668. */
  669. png_time mod_time;
  670. #endif
  671. #if defined(PNG_sBIT_SUPPORTED)
  672. /* The sBIT chunk specifies the number of significant high-order bits
  673. * in the pixel data. Values are in the range [1, bit_depth], and are
  674. * only specified for the channels in the pixel data. The contents of
  675. * the low-order bits is not specified. Data is valid if
  676. * (valid & PNG_INFO_sBIT) is non-zero.
  677. */
  678. png_color_8 sig_bit; /* significant bits in color channels */
  679. #endif
  680. #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \
  681. defined(PNG_READ_BACKGROUND_SUPPORTED)
  682. /* The tRNS chunk supplies transparency data for paletted images and
  683. * other image types that don't need a full alpha channel. There are
  684. * "num_trans" transparency values for a paletted image, stored in the
  685. * same order as the palette colors, starting from index 0. Values
  686. * for the data are in the range [0, 255], ranging from fully transparent
  687. * to fully opaque, respectively. For non-paletted images, there is a
  688. * single color specified that should be treated as fully transparent.
  689. * Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
  690. */
  691. png_bytep trans; /* transparent values for paletted image */
  692. png_color_16 trans_values; /* transparent color for non-palette image */
  693. #endif
  694. #if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
  695. /* The bKGD chunk gives the suggested image background color if the
  696. * display program does not have its own background color and the image
  697. * is needs to composited onto a background before display. The colors
  698. * in "background" are normally in the same color space/depth as the
  699. * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
  700. */
  701. png_color_16 background;
  702. #endif
  703. #if defined(PNG_oFFs_SUPPORTED)
  704. /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
  705. * and downwards from the top-left corner of the display, page, or other
  706. * application-specific co-ordinate space. See the PNG_OFFSET_ defines
  707. * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.
  708. */
  709. png_int_32 x_offset; /* x offset on page */
  710. png_int_32 y_offset; /* y offset on page */
  711. png_byte offset_unit_type; /* offset units type */
  712. #endif
  713. #if defined(PNG_pHYs_SUPPORTED)
  714. /* The pHYs chunk gives the physical pixel density of the image for
  715. * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
  716. * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
  717. */
  718. png_uint_32 x_pixels_per_unit; /* horizontal pixel density */
  719. png_uint_32 y_pixels_per_unit; /* vertical pixel density */
  720. png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
  721. #endif
  722. #if defined(PNG_hIST_SUPPORTED)
  723. /* The hIST chunk contains the relative frequency or importance of the
  724. * various palette entries, so that a viewer can intelligently select a
  725. * reduced-color palette, if required. Data is an array of "num_palette"
  726. * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
  727. * is non-zero.
  728. */
  729. png_uint_16p hist;
  730. #endif
  731. #ifdef PNG_cHRM_SUPPORTED
  732. /* The cHRM chunk describes the CIE color characteristics of the monitor
  733. * on which the PNG was created. This data allows the viewer to do gamut
  734. * mapping of the input image to ensure that the viewer sees the same
  735. * colors in the image as the creator. Values are in the range
  736. * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero.
  737. */
  738. #ifdef PNG_FLOATING_POINT_SUPPORTED
  739. float x_white;
  740. float y_white;
  741. float x_red;
  742. float y_red;
  743. float x_green;
  744. float y_green;
  745. float x_blue;
  746. float y_blue;
  747. #endif
  748. #endif
  749. #if defined(PNG_pCAL_SUPPORTED)
  750. /* The pCAL chunk describes a transformation between the stored pixel
  751. * values and original physical data values used to create the image.
  752. * The integer range [0, 2^bit_depth - 1] maps to the floating-point
  753. * range given by [pcal_X0, pcal_X1], and are further transformed by a
  754. * (possibly non-linear) transformation function given by "pcal_type"
  755. * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_
  756. * defines below, and the PNG-Group's PNG extensions document for a
  757. * complete description of the transformations and how they should be
  758. * implemented, and for a description of the ASCII parameter strings.
  759. * Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
  760. */
  761. png_charp pcal_purpose; /* pCAL chunk description string */
  762. png_int_32 pcal_X0; /* minimum value */
  763. png_int_32 pcal_X1; /* maximum value */
  764. png_charp pcal_units; /* Latin-1 string giving physical units */
  765. png_charpp pcal_params; /* ASCII strings containing parameter values */
  766. png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */
  767. png_byte pcal_nparams; /* number of parameters given in pcal_params */
  768. #endif
  769. /* New members added in libpng-1.0.6 */
  770. #ifdef PNG_FREE_ME_SUPPORTED
  771. png_uint_32 free_me; /* flags items libpng is responsible for freeing */
  772. #endif
  773. #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
  774. /* storage for unknown chunks that the library doesn't recognize. */
  775. png_unknown_chunkp unknown_chunks;
  776. png_size_t unknown_chunks_num;
  777. #endif
  778. #if defined(PNG_iCCP_SUPPORTED)
  779. /* iCCP chunk data. */
  780. png_charp iccp_name; /* profile name */
  781. png_charp iccp_profile; /* International Color Consortium profile data */
  782. /* Note to maintainer: should be png_bytep */
  783. png_uint_32 iccp_proflen; /* ICC profile data length */
  784. png_byte iccp_compression; /* Always zero */
  785. #endif
  786. #if defined(PNG_sPLT_SUPPORTED)
  787. /* data on sPLT chunks (there may be more than one). */
  788. png_sPLT_tp splt_palettes;
  789. png_uint_32 splt_palettes_num;
  790. #endif
  791. #if defined(PNG_sCAL_SUPPORTED)
  792. /* The sCAL chunk describes the actual physical dimensions of the
  793. * subject matter of the graphic. The chunk contains a unit specification
  794. * a byte value, and two ASCII strings representing floating-point
  795. * values. The values are width and height corresponsing to one pixel
  796. * in the image. This external representation is converted to double
  797. * here. Data values are valid if (valid & PNG_INFO_sCAL) is non-zero.
  798. */
  799. png_byte scal_unit; /* unit of physical scale */
  800. #ifdef PNG_FLOATING_POINT_SUPPORTED
  801. double scal_pixel_width; /* width of one pixel */
  802. double scal_pixel_height; /* height of one pixel */
  803. #endif
  804. #ifdef PNG_FIXED_POINT_SUPPORTED
  805. png_charp scal_s_width; /* string containing height */
  806. png_charp scal_s_height; /* string containing width */
  807. #endif
  808. #endif
  809. #if defined(PNG_INFO_IMAGE_SUPPORTED)
  810. /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */
  811. /* Data valid if (valid & PNG_INFO_IDAT) non-zero */
  812. png_bytepp row_pointers; /* the image bits */
  813. #endif
  814. #if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED)
  815. png_fixed_point int_gamma; /* gamma of image, if (valid & PNG_INFO_gAMA) */
  816. #endif
  817. #if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED)
  818. png_fixed_point int_x_white;
  819. png_fixed_point int_y_white;
  820. png_fixed_point int_x_red;
  821. png_fixed_point int_y_red;
  822. png_fixed_point int_x_green;
  823. png_fixed_point int_y_green;
  824. png_fixed_point int_x_blue;
  825. png_fixed_point int_y_blue;
  826. #endif
  827. } png_info;
  828. typedef png_info FAR * png_infop;
  829. typedef png_info FAR * FAR * png_infopp;
  830. /* Maximum positive integer used in PNG is (2^31)-1 */
  831. #define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)
  832. #define PNG_UINT_32_MAX ((png_uint_32)(-1))
  833. #define PNG_SIZE_MAX ((png_size_t)(-1))
  834. /* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */
  835. #define PNG_MAX_UINT PNG_UINT_31_MAX
  836. /* These describe the color_type field in png_info. */
  837. /* color type masks */
  838. #define PNG_COLOR_MASK_PALETTE 1
  839. #define PNG_COLOR_MASK_COLOR 2
  840. #define PNG_COLOR_MASK_ALPHA 4
  841. /* color types. Note that not all combinations are legal */
  842. #define PNG_COLOR_TYPE_GRAY 0
  843. #define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
  844. #define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR)
  845. #define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  846. #define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
  847. /* aliases */
  848. #define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA
  849. #define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA
  850. /* This is for compression type. PNG 1.0-1.2 only define the single type. */
  851. #define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */
  852. #define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE
  853. /* This is for filter type. PNG 1.0-1.2 only define the single type. */
  854. #define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */
  855. #define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */
  856. #define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE
  857. /* These are for the interlacing type. These values should NOT be changed. */
  858. #define PNG_INTERLACE_NONE 0 /* Non-interlaced image */
  859. #define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */
  860. #define PNG_INTERLACE_LAST 2 /* Not a valid value */
  861. /* These are for the oFFs chunk. These values should NOT be changed. */
  862. #define PNG_OFFSET_PIXEL 0 /* Offset in pixels */
  863. #define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */
  864. #define PNG_OFFSET_LAST 2 /* Not a valid value */
  865. /* These are for the pCAL chunk. These values should NOT be changed. */
  866. #define PNG_EQUATION_LINEAR 0 /* Linear transformation */
  867. #define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */
  868. #define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */
  869. #define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */
  870. #define PNG_EQUATION_LAST 4 /* Not a valid value */
  871. /* These are for the sCAL chunk. These values should NOT be changed. */
  872. #define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */
  873. #define PNG_SCALE_METER 1 /* meters per pixel */
  874. #define PNG_SCALE_RADIAN 2 /* radians per pixel */
  875. #define PNG_SCALE_LAST 3 /* Not a valid value */
  876. /* These are for the pHYs chunk. These values should NOT be changed. */
  877. #define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */
  878. #define PNG_RESOLUTION_METER 1 /* pixels/meter */
  879. #define PNG_RESOLUTION_LAST 2 /* Not a valid value */
  880. /* These are for the sRGB chunk. These values should NOT be changed. */
  881. #define PNG_sRGB_INTENT_PERCEPTUAL 0
  882. #define PNG_sRGB_INTENT_RELATIVE 1
  883. #define PNG_sRGB_INTENT_SATURATION 2
  884. #define PNG_sRGB_INTENT_ABSOLUTE 3
  885. #define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */
  886. /* This is for text chunks */
  887. #define PNG_KEYWORD_MAX_LENGTH 79
  888. /* Maximum number of entries in PLTE/sPLT/tRNS arrays */
  889. #define PNG_MAX_PALETTE_LENGTH 256
  890. /* These determine if an ancillary chunk's data has been successfully read
  891. * from the PNG header, or if the application has filled in the corresponding
  892. * data in the info_struct to be written into the output file. The values
  893. * of the PNG_INFO_<chunk> defines should NOT be changed.
  894. */
  895. #define PNG_INFO_gAMA 0x0001
  896. #define PNG_INFO_sBIT 0x0002
  897. #define PNG_INFO_cHRM 0x0004
  898. #define PNG_INFO_PLTE 0x0008
  899. #define PNG_INFO_tRNS 0x0010
  900. #define PNG_INFO_bKGD 0x0020
  901. #define PNG_INFO_hIST 0x0040
  902. #define PNG_INFO_pHYs 0x0080
  903. #define PNG_INFO_oFFs 0x0100
  904. #define PNG_INFO_tIME 0x0200
  905. #define PNG_INFO_pCAL 0x0400
  906. #define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */
  907. #define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */
  908. #define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */
  909. #define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */
  910. #define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */
  911. /* This is used for the transformation routines, as some of them
  912. * change these values for the row. It also should enable using
  913. * the routines for other purposes.
  914. */
  915. typedef struct png_row_info_struct
  916. {
  917. png_uint_32 width; /* width of row */
  918. png_uint_32 rowbytes; /* number of bytes in row */
  919. png_byte color_type; /* color type of row */
  920. png_byte bit_depth; /* bit depth of row */
  921. png_byte channels; /* number of channels (1, 2, 3, or 4) */
  922. png_byte pixel_depth; /* bits per pixel (depth * channels) */
  923. } png_row_info;
  924. typedef png_row_info FAR * png_row_infop;
  925. typedef png_row_info FAR * FAR * png_row_infopp;
  926. /* These are the function types for the I/O functions and for the functions
  927. * that allow the user to override the default I/O functions with his or her
  928. * own. The png_error_ptr type should match that of user-supplied warning
  929. * and error functions, while the png_rw_ptr type should match that of the
  930. * user read/write data functions.
  931. */
  932. typedef struct png_struct_def png_struct;
  933. typedef png_struct FAR * png_structp;
  934. typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp));
  935. typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t));
  936. typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp));
  937. typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32,
  938. int));
  939. typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32,
  940. int));
  941. #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
  942. typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop));
  943. typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop));
  944. typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
  945. png_uint_32, int));
  946. #endif
  947. #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
  948. defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
  949. defined(PNG_LEGACY_SUPPORTED)
  950. typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp,
  951. png_row_infop, png_bytep));
  952. #endif
  953. #if defined(PNG_USER_CHUNKS_SUPPORTED)
  954. typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp));
  955. #endif
  956. #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
  957. typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp));
  958. #endif
  959. /* Transform masks for the high-level interface */
  960. #define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */
  961. #define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */
  962. #define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */
  963. #define PNG_TRANSFORM_PACKING 0x0004 /* read and write */
  964. #define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */
  965. #define PNG_TRANSFORM_EXPAND 0x0010 /* read only */
  966. #define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */
  967. #define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */
  968. #define PNG_TRANSFORM_BGR 0x0080 /* read and write */
  969. #define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */
  970. #define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */
  971. #define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */
  972. #define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */
  973. /* Flags for MNG supported features */
  974. #define PNG_FLAG_MNG_EMPTY_PLTE 0x01
  975. #define PNG_FLAG_MNG_FILTER_64 0x04
  976. #define PNG_ALL_MNG_FEATURES 0x05
  977. typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t));
  978. typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp));
  979. /* The structure that holds the information to read and write PNG files.
  980. * The only people who need to care about what is inside of this are the
  981. * people who will be modifying the library for their own special needs.
  982. * It should NOT be accessed directly by an application, except to store
  983. * the jmp_buf.
  984. */
  985. struct png_struct_def
  986. {
  987. #ifdef PNG_SETJMP_SUPPORTED
  988. jmp_buf jmpbuf; /* used in png_error */
  989. #endif
  990. png_error_ptr error_fn; /* function for printing errors and aborting */
  991. png_error_ptr warning_fn; /* function for printing warnings */
  992. png_voidp error_ptr; /* user supplied struct for error functions */
  993. png_rw_ptr write_data_fn; /* function for writing output data */
  994. png_rw_ptr read_data_fn; /* function for reading input data */
  995. png_voidp io_ptr; /* ptr to application struct for I/O functions */
  996. #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
  997. png_user_transform_ptr read_user_transform_fn; /* user read transform */
  998. #endif
  999. #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
  1000. png_user_transform_ptr write_user_transform_fn; /* user write transform */
  1001. #endif
  1002. /* These were added in libpng-1.0.2 */
  1003. #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
  1004. #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
  1005. defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
  1006. png_voidp user_transform_ptr; /* user supplied struct for user transform */
  1007. png_byte user_transform_depth; /* bit depth of user transformed pixels */
  1008. png_byte user_transform_channels; /* channels in user transformed pixels */
  1009. #endif
  1010. #endif
  1011. png_uint_32 mode; /* tells us where we are in the PNG file */
  1012. png_uint_32 flags; /* flags indicating various things to libpng */
  1013. png_uint_32 transformations; /* which transformations to perform */
  1014. z_stream zstream; /* pointer to decompression structure (below) */
  1015. png_bytep zbuf; /* buffer for zlib */
  1016. png_size_t zbuf_size; /* size of zbuf */
  1017. int zlib_level; /* holds zlib compression level */
  1018. int zlib_method; /* holds zlib compression method */
  1019. int zlib_window_bits; /* holds zlib compression window bits */
  1020. int zlib_mem_level; /* holds zlib compression memory level */
  1021. int zlib_strategy; /* holds zlib compression strategy */
  1022. png_uint_32 width; /* width of image in pixels */
  1023. png_uint_32 height; /* height of image in pixels */
  1024. png_uint_32 num_rows; /* number of rows in current pass */
  1025. png_uint_32 usr_width; /* width of row at start of write */
  1026. png_uint_32 rowbytes; /* size of row in bytes */
  1027. png_uint_32 irowbytes; /* size of current interlaced row in bytes */
  1028. png_uint_32 iwidth; /* width of current interlaced row in pixels */
  1029. png_uint_32 row_number; /* current row in interlace pass */
  1030. png_bytep prev_row; /* buffer to save previous (unfiltered) row */
  1031. png_bytep row_buf; /* buffer to save current (unfiltered) row */
  1032. png_bytep sub_row; /* buffer to save "sub" row when filtering */
  1033. png_bytep up_row; /* buffer to save "up" row when filtering */
  1034. png_bytep avg_row; /* buffer to save "avg" row when filtering */
  1035. png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
  1036. png_row_info row_info; /* used for transformation routines */
  1037. png_uint_32 idat_size; /* current IDAT size for read */
  1038. png_uint_32 crc; /* current chunk CRC value */
  1039. png_colorp palette; /* palette from the input file */
  1040. png_uint_16 num_palette; /* number of color entries in palette */
  1041. png_uint_16 num_trans; /* number of transparency values */
  1042. png_byte chunk_name[5]; /* null-terminated name of current chunk */
  1043. png_byte compression; /* file compression type (always 0) */
  1044. png_byte filter; /* file filter type (always 0) */
  1045. png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
  1046. png_byte pass; /* current interlace pass (0 - 6) */
  1047. png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */
  1048. png_byte color_type; /* color type of file */
  1049. png_byte bit_depth; /* bit depth of file */
  1050. png_byte usr_bit_depth; /* bit depth of users row */
  1051. png_byte pixel_depth; /* number of bits per pixel */
  1052. png_byte channels; /* number of channels in file */
  1053. png_byte usr_channels; /* channels at start of write */
  1054. png_byte sig_bytes; /* magic bytes read/written from start of file */
  1055. #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
  1056. #ifdef PNG_LEGACY_SUPPORTED
  1057. png_byte filler; /* filler byte for pixel expansion */
  1058. #else
  1059. png_uint_16 filler; /* filler bytes for pixel expansion */
  1060. #endif
  1061. #endif
  1062. #if defined(PNG_bKGD_SUPPORTED)
  1063. png_byte background_gamma_type;
  1064. # ifdef PNG_FLOATING_POINT_SUPPORTED
  1065. float background_gamma;
  1066. # endif
  1067. png_color_16 background; /* background color in screen gamma space */
  1068. #if defined(PNG_READ_GAMMA_SUPPORTED)
  1069. png_color_16 background_1; /* background normalized to gamma 1.0 */
  1070. #endif
  1071. #endif /* PNG_bKGD_SUPPORTED */
  1072. #if defined(PNG_WRITE_FLUSH_SUPPORTED)
  1073. png_flush_ptr output_flush_fn;/* Function for flushing output */
  1074. png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */
  1075. png_uint_32 flush_rows; /* number of rows written since last flush */
  1076. #endif
  1077. #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
  1078. int gamma_shift; /* number of "insignificant" bits 16-bit gamma */
  1079. #ifdef PNG_FLOATING_POINT_SUPPORTED
  1080. float gamma; /* file gamma value */
  1081. float screen_gamma; /* screen gamma value (display_exponent) */
  1082. #endif
  1083. #endif
  1084. #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
  1085. png_bytep gamma_table; /* gamma table for 8-bit depth files */
  1086. png_bytep gamma_from_1; /* converts from 1.0 to screen */
  1087. png_bytep gamma_to_1; /* converts from file to 1.0 */
  1088. png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
  1089. png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
  1090. png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
  1091. #endif
  1092. #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)
  1093. png_color_8 sig_bit; /* significant bits in each available channel */
  1094. #endif
  1095. #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
  1096. png_color_8 shift; /* shift for significant bit tranformation */
  1097. #endif
  1098. #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
  1099. || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
  1100. png_bytep trans; /* transparency values for paletted files */
  1101. png_color_16 trans_values; /* transparency values for non-paletted files */
  1102. #endif
  1103. png_read_status_ptr read_row_fn; /* called after each row is decoded */
  1104. png_write_status_ptr write_row_fn; /* called after each row is encoded */
  1105. #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
  1106. png_progressive_info_ptr info_fn; /* called after header data fully read */
  1107. png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */
  1108. png_progressive_end_ptr end_fn; /* called after image is complete */
  1109. png_bytep save_buffer_ptr; /* current location in save_buffer */
  1110. png_bytep save_buffer; /* buffer for previously read data */
  1111. png_bytep current_buffer_ptr; /* current location in current_buffer */
  1112. png_bytep current_buffer; /* buffer for recently used data */
  1113. png_uint_32 push_length; /* size of current input chunk */
  1114. png_uint_32 skip_length; /* bytes to skip in input data */
  1115. png_size_t save_buffer_size; /* amount of data now in save_buffer */
  1116. png_size_t save_buffer_max; /* total size of save_buffer */
  1117. png_size_t buffer_size; /* total amount of available input data */
  1118. png_size_t current_buffer_size; /* amount of data now in current_buffer */
  1119. int process_mode; /* what push library is currently doing */
  1120. int cur_palette; /* current push library palette index */
  1121. # if defined(PNG_TEXT_SUPPORTED)
  1122. png_size_t current_text_size; /* current size of text input data */
  1123. png_size_t current_text_left; /* how much text left to read in input */
  1124. png_charp current_text; /* current text chunk buffer */
  1125. png_charp current_text_ptr; /* current location in current_text */
  1126. # endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */
  1127. #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
  1128. #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
  1129. /* for the Borland special 64K segment handler */
  1130. png_bytepp offset_table_ptr;
  1131. png_bytep offset_table;
  1132. png_uint_16 offset_table_number;
  1133. png_uint_16 offset_table_count;
  1134. png_uint_16 offset_table_count_free;
  1135. #endif
  1136. #if defined(PNG_READ_DITHER_SUPPORTED)
  1137. png_bytep palette_lookup; /* lookup table for dithering */
  1138. png_bytep dither_index; /* index translation for palette files */
  1139. #endif
  1140. #if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED)
  1141. png_uint_16p hist; /* histogram */
  1142. #endif
  1143. #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
  1144. png_byte heuristic_method; /* heuristic for row filter selection */
  1145. png_byte num_prev_filters; /* number of weights for previous rows */
  1146. png_bytep prev_filters; /* filter type(s) of previous row(s) */
  1147. png_uint_16p filter_weights; /* weight(s) for previous line(s) */
  1148. png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */
  1149. png_uint_16p filter_costs; /* relative filter calculation cost */
  1150. png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
  1151. #endif
  1152. #if defined(PNG_TIME_RFC1123_SUPPORTED)
  1153. png_charp time_buffer; /* String to hold RFC 1123 time text */
  1154. #endif
  1155. /* New members added in libpng-1.0.6 */
  1156. #ifdef PNG_FREE_ME_SUPPORTED
  1157. png_uint_32 free_me; /* flags items libpng is responsible for freeing */
  1158. #endif
  1159. #if defined(PNG_USER_CHUNKS_SUPPORTED)
  1160. png_voidp user_chunk_ptr;
  1161. png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
  1162. #endif
  1163. #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
  1164. int num_chunk_list;
  1165. png_bytep chunk_list;
  1166. #endif
  1167. /* New members added in libpng-1.0.3 */
  1168. #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
  1169. png_byte rgb_to_gray_status;
  1170. /* These were changed from png_byte in libpng-1.0.6 */
  1171. png_uint_16 rgb_to_gray_red_coeff;
  1172. png_uint_16 rgb_to_gray_green_coeff;
  1173. png_uint_16 rgb_to_gray_blue_coeff;
  1174. #endif
  1175. /* New member added in libpng-1.0.4 (renamed in 1.0.9) */
  1176. #if defined(PNG_MNG_FEATURES_SUPPORTED) || \
  1177. defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
  1178. defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
  1179. /* changed from png_byte to png_uint_32 at version 1.2.0 */
  1180. #ifdef PNG_1_0_X
  1181. png_byte mng_features_permitted;
  1182. #else
  1183. png_uint_32 mng_features_permitted;
  1184. #endif /* PNG_1_0_X */
  1185. #endif
  1186. /* New member added in libpng-1.0.7 */
  1187. #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
  1188. png_fixed_point int_gamma;
  1189. #endif
  1190. /* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */
  1191. #if defined(PNG_MNG_FEATURES_SUPPORTED)
  1192. png_byte filter_type;
  1193. #endif
  1194. #if defined(PNG_1_0_X) || (defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD))
  1195. /* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */
  1196. png_uint_32 row_buf_size;
  1197. #endif
  1198. /* New members added in libpng-1.2.0 */
  1199. #if !defined(PNG_1_0_X) && defined(PNG_ASSEMBLER_CODE_SUPPORTED)
  1200. png_byte mmx_bitdepth_threshold;
  1201. png_uint_32 mmx_rowbytes_threshold;
  1202. png_uint_32 asm_flags;
  1203. #endif
  1204. /* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
  1205. #ifdef PNG_USER_MEM_SUPPORTED
  1206. png_voidp mem_ptr; /* user supplied struct for mem functions */
  1207. png_malloc_ptr malloc_fn; /* function for allocating memory */
  1208. png_free_ptr free_fn; /* function for freeing memory */
  1209. #endif
  1210. /* New member added in libpng-1.0.13 and 1.2.0 */
  1211. png_bytep big_row_buf; /* buffer to save current (unfiltered) row */
  1212. #if defined(PNG_READ_DITHER_SUPPORTED)
  1213. /* The following three members were added at version 1.0.14 and 1.2.4 */
  1214. png_bytep dither_sort; /* working sort array */
  1215. png_bytep index_to_palette; /* where the original index currently is */
  1216. /* in the palette */
  1217. png_bytep palette_to_index; /* which original index points to this */
  1218. /* palette color */
  1219. #endif
  1220. /* New members added in libpng-1.0.16 and 1.2.6 */
  1221. png_byte compression_type;
  1222. #ifdef PNG_SET_USER_LIMITS_SUPPORTED
  1223. png_uint_32 user_width_max;
  1224. png_uint_32 user_height_max;
  1225. #endif
  1226. };
  1227. /* This triggers a compiler error in png.c, if png.c and png.h
  1228. * do not agree upon the version number.
  1229. */
  1230. typedef png_structp version_1_2_8;
  1231. typedef png_struct FAR * FAR * png_structpp;
  1232. /* Here are the function definitions most commonly used. This is not
  1233. * the place to find out how to use libpng. See libpng.txt for the
  1234. * full explanation, see example.c for the summary. This just provides
  1235. * a simple one line description of the use of each function.
  1236. */
  1237. /* Returns the version number of the library */
  1238. extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void));
  1239. /* Tell lib we have already handled the first <num_bytes> magic bytes.
  1240. * Handling more than 8 bytes from the beginning of the file is an error.
  1241. */
  1242. extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr,
  1243. int num_bytes));
  1244. /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a
  1245. * PNG file. Returns zero if the supplied bytes match the 8-byte PNG
  1246. * signature, and non-zero otherwise. Having num_to_check == 0 or
  1247. * start > 7 will always fail (ie return non-zero).
  1248. */
  1249. extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start,
  1250. png_size_t num_to_check));
  1251. /* Simple signature checking function. This is the same as calling
  1252. * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
  1253. */
  1254. extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num));
  1255. /* Allocate and initialize png_ptr struct for reading, and any other memory. */
  1256. extern PNG_EXPORT(png_structp,png_create_read_struct)
  1257. PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
  1258. png_error_ptr error_fn, png_error_ptr warn_fn));
  1259. /* Allocate and initialize png_ptr struct for writing, and any other memory */
  1260. extern PNG_EXPORT(png_structp,png_create_write_struct)
  1261. PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
  1262. png_error_ptr error_fn, png_error_ptr warn_fn));
  1263. #ifdef PNG_WRITE_SUPPORTED
  1264. extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size)
  1265. PNGARG((png_structp png_ptr));
  1266. #endif
  1267. #ifdef PNG_WRITE_SUPPORTED
  1268. extern PNG_EXPORT(void,png_set_compression_buffer_size)
  1269. PNGARG((png_structp png_ptr, png_uint_32 size));
  1270. #endif
  1271. /* Reset the compression stream */
  1272. extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr));
  1273. /* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */
  1274. #ifdef PNG_USER_MEM_SUPPORTED
  1275. extern PNG_EXPORT(png_structp,png_create_read_struct_2)
  1276. PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
  1277. png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
  1278. png_malloc_ptr malloc_fn, png_free_ptr free_fn));
  1279. extern PNG_EXPORT(png_structp,png_create_write_struct_2)
  1280. PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
  1281. png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
  1282. png_malloc_ptr malloc_fn, png_free_ptr free_fn));
  1283. #endif
  1284. /* Write a PNG chunk - size, type, (optional) data, CRC. */
  1285. extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr,
  1286. png_bytep chunk_name, png_bytep data, png_size_t length));
  1287. /* Write the start of a PNG chunk - length and chunk name. */
  1288. extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr,
  1289. png_bytep chunk_name, png_uint_32 length));
  1290. /* Write the data of a PNG chunk started with png_write_chunk_start(). */
  1291. extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr,
  1292. png_bytep data, png_size_t length));
  1293. /* Finish a chunk started with png_write_chunk_start() (includes CRC). */
  1294. extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr));
  1295. /* Allocate and initialize the info structure */
  1296. extern PNG_EXPORT(png_infop,png_create_info_struct)
  1297. PNGARG((png_structp png_ptr));
  1298. /* Initialize the info structure (old interface - DEPRECATED) */
  1299. extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr));
  1300. #undef png_info_init
  1301. #define png_info_init(info_ptr) png_info_init_3(&info_ptr,\
  1302. png_sizeof(png_info));
  1303. extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr,
  1304. png_size_t png_info_struct_size));
  1305. /* Writes all the PNG information before the image. */
  1306. extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr,
  1307. png_infop info_ptr));
  1308. extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr,
  1309. png_infop info_ptr));
  1310. #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
  1311. /* read the information before the actual image data. */
  1312. extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr,
  1313. png_infop info_ptr));
  1314. #endif
  1315. #if defined(PNG_TIME_RFC1123_SUPPORTED)
  1316. extern PNG_EXPORT(png_charp,png_convert_to_rfc1123)
  1317. PNGARG((png_structp png_ptr, png_timep ptime));
  1318. #endif
  1319. #if !defined(_WIN32_WCE)
  1320. /* "time.h" functions are not supported on WindowsCE */
  1321. #if defined(PNG_WRITE_tIME_SUPPORTED)
  1322. /* convert from a struct tm to png_time */
  1323. extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime,
  1324. struct tm FAR * ttime));
  1325. /* convert from time_t to png_time. Uses gmtime() */
  1326. extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime,
  1327. time_t ttime));
  1328. #endif /* PNG_WRITE_tIME_SUPPORTED */
  1329. #endif /* _WIN32_WCE */
  1330. #if defined(PNG_READ_EXPAND_SUPPORTED)
  1331. /* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
  1332. extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr));
  1333. extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr));
  1334. extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr));
  1335. extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr));
  1336. #endif
  1337. #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
  1338. /* Use blue, green, red order for pixels. */
  1339. extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr));
  1340. #endif
  1341. #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
  1342. /* Expand the grayscale to 24-bit RGB if necessary. */
  1343. extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_p