Subversion Repositories Kolibri OS

Rev

Rev 6779 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. ; png.inc - header file for PNG reference library
  3.  
  4. ; libpng version 1.6.25, September 1, 2016
  5.  
  6. ; Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
  7. ; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  8. ; (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  9.  
  10. ; This code is released under the libpng license (See LICENSE, below)
  11.  
  12. ; Authors and maintainers:
  13. ;   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
  14. ;   libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
  15. ;   libpng versions 0.97, January 1998, through 1.6.25, September 1, 2016:
  16. ;     Glenn Randers-Pehrson.
  17. ;   See also "Contributing Authors", below.
  18.  
  19.  
  20.  
  21. ; COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
  22.  
  23. ; If you modify libpng you may insert additional notices immediately following
  24. ; this sentence.
  25.  
  26. ; This code is released under the libpng license.
  27.  
  28. ; Some files in the "contrib" directory and some configure-generated
  29. ; files that are distributed with libpng have other copyright owners and
  30. ; are released under other open source licenses.
  31.  
  32. ; libpng versions 1.0.7, July 1, 2000 through 1.6.25, September 1, 2016 are
  33. ; Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
  34. ; derived from libpng-1.0.6, and are distributed according to the same
  35. ; disclaimer and license as libpng-1.0.6 with the following individuals
  36. ; added to the list of Contributing Authors:
  37.  
  38. ;    Simon-Pierre Cadieux
  39. ;    Eric S. Raymond
  40. ;    Mans Rullgard
  41. ;    Cosmin Truta
  42. ;    Gilles Vollant
  43. ;    James Yu
  44. ;    Mandar Sahastrabuddhe
  45.  
  46. ; and with the following additions to the disclaimer:
  47.  
  48. ;    There is no warranty against interference with your enjoyment of the
  49. ;    library or against infringement.  There is no warranty that our
  50. ;    efforts or the library will fulfill any of your particular purposes
  51. ;    or needs.  This library is provided with all faults, and the entire
  52. ;    risk of satisfactory quality, performance, accuracy, and effort is with
  53. ;    the user.
  54.  
  55. ; Some files in the "contrib" directory have other copyright owners and
  56. ; are released under other open source licenses.
  57.  
  58.  
  59. ; libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
  60. ; Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
  61. ; libpng-0.96, and are distributed according to the same disclaimer and
  62. ; license as libpng-0.96, with the following individuals added to the list
  63. ; of Contributing Authors:
  64.  
  65. ;    Tom Lane
  66. ;    Glenn Randers-Pehrson
  67. ;    Willem van Schaik
  68.  
  69. ; Some files in the "scripts" directory have different copyright owners
  70. ; but are also released under this license.
  71.  
  72. ; libpng versions 0.89, June 1996, through 0.96, May 1997, are
  73. ; Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
  74. ; and are distributed according to the same disclaimer and license as
  75. ; libpng-0.88, with the following individuals added to the list of
  76. ; Contributing Authors:
  77.  
  78. ;    John Bowler
  79. ;    Kevin Bracey
  80. ;    Sam Bushell
  81. ;    Magnus Holmgren
  82. ;    Greg Roelofs
  83. ;    Tom Tanner
  84.  
  85. ; Some files in the "scripts" directory have other copyright owners
  86. ; but are released under this license.
  87.  
  88. ; libpng versions 0.5, May 1995, through 0.88, January 1996, are
  89. ; Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  90.  
  91. ; For the purposes of this copyright and license, "Contributing Authors"
  92. ; is defined as the following set of individuals:
  93.  
  94. ;    Andreas Dilger
  95. ;    Dave Martindale
  96. ;    Guy Eric Schalnat
  97. ;    Paul Schmidt
  98. ;    Tim Wegner
  99.  
  100. ; The PNG Reference Library is supplied "AS IS".  The Contributing Authors
  101. ; and Group 42, Inc. disclaim all warranties, expressed or implied,
  102. ; including, without limitation, the warranties of merchantability and of
  103. ; fitness for any purpose.  The Contributing Authors and Group 42, Inc.
  104. ; assume no liability for direct, indirect, incidental, special, exemplary,
  105. ; or consequential damages, which may result from the use of the PNG
  106. ; Reference Library, even if advised of the possibility of such damage.
  107.  
  108. ; Permission is hereby granted to use, copy, modify, and distribute this
  109. ; source code, or portions hereof, for any purpose, without fee, subject
  110. ; to the following restrictions:
  111.  
  112. ;   1. The origin of this source code must not be misrepresented.
  113.  
  114. ;   2. Altered versions must be plainly marked as such and must not
  115. ;      be misrepresented as being the original source.
  116.  
  117. ;   3. This Copyright notice may not be removed or altered from any
  118. ;      source or altered source distribution.
  119.  
  120. ; The Contributing Authors and Group 42, Inc. specifically permit, without
  121. ; fee, and encourage the use of this source code as a component to
  122. ; supporting the PNG file format in commercial products.  If you use this
  123. ; source code in a product, acknowledgment is not required but would be
  124. ; appreciated.
  125.  
  126. ; END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
  127.  
  128. ; TRADEMARK:
  129.  
  130. ; The name "libpng" has not been registered by the Copyright owner
  131. ; as a trademark in any jurisdiction.  However, because libpng has
  132. ; been distributed and maintained world-wide, continually since 1995,
  133. ; the Copyright owner claims "common-law trademark protection" in any
  134. ; jurisdiction where common-law trademark is recognized.
  135.  
  136. ; OSI CERTIFICATION:
  137.  
  138. ; Libpng is OSI Certified Open Source Software.  OSI Certified Open Source is
  139. ; a certification mark of the Open Source Initiative. OSI has not addressed
  140. ; the additional disclaimers inserted at version 1.0.7.
  141.  
  142. ; EXPORT CONTROL:
  143.  
  144. ; The Copyright owner believes that the Export Control Classification
  145. ; Number (ECCN) for libpng is EAR99, which means not subject to export
  146. ; controls or International Traffic in Arms Regulations (ITAR) because
  147. ; it is open source, publicly available software, that does not contain
  148. ; any encryption software.  See the EAR, paragraphs 734.3(b)(3) and
  149. ; 734.7(b).
  150.  
  151.  
  152.  
  153. ; A "png_get_copyright" function is available, for convenient use in "about"
  154. ; boxes and the like:
  155.  
  156. ;    printf("%s", png_get_copyright(NULL));
  157.  
  158. ; Also, the PNG logo (in PNG format, of course) is supplied in the
  159. ; files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
  160.  
  161.  
  162.  
  163. ; The contributing authors would like to thank all those who helped
  164. ; with testing, bug fixes, and patience.  This wouldn't have been
  165. ; possible without all of you.
  166.  
  167. ; Thanks to Frank J. T. Wojcik for helping with the documentation.
  168.  
  169. ;
  170. ; Note about libpng version numbers:
  171. ;
  172. ;    Due to various miscommunications, unforeseen code incompatibilities
  173. ;    and occasional factors outside the authors' control, version numbering
  174. ;    on the library has not always been consistent and straightforward.
  175. ;    The following table summarizes matters since version 0.89c, which was
  176. ;    the first widely used release:
  177. ;
  178. ;    source                 png.h  png.h  shared-lib
  179. ;    version                string   int  version
  180. ;    -------                ------ -----  ----------
  181. ;    ...
  182. ;    1.2.56                  13    10256  12.so.0.56[.0]
  183. ;    ...
  184. ;    1.5.27                  15    10527  15.so.15.27[.0]
  185. ;    ...
  186. ;    1.6.25                  16    10625  16.so.16.25[.0]
  187.  
  188. ;    Henceforth the source version will match the shared-library major
  189. ;    and minor numbers; the shared-library major version number will be
  190. ;    used for changes in backward compatibility, as it is intended.  The
  191. ;    PNG_LIBPNG_VER macro, which is not used within libpng but is available
  192. ;    for applications, is an unsigned integer of the form xyyzz corresponding
  193. ;    to the source version x.y.z (leading zeros in y and z).  Beta versions
  194. ;    were given the previous public release number plus a letter, until
  195. ;    version 1.0.6j; from then on they were given the upcoming public
  196. ;    release number plus "betaNN" or "rcNN".
  197.  
  198. ;    Binary incompatibility exists only when applications make direct access
  199. ;    to the info_ptr or png_ptr members through png.h, and the compiled
  200. ;    application is loaded with a different version of the library.
  201.  
  202. ;    DLLNUM will change each time there are forward or backward changes
  203. ;    in binary compatibility (e.g., when a new feature is added).
  204.  
  205. ; See libpng.txt or libpng.3 for more information.  The PNG specification
  206. ; is available as a W3C Recommendation and as an ISO Specification,
  207. ; <http://www.w3.org/TR/2003/REC-PNG-20031110/
  208.  
  209.  
  210.  
  211. ; Y2K compliance in libpng:
  212. ; =========================
  213.  
  214. ;    September 1, 2016
  215.  
  216. ;    Since the PNG Development group is an ad-hoc body, we can't make
  217. ;    an official declaration.
  218.  
  219. ;    This is your unofficial assurance that libpng from version 0.71 and
  220. ;    upward through 1.6.25 are Y2K compliant.  It is my belief that
  221. ;    earlier versions were also Y2K compliant.
  222.  
  223. ;    Libpng only has two year fields.  One is a 2-byte unsigned integer
  224. ;    that will hold years up to 65535.  The other, which is deprecated,
  225. ;    holds the date in text format, and will hold years up to 9999.
  226.  
  227. ;    The integer is
  228. ;        "uint_16 year" in png_time_struct.
  229.  
  230. ;    The string is
  231. ;        "char time_buffer[29]" in png_struct.  This is no longer used
  232. ;    in libpng-1.6.x and will be removed from libpng-1.7.0.
  233.  
  234. ;    There are seven time-related functions:
  235. ;        png.asm: png_convert_to_rfc_1123_buffer() in png.asm
  236. ;          (formerly png_convert_to_rfc_1123() prior to libpng-1.5.x and
  237. ;          png_convert_to_rfc_1152() in error prior to libpng-0.98)
  238. ;        png_convert_from_struct_tm() in pngwrite.asm, called in pngwrite.asm
  239. ;        png_convert_from_time_t() in pngwrite.asm
  240. ;        png_get_tIME() in pngget.asm
  241. ;        png_handle_tIME() in pngrutil.asm, called in pngread.asm
  242. ;        png_set_tIME() in pngset.asm
  243. ;        png_write_tIME() in pngwutil.asm, called in pngwrite.asm
  244.  
  245. ;    All handle dates properly in a Y2K environment.  The
  246. ;    png_convert_from_time_t() function calls gmtime() to convert from system
  247. ;    clock time, which returns (year - 1900), which we properly convert to
  248. ;    the full 4-digit year.  There is a possibility that libpng applications
  249. ;    are not passing 4-digit years into the png_convert_to_rfc_1123_buffer()
  250. ;    function, or that they are incorrectly passing only a 2-digit year
  251. ;    instead of "year - 1900" into the png_convert_from_struct_tm() function,
  252. ;    but this is not under our control.  The libpng documentation has always
  253. ;    stated that it works with 4-digit years, and the APIs have been
  254. ;    documented as such.
  255.  
  256. ;    The tIME chunk itself is also Y2K compliant.  It uses a 2-byte unsigned
  257. ;    integer to hold the year, and can hold years as large as 65535.
  258.  
  259. ;    zlib, upon which libpng depends, is also Y2K compliant.  It contains
  260. ;    no date-related code.
  261.  
  262. ;       Glenn Randers-Pehrson
  263. ;       libpng maintainer
  264. ;       PNG Development Group
  265.  
  266.  
  267. ; This is not the place to learn how to use libpng. The file libpng-manual.txt
  268. ; describes how to use libpng, and the file example.c summarizes it
  269. ; with some code on which to build.  This file is useful for looking
  270. ; at the actual function definitions and structure components.  If that
  271. ; file has been stripped from your copy of libpng, you can find it at
  272. ; <http://www.libpng.org/pub/png/libpng-manual.txt>
  273.  
  274. ; If you just need to read a PNG file and don't want to read the documentation
  275. ; skip to the end of this file and read the section entitled 'simplified API'.
  276.  
  277.  
  278. ; Version information for png.h - this should match the version in png.asm
  279. PNG_LIBPNG_VER_STRING db '1.6.25',0
  280. PNG_HEADER_VERSION_STRING db ' libpng version 1.6.25 - September 1, 2016',13,10,0
  281.  
  282. PNG_LIBPNG_VER_SONUM  equ 16
  283. PNG_LIBPNG_VER_DLLNUM equ 16
  284.  
  285. ; These should match the first 3 components of PNG_LIBPNG_VER_STRING:
  286. PNG_LIBPNG_VER_MAJOR  equ 1
  287. PNG_LIBPNG_VER_MINOR  equ 6
  288. PNG_LIBPNG_VER_RELEASE equ 25
  289.  
  290. ; This should match the numeric part of the final component of
  291. ; PNG_LIBPNG_VER_STRING, omitting any leading zero:
  292.  
  293.  
  294. PNG_LIBPNG_VER_BUILD equ 0
  295.  
  296. ; Release Status
  297. PNG_LIBPNG_BUILD_ALPHA   equ 1
  298. PNG_LIBPNG_BUILD_BETA    equ 2
  299. PNG_LIBPNG_BUILD_RC      equ 3
  300. PNG_LIBPNG_BUILD_STABLE  equ 4
  301. PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK equ 7
  302.  
  303. ; Release-Specific Flags
  304. PNG_LIBPNG_BUILD_PATCH   equ  8 ;Can be OR'ed with PNG_LIBPNG_BUILD_STABLE only
  305. PNG_LIBPNG_BUILD_PRIVATE equ 16 ;Cannot be OR'ed with PNG_LIBPNG_BUILD_SPECIAL
  306. PNG_LIBPNG_BUILD_SPECIAL equ 32 ;Cannot be OR'ed with PNG_LIBPNG_BUILD_PRIVATE
  307.  
  308. PNG_LIBPNG_BUILD_BASE_TYPE equ PNG_LIBPNG_BUILD_STABLE
  309.  
  310. ; Careful here.  At one time, Guy wanted to use 082, but that would be octal.
  311. ; We must not include leading zeros.
  312. ; Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
  313. ; version 1.0.0 was mis-numbered 100 instead of 10000).  From
  314. ; version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release
  315.  
  316. PNG_LIBPNG_VER equ 10625 ;1.6.25
  317.  
  318. ; Library configuration: these options cannot be changed after
  319. ; the library has been built.
  320.  
  321.  
  322. ; Added at libpng-1.2.8
  323.  
  324. ; Ref MSDN: Private as priority over Special
  325. ; VS_FF_PRIVATEBUILD File *was not* built using standard release
  326. ; procedures. If this value is given, the StringFileInfo block must
  327. ; contain a PrivateBuild string.
  328.  
  329. ; VS_FF_SPECIALBUILD File *was* built by the original company using
  330. ; standard release procedures but is a variation of the standard
  331. ; file of the same version number. If this value is given, the
  332. ; StringFileInfo block must contain a SpecialBuild string.
  333.  
  334. ;if PNG_USER_PRIVATEBUILD /* From pnglibconf.h */
  335. ;#  define PNG_LIBPNG_BUILD_TYPE \
  336. ;       (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE)
  337. ;#else
  338. ;#  ifdef PNG_LIBPNG_SPECIALBUILD
  339. ;#    define PNG_LIBPNG_BUILD_TYPE \
  340. ;         (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL)
  341. ;#  else
  342. ;#    define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE)
  343. ;#  endif
  344. ;end if
  345.  
  346. ;#ifndef PNG_VERSION_INFO_ONLY
  347.  
  348. ; Version information for C files, stored in png.asm.  This had better match
  349. ; the version above.
  350.  
  351. ;#define png_libpng_ver png_get_header_ver(NULL)
  352.  
  353. ; This file is arranged in several sections:
  354.  
  355. ; 1. [omitted]
  356. ; 2. Any configuration options that can be specified by for the application
  357. ;    code when it is built.  (Build time configuration is in pnglibconf.h)
  358. ; 3. Type definitions (base types are defined in pngconf.h), structure
  359. ;    definitions.
  360. ; 4. Exported library functions.
  361. ; 5. Simplified API.
  362. ; 6. Implementation options.
  363.  
  364. ; The library source code has additional files (principally pngpriv.h) that
  365. ; allow configuration of the library.
  366.  
  367.  
  368. ; Section 1: [omitted]
  369.  
  370. ; Section 2: run time configuration
  371. ; See pnglibconf.h for build time configuration
  372.  
  373. ; Run time configuration allows the application to choose between
  374. ; implementations of certain arithmetic APIs.  The default is set
  375. ; at build time and recorded in pnglibconf.h, but it is safe to
  376. ; override these (and only these) settings.  Note that this won't
  377. ; change what the library does, only application code, and the
  378. ; settings can (and probably should) be made on a per-file basis
  379. ; by setting the #defines before including png.h
  380.  
  381. ; Use macros to read integers from PNG data or use the exported
  382. ; functions?
  383. ;   PNG_USE_READ_MACROS: use the macros (see below)  Note that
  384. ;     the macros evaluate their argument multiple times.
  385. ;   PNG_NO_USE_READ_MACROS: call the relevant library function.
  386.  
  387. ; Use the alternative algorithm for compositing alpha samples that
  388. ; does not use division?
  389. ;   PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division'
  390. ;      algorithm.
  391. ;   PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm.
  392.  
  393. ; How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is
  394. ; false?
  395. ;   PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error
  396. ;      APIs to png_warning.
  397. ; Otherwise the calls are mapped to png_error.
  398.  
  399.  
  400. ; Section 3: type definitions, including structures and compile time
  401. ; constants.
  402. ; See pngconf.h for base types that vary by machine/system
  403.  
  404.  
  405. ; This triggers a compiler error in png.c, if png.c and png.h
  406. ; do not agree upon the version number.
  407.  
  408. ;typedef char* png_libpng_version_1_6_25;
  409.  
  410. ; Basic control structions.  Read libpng-manual.txt or libpng.3 for more info.
  411.  
  412. ; png_struct is the cache of information used while reading or writing a single
  413. ; PNG file.  One of these is always required, although the simplified API
  414. ; (below) hides the creation and destruction of it.
  415.  
  416. ; png_info contains information read from or to be written to a PNG file.  One
  417. ; or more of these must exist while reading or creating a PNG file.  The
  418. ; information is not used by libpng during read but is used to control what
  419. ; gets written when a PNG file is created.  "png_get_" function calls read
  420. ; information during read and "png_set_" functions calls write information
  421. ; when creating a PNG.
  422. ; been moved into a separate header file that is not accessible to
  423. ; applications.  Read libpng-manual.txt or libpng.3 for more info.
  424.  
  425. ; Types with names ending 'p' are pointer types.  The corresponding types with
  426. ; names ending 'rp' are identical pointer types except that the pointer is
  427. ; marked 'restrict', which means that it is the only pointer to the object
  428. ; passed to the function.  Applications should not use the 'restrict' types;
  429. ; it is always valid to pass 'p' to a pointer with a function argument of the
  430. ; corresponding 'rp' type.  Different compilers have different rules with
  431. ; regard to type matching in the presence of 'restrict'.  For backward
  432. ; compatibility libpng callbacks never have 'restrict' in their parameters and,
  433. ; consequentially, writing portable application code is extremely difficult if
  434. ; an attempt is made to use 'restrict'.
  435.  
  436. ; Three color definitions.  The order of the red, green, and blue, (and the
  437. ; exact size) is not important, although the size of the fields need to
  438. ; be byte or uint_16 (as defined below).
  439.  
  440. struct png_color
  441.         red   db ? ;byte
  442.         green db ? ;byte
  443.         blue  db ? ;byte
  444. ends
  445.  
  446. struct png_color_16
  447.         index db ? ;byte ;used for palette files
  448.         red   dw ? ;uint_16 ;for use in red green blue files
  449.         green dw ? ;uint_16
  450.         blue  dw ? ;uint_16
  451.         gray  dw ? ;uint_16 ;for use in grayscale files
  452. ends
  453.  
  454. struct png_color_8
  455.         red   db ? ;byte ;for use in red green blue files
  456.         green db ? ;byte
  457.         blue  db ? ;byte
  458.         gray  db ? ;byte ;for use in grayscale files
  459.         alpha db ? ;byte ;for alpha channel files
  460. ends
  461.  
  462.  
  463. ; The following two structures are used for the in-core representation
  464. ; of sPLT chunks.
  465.  
  466. struct png_sPLT_entry
  467.         red   dw ? ;uint_16
  468.         green dw ? ;uint_16
  469.         blue  dw ? ;uint_16
  470.         alpha dw ? ;uint_16
  471.         frequency dw ? ;uint_16
  472. ends
  473.  
  474. ; When the depth of the sPLT palette is 8 bits, the color and alpha samples
  475. ; occupy the LSB of their respective members, and the MSB of each member
  476. ; is zero-filled.  The frequency member always occupies the full 16 bits.
  477.  
  478.  
  479. struct png_sPLT_t
  480.         name    dd ? ;charp ;palette name
  481.         depth   db ? ;byte ;depth of palette samples
  482.         entries dd ? ;png_sPLT_entryp ;palette entries
  483.         nentries dd ? ;int_32 ;number of palette entries
  484. ends
  485.  
  486. if PNG_TEXT_SUPPORTED eq 1
  487. ; png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,
  488. ; and whether that contents is compressed or not.  The "key" field
  489. ; points to a regular zero-terminated C string.  The "text" fields can be a
  490. ; regular C string, an empty string, or a NULL pointer.
  491. ; However, the structure returned by png_get_text() will always contain
  492. ; the "text" field as a regular zero-terminated C string (possibly
  493. ; empty), never a NULL pointer, so it can be safely used in printf() and
  494. ; other string-handling functions.  Note that the "itxt_length", "lang", and
  495. ; "lang_key" members of the structure only exist when the library is built
  496. ; with iTXt chunk support.  Prior to libpng-1.4.0 the library was built by
  497. ; default without iTXt support. Also note that when iTXt *is* supported,
  498. ; the "lang" and "lang_key" fields contain NULL pointers when the
  499. ; "compression" field contains * PNG_TEXT_COMPRESSION_NONE or
  500. ; PNG_TEXT_COMPRESSION_zTXt. Note that the "compression value" is not the
  501. ; same as what appears in the PNG tEXt/zTXt/iTXt chunk's "compression flag"
  502. ; which is always 0 or 1, or its "compression method" which is always 0.
  503.  
  504. struct png_text
  505.         compression dd ? ;int ;compression value:
  506.                         ;-1: tEXt, none
  507.                         ; 0: zTXt, deflate
  508.                         ; 1: iTXt, none
  509.                         ; 2: iTXt, deflate
  510.         key  dd ? ;charp ;keyword, 1-79 character description of "text"
  511.         text dd ? ;charp ;comment, may be an empty string (ie "")
  512.                         ; or a NULL pointer
  513.         text_length dd ? ;png_size_t ;length of the text string
  514.         itxt_length dd ? ;png_size_t ;length of the itxt string
  515.         lang dd ? ;charp ;language code, 0-79 characters
  516.                         ; or a NULL pointer
  517.         lang_key dd ? ;charp ;keyword translated UTF-8 string, 0 or more
  518.                         ; chars or a NULL pointer
  519. ends
  520. end if
  521.  
  522. ; Supported compression types for text in PNG files (tEXt, and zTXt).
  523. ; The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed.
  524. PNG_TEXT_COMPRESSION_NONE_WR equ -3
  525. PNG_TEXT_COMPRESSION_zTXt_WR equ -2
  526. PNG_TEXT_COMPRESSION_NONE    equ -1
  527. PNG_TEXT_COMPRESSION_zTXt    equ 0
  528. PNG_ITXT_COMPRESSION_NONE    equ 1
  529. PNG_ITXT_COMPRESSION_zTXt    equ 2
  530. PNG_TEXT_COMPRESSION_LAST    equ 3 ;Not a valid value
  531.  
  532. ; png_time is a way to hold the time in an machine independent way.
  533. ; Two conversions are provided, both from time_t and struct tm.  There
  534. ; is no portable way to convert to either of these structures, as far
  535. ; as I know.  If you know of a portable way, send it to me.  As a side
  536. ; note - PNG has always been Year 2000 compliant!
  537.  
  538. struct png_time
  539.         year  dw ? ;uint_16 ;full year, as in, 1995
  540.         month db ? ;byte ;month of year, 1 - 12
  541.         day   db ? ;byte ;day of month, 1 - 31
  542.         hour  db ? ;byte ;hour of day, 0 - 23
  543.         minute db ? ;byte ;minute of hour, 0 - 59
  544.         second db ? ;byte ;second of minute, 0 - 60 (for leap seconds)
  545. ends
  546.  
  547. if (PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED eq 1) | (PNG_USER_CHUNKS_SUPPORTED eq 1)
  548. ; png_unknown_chunk is a structure to hold queued chunks for which there is
  549. ; no specific support.  The idea is that we can use this to queue
  550. ; up private chunks for output even though the library doesn't actually
  551. ; know about their semantics.
  552.  
  553. ; The data in the structure is set by libpng on read and used on write.
  554.  
  555. struct png_unknown_chunk
  556.         name rb 5 ;byte[5] ;Textual chunk name with '\0' terminator
  557.         podata dd ? ;byte* ;Data, should not be modified on read!
  558.         size dd ? ;png_size_t
  559.  
  560.         ; On write 'location' must be set using the flag values listed below.
  561.         ; Notice that on read it is set by libpng however the values stored have
  562.         ; more bits set than are listed below.  Always treat the value as a
  563.         ; bitmask.  On write set only one bit - setting multiple bits may cause the
  564.         ; chunk to be written in multiple places.
  565.  
  566.         location db ? ;byte ;mode of operation at read time
  567. ends
  568. end if
  569.  
  570. ; Flag values for the unknown chunk location byte.
  571. PNG_HAVE_IHDR equ  0x01
  572. PNG_HAVE_PLTE equ  0x02
  573. PNG_AFTER_IDAT equ 0x08
  574.  
  575. ; Maximum positive integer used in PNG is (2^31)-1
  576. PNG_UINT_31_MAX equ 0x7fffffff ;uint_32
  577. PNG_UINT_32_MAX equ -1 ;uint_32
  578. PNG_SIZE_MAX    equ 0x60000000 ;1.5 Gb
  579.  
  580. ; These are constants for fixed point values encoded in the
  581. ; PNG specification manner (x100000)
  582.  
  583. PNG_FP_1   equ 100000
  584. PNG_FP_HALF equ 50000
  585. PNG_FP_MAX equ ((png_fixed_point)0x7fffffffL)
  586. PNG_FP_MIN equ (-PNG_FP_MAX)
  587.  
  588. ; These describe the color_type field in png_info.
  589. ; color type masks
  590. PNG_COLOR_MASK_PALETTE equ 1
  591. PNG_COLOR_MASK_COLOR   equ 2
  592. PNG_COLOR_MASK_ALPHA   equ 4
  593.  
  594. ; color types.  Note that not all combinations are legal
  595. PNG_COLOR_TYPE_GRAY equ 0
  596. PNG_COLOR_TYPE_PALETTE equ (PNG_COLOR_MASK_COLOR or PNG_COLOR_MASK_PALETTE)
  597. PNG_COLOR_TYPE_RGB      equ (PNG_COLOR_MASK_COLOR)
  598. PNG_COLOR_TYPE_RGB_ALPHA equ (PNG_COLOR_MASK_COLOR or PNG_COLOR_MASK_ALPHA)
  599. PNG_COLOR_TYPE_GRAY_ALPHA equ (PNG_COLOR_MASK_ALPHA)
  600. ; aliases
  601. PNG_COLOR_TYPE_RGBA equ PNG_COLOR_TYPE_RGB_ALPHA
  602. PNG_COLOR_TYPE_GA equ PNG_COLOR_TYPE_GRAY_ALPHA
  603.  
  604. ; This is for compression type. PNG 1.0-1.2 only define the single type.
  605. PNG_COMPRESSION_TYPE_BASE equ 0 ;Deflate method 8, 32K window
  606. PNG_COMPRESSION_TYPE_DEFAULT equ PNG_COMPRESSION_TYPE_BASE
  607.  
  608. ; This is for filter type. PNG 1.0-1.2 only define the single type.
  609. PNG_FILTER_TYPE_BASE     equ 0 ;Single row per-byte filtering
  610. PNG_INTRAPIXEL_DIFFERENCING equ 64 ;Used only in MNG datastreams
  611. PNG_FILTER_TYPE_DEFAULT  equ PNG_FILTER_TYPE_BASE
  612.  
  613. ; These are for the interlacing type.  These values should NOT be changed.
  614. PNG_INTERLACE_NONE       equ 0 ;Non-interlaced image
  615. PNG_INTERLACE_ADAM7      equ 1 ;Adam7 interlacing
  616. PNG_INTERLACE_LAST       equ 2 ;Not a valid value
  617.  
  618. ; These are for the oFFs chunk.  These values should NOT be changed.
  619. PNG_OFFSET_PIXEL         equ 0 ;Offset in pixels
  620. PNG_OFFSET_MICROMETER    equ 1 ;Offset in micrometers (1/10^6 meter)
  621. PNG_OFFSET_LAST          equ 2 ;Not a valid value
  622.  
  623. ; These are for the pCAL chunk.  These values should NOT be changed.
  624. PNG_EQUATION_LINEAR      equ 0 ;Linear transformation
  625. PNG_EQUATION_BASE_E      equ 1 ;Exponential base e transform
  626. PNG_EQUATION_ARBITRARY   equ 2 ;Arbitrary base exponential transform
  627. PNG_EQUATION_HYPERBOLIC  equ 3 ;Hyperbolic sine transformation
  628. PNG_EQUATION_LAST        equ 4 ;Not a valid value
  629.  
  630. ; These are for the sCAL chunk.  These values should NOT be changed.
  631. PNG_SCALE_UNKNOWN        equ 0 ;unknown unit (image scale)
  632. PNG_SCALE_METER          equ 1 ;meters per pixel
  633. PNG_SCALE_RADIAN         equ 2 ;radians per pixel
  634. PNG_SCALE_LAST           equ 3 ;Not a valid value
  635.  
  636. ; These are for the pHYs chunk.  These values should NOT be changed.
  637. PNG_RESOLUTION_UNKNOWN   equ 0 ;pixels/unknown unit (aspect ratio)
  638. PNG_RESOLUTION_METER     equ 1 ;pixels/meter
  639. PNG_RESOLUTION_LAST      equ 2 ;Not a valid value
  640.  
  641. ; These are for the sRGB chunk.  These values should NOT be changed.
  642. PNG_sRGB_INTENT_PERCEPTUAL equ 0
  643. PNG_sRGB_INTENT_RELATIVE   equ 1
  644. PNG_sRGB_INTENT_SATURATION equ 2
  645. PNG_sRGB_INTENT_ABSOLUTE   equ 3
  646. PNG_sRGB_INTENT_LAST       equ 4 ;Not a valid value
  647.  
  648. ; This is for text chunks
  649. PNG_KEYWORD_MAX_LENGTH equ 79
  650.  
  651. ; Maximum number of entries in PLTE/sPLT/tRNS arrays
  652. PNG_MAX_PALETTE_LENGTH equ 256
  653.  
  654. ; These determine if an ancillary chunk's data has been successfully read
  655. ; from the PNG header, or if the application has filled in the corresponding
  656. ; data in the info_struct to be written into the output file.  The values
  657. ; of the PNG_INFO_<chunk> defines should NOT be changed.
  658.  
  659. PNG_INFO_gAMA equ 0x0001
  660. PNG_INFO_sBIT equ 0x0002
  661. PNG_INFO_cHRM equ 0x0004
  662. PNG_INFO_PLTE equ 0x0008
  663. PNG_INFO_tRNS equ 0x0010
  664. PNG_INFO_bKGD equ 0x0020
  665. PNG_INFO_hIST equ 0x0040
  666. PNG_INFO_pHYs equ 0x0080
  667. PNG_INFO_oFFs equ 0x0100
  668. PNG_INFO_tIME equ 0x0200
  669. PNG_INFO_pCAL equ 0x0400
  670. PNG_INFO_sRGB equ 0x0800 ; GR-P, 0.96a
  671. PNG_INFO_iCCP equ 0x1000 ; ESR, 1.0.6
  672. PNG_INFO_sPLT equ 0x2000 ; ESR, 1.0.6
  673. PNG_INFO_sCAL equ 0x4000 ; ESR, 1.0.6
  674. PNG_INFO_IDAT equ 0x8000 ; ESR, 1.0.6
  675.  
  676. ; This is used for the transformation routines, as some of them
  677. ; change these values for the row.  It also should enable using
  678. ; the routines for other purposes.
  679.  
  680. struct png_row_info ;png_row_info_struct
  681.         width      dd ? ;uint_32 ;width of row
  682.         rowbytes   dd ? ;png_size_t ;number of bytes in row
  683.         color_type db ? ;byte ;color type of row
  684.         bit_depth  db ? ;byte ;bit depth of row
  685.         channels   db ? ;byte ;number of channels (1, 2, 3, or 4)
  686.         pixel_depth db ? ;byte ;bits per pixel (depth * channels)
  687. ends
  688.  
  689. if PNG_SETJMP_SUPPORTED eq 1
  690. ; This must match the function definition in <setjmp.h>, and the application
  691. ; must include this before png.h to obtain the definition of jmp_buf.  The
  692. ; function is required to be PNG_NORETURN, but this is not checked.  If the
  693. ; function does return the application will crash via an abort() or similar
  694. ; system level call.
  695.  
  696. ; If you get a warning here while building the library you may need to make
  697. ; changes to ensure that pnglibconf.h records the calling convention used by
  698. ; your compiler.  This may be very difficult - try using a different compiler
  699. ; to build the library!
  700.  
  701. ;PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef);
  702. end if
  703.  
  704. ; Transform masks for the high-level interface
  705. PNG_TRANSFORM_IDENTITY      equ 0x0000 ; read and write
  706. PNG_TRANSFORM_STRIP_16      equ 0x0001 ; read only
  707. PNG_TRANSFORM_STRIP_ALPHA   equ 0x0002 ; read only
  708. PNG_TRANSFORM_PACKING       equ 0x0004 ; read and write
  709. PNG_TRANSFORM_PACKSWAP      equ 0x0008 ; read and write
  710. PNG_TRANSFORM_EXPAND        equ 0x0010 ; read only
  711. PNG_TRANSFORM_INVERT_MONO   equ 0x0020 ; read and write
  712. PNG_TRANSFORM_SHIFT         equ 0x0040 ; read and write
  713. PNG_TRANSFORM_BGR           equ 0x0080 ; read and write
  714. PNG_TRANSFORM_SWAP_ALPHA    equ 0x0100 ; read and write
  715. PNG_TRANSFORM_SWAP_ENDIAN   equ 0x0200 ; read and write
  716. PNG_TRANSFORM_INVERT_ALPHA  equ 0x0400 ; read and write
  717. PNG_TRANSFORM_STRIP_FILLER  equ 0x0800 ; write only
  718. ; Added to libpng-1.2.34
  719. PNG_TRANSFORM_STRIP_FILLER_BEFORE equ PNG_TRANSFORM_STRIP_FILLER
  720. PNG_TRANSFORM_STRIP_FILLER_AFTER equ 0x1000 ; write only
  721. ; Added to libpng-1.4.0
  722. PNG_TRANSFORM_GRAY_TO_RGB  equ 0x2000 ; read only
  723. ; Added to libpng-1.5.4
  724. PNG_TRANSFORM_EXPAND_16    equ 0x4000 ;read only
  725. ;if INT_MAX >= 0x8000 ;else this might break
  726. PNG_TRANSFORM_SCALE_16     equ 0x8000 ;read only
  727. ;end if
  728.  
  729. ; Flags for MNG supported features
  730. PNG_FLAG_MNG_EMPTY_PLTE    equ 0x01
  731. PNG_FLAG_MNG_FILTER_64     equ 0x04
  732. PNG_ALL_MNG_FEATURES       equ 0x05
  733.  
  734. ; NOTE: prior to 1.5 these functions had no 'API' style declaration,
  735. ; this allowed the zlib default functions to be used on Windows
  736. ; platforms.  In 1.5 the zlib default malloc (which just calls malloc and
  737. ; ignores the first argument) should be completely compatible with the
  738. ; following.
  739.  
  740. ; Section 4: exported functions
  741. ; Here are the function definitions most commonly used.  This is not
  742. ; the place to find out how to use libpng.  See libpng-manual.txt for the
  743. ; full explanation, see example.c for the summary.  This just provides
  744. ; a simple one line description of the use of each function.
  745.  
  746. ; The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in
  747. ; pngconf.h and in the *.dfn files in the scripts directory.
  748.  
  749. ;   PNG_EXPORT(ordinal, type, name, (args));
  750.  
  751. ;       ordinal:    ordinal that is used while building
  752. ;                   *.def files. The ordinal value is only
  753. ;                   relevant when preprocessing png.h with
  754. ;                   the *.dfn files for building symbol table
  755. ;                   entries, and are removed by pngconf.h.
  756. ;       type:       return type of the function
  757. ;       name:       function name
  758. ;       args:       function arguments, with types
  759.  
  760. ; When we wish to append attributes to a function prototype we use
  761. ; the PNG_EXPORTA() macro instead.
  762.  
  763. ;   PNG_EXPORTA(ordinal, type, name, (args), attributes);
  764.  
  765. ;       ordinal, type, name, and args: same as in PNG_EXPORT().
  766. ;       attributes: function attributes
  767.  
  768. macro PNG_EXPORT ordinal, typ, nam, arg
  769. {
  770. align 4
  771. nam:
  772. local .end_t
  773. local .m_txt
  774. jmp .end_t
  775.         .m_txt db `nam,13,10,0
  776. .end_t:
  777.         stdcall dbg_print,txt_zv,.m_txt
  778. ret
  779. }
  780.  
  781. ; Simple signature checking function.  This is the same as calling
  782. ; png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
  783.  
  784. ;#define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n))
  785.  
  786. macro png_setup_abs sum
  787. {
  788. local .end0
  789.         and eax,0xff
  790. if PNG_USE_ABS eq 1
  791.         add sum,128
  792.         sub al,128 ;v - 128
  793.         cmp al,128
  794.         jl @f
  795.                 neg al
  796.                 inc al ;abs(v - 128)
  797.         @@:
  798.         sub sum,eax
  799. else
  800.         cmp eax,128
  801.         jl @f
  802.                 add sum,256
  803.                 sub sum,eax
  804.                 jmp .end0
  805.         @@:
  806.                 add sum,eax
  807.         .end0:
  808. end if
  809. }
  810.  
  811. ; Allocate and initialize png_ptr struct for reading, and any other memory.
  812. ;PNG_EXPORTA(4, png_structp, png_create_read_struct,
  813. ;    (charp user_png_ver, voidp error_ptr,
  814. ;    png_error_ptr error_fn, png_error_ptr warn_fn),
  815. ;    PNG_ALLOCATED);
  816.  
  817. ; Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp
  818. ; match up.
  819.  
  820. ; Read the information before the actual image data.
  821. PNG_EXPORT 22, void, png_read_info, '(png_structrp png_ptr, png_inforp info_ptr)'
  822.  
  823. ; Convert to a US string format: there is no localization support in this
  824. ; routine.  The original implementation used a 29 character buffer in
  825. ; png_struct, this will be removed in future versions.
  826.  
  827. ;#if PNG_LIBPNG_VER < 10700
  828. ; To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h)
  829. ;PNG_EXPORTA(23, charp, png_convert_to_rfc1123, (png_structrp png_ptr,
  830. ;    png_const_timep ptime),PNG_DEPRECATED);
  831. ;end if
  832.  
  833. ; Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available.
  834. PNG_EXPORT 26, void, png_set_expand, '(png_structrp png_ptr)'
  835. PNG_EXPORT 27, void, png_set_expand_gray_1_2_4_to_8, '(png_structrp png_ptr)'
  836. PNG_EXPORT 28, void, png_set_palette_to_rgb, '(png_structrp png_ptr)'
  837. PNG_EXPORT 29, void, png_set_tRNS_to_alpha, '(png_structrp png_ptr)'
  838.  
  839. ; Expand to 16-bit channels, forces conversion of palette to RGB and expansion
  840. ; of a tRNS chunk if present.
  841. PNG_EXPORT 221, void, png_set_expand_16, '(png_structrp png_ptr)'
  842.  
  843. ; Expand the grayscale to 24-bit RGB if necessary.
  844. PNG_EXPORT 31, void, png_set_gray_to_rgb, '(png_structrp png_ptr)'
  845.  
  846. ; Reduce RGB to grayscale.
  847. PNG_ERROR_ACTION_NONE equ 1
  848. PNG_ERROR_ACTION_WARN equ 2
  849. PNG_ERROR_ACTION_ERROR equ 3
  850. PNG_RGB_TO_GRAY_DEFAULT equ (-1) ;for red/green coefficients
  851.  
  852. PNG_EXPORT 32, void, png_set_rgb_to_gray, '(png_structrp png_ptr, int error_action, double red, double green)'
  853. PNG_EXPORT 33, void, png_set_rgb_to_gray_fixed, '(png_structrp png_ptr, int error_action, png_fixed_point red, png_fixed_point green)'
  854.  
  855. PNG_EXPORT 34, byte, png_get_rgb_to_gray_status, '(png_const_structrp png_ptr)'
  856.  
  857. PNG_EXPORT 35, void, png_build_grayscale_palette, '(int bit_depth, png_colorp palette)'
  858.  
  859. ; How the alpha channel is interpreted - this affects how the color channels
  860. ; of a PNG file are returned to the calling application when an alpha channel,
  861. ; or a tRNS chunk in a palette file, is present.
  862.  
  863. ; This has no effect on the way pixels are written into a PNG output
  864. ; datastream. The color samples in a PNG datastream are never premultiplied
  865. ; with the alpha samples.
  866.  
  867. ; The default is to return data according to the PNG specification: the alpha
  868. ; channel is a linear measure of the contribution of the pixel to the
  869. ; corresponding composited pixel, and the color channels are unassociated
  870. ; (not premultiplied).  The gamma encoded color channels must be scaled
  871. ; according to the contribution and to do this it is necessary to undo
  872. ; the encoding, scale the color values, perform the composition and reencode
  873. ; the values.  This is the 'PNG' mode.
  874.  
  875. ; The alternative is to 'associate' the alpha with the color information by
  876. ; storing color channel values that have been scaled by the alpha.
  877. ; image.  These are the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' modes
  878. ; (the latter being the two common names for associated alpha color channels).
  879.  
  880. ; For the 'OPTIMIZED' mode, a pixel is treated as opaque only if the alpha
  881. ; value is equal to the maximum value.
  882.  
  883. ; The final choice is to gamma encode the alpha channel as well.  This is
  884. ; broken because, in practice, no implementation that uses this choice
  885. ; correctly undoes the encoding before handling alpha composition.  Use this
  886. ; choice only if other serious errors in the software or hardware you use
  887. ; mandate it; the typical serious error is for dark halos to appear around
  888. ; opaque areas of the composited PNG image because of arithmetic overflow.
  889.  
  890. ; The API function png_set_alpha_mode specifies which of these choices to use
  891. ; with an enumerated 'mode' value and the gamma of the required output:
  892.  
  893. PNG_ALPHA_PNG          equ 0 ;according to the PNG standard
  894. PNG_ALPHA_STANDARD     equ 1 ;according to Porter/Duff
  895. PNG_ALPHA_ASSOCIATED   equ 1 ;as above; this is the normal practice
  896. PNG_ALPHA_PREMULTIPLIED equ 1 ;as above
  897. PNG_ALPHA_OPTIMIZED    equ 2 ;'PNG' for opaque pixels, else 'STANDARD'
  898. PNG_ALPHA_BROKEN       equ 3 ;the alpha channel is gamma encoded
  899.  
  900. PNG_EXPORT 227, void, png_set_alpha_mode, '(png_structrp png_ptr, int mode, double output_gamma)'
  901. PNG_EXPORT 228, void, png_set_alpha_mode_fixed, '(png_structrp png_ptr, int mode, png_fixed_point output_gamma)'
  902.  
  903. if (PNG_GAMMA_SUPPORTED eq 1) | (PNG_READ_ALPHA_MODE_SUPPORTED eq 1)
  904. ; The output_gamma value is a screen gamma in libpng terminology: it expresses
  905. ; how to decode the output values, not how they are encoded.
  906.  
  907. PNG_DEFAULT_sRGB equ -1       ;sRGB gamma and color space
  908. PNG_GAMMA_MAC_18 equ -2       ;Old Mac '1.8' gamma and color space
  909. PNG_GAMMA_sRGB   equ 220000   ;Television standards--matches sRGB gamma
  910. PNG_GAMMA_LINEAR equ PNG_FP_1 ;Linear
  911. end if
  912.  
  913. ; The following are examples of calls to png_set_alpha_mode to achieve the
  914. ; required overall gamma correction and, where necessary, alpha
  915. ; premultiplication.
  916.  
  917. ; png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);
  918. ;    This is the default libpng handling of the alpha channel - it is not
  919. ;    pre-multiplied into the color components.  In addition the call states
  920. ;    that the output is for a sRGB system and causes all PNG files without gAMA
  921. ;    chunks to be assumed to be encoded using sRGB.
  922.  
  923. ; png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);
  924. ;    In this case the output is assumed to be something like an sRGB conformant
  925. ;    display preceeded by a power-law lookup table of power 1.45.  This is how
  926. ;    early Mac systems behaved.
  927.  
  928. ; png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR);
  929. ;    This is the classic Jim Blinn approach and will work in academic
  930. ;    environments where everything is done by the book.  It has the shortcoming
  931. ;    of assuming that input PNG data with no gamma information is linear - this
  932. ;    is unlikely to be correct unless the PNG files where generated locally.
  933. ;    Most of the time the output precision will be so low as to show
  934. ;    significant banding in dark areas of the image.
  935.  
  936. ; png_set_expand_16(pp);
  937. ; png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB);
  938. ;    This is a somewhat more realistic Jim Blinn inspired approach.  PNG files
  939. ;    are assumed to have the sRGB encoding if not marked with a gamma value and
  940. ;    the output is always 16 bits per component.  This permits accurate scaling
  941. ;    and processing of the data.  If you know that your input PNG files were
  942. ;    generated locally you might need to replace PNG_DEFAULT_sRGB with the
  943. ;    correct value for your system.
  944.  
  945. ; png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB);
  946. ;    If you just need to composite the PNG image onto an existing background
  947. ;    and if you control the code that does this you can use the optimization
  948. ;    setting.  In this case you just copy completely opaque pixels to the
  949. ;    output.  For pixels that are not completely transparent (you just skip
  950. ;    those) you do the composition math using png_composite or png_composite_16
  951. ;    below then encode the resultant 8-bit or 16-bit values to match the output
  952. ;    encoding.
  953.  
  954. ; Other cases
  955. ;    If neither the PNG nor the standard linear encoding work for you because
  956. ;    of the software or hardware you use then you have a big problem.  The PNG
  957. ;    case will probably result in halos around the image.  The linear encoding
  958. ;    will probably result in a washed out, too bright, image (it's actually too
  959. ;    contrasty.)  Try the ALPHA_OPTIMIZED mode above - this will probably
  960. ;    substantially reduce the halos.  Alternatively try:
  961.  
  962. ; png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB);
  963. ;    This option will also reduce the halos, but there will be slight dark
  964. ;    halos round the opaque parts of the image where the background is light.
  965. ;    In the OPTIMIZED mode the halos will be light halos where the background
  966. ;    is dark.  Take your pick - the halos are unavoidable unless you can get
  967. ;    your hardware/software fixed!  (The OPTIMIZED approach is slightly
  968. ;    faster.)
  969.  
  970. ; When the default gamma of PNG files doesn't match the output gamma.
  971. ;    If you have PNG files with no gamma information png_set_alpha_mode allows
  972. ;    you to provide a default gamma, but it also sets the ouput gamma to the
  973. ;    matching value.  If you know your PNG files have a gamma that doesn't
  974. ;    match the output you can take advantage of the fact that
  975. ;    png_set_alpha_mode always sets the output gamma but only sets the PNG
  976. ;    default if it is not already set:
  977.  
  978. ; png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);
  979. ; png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);
  980. ;    The first call sets both the default and the output gamma values, the
  981. ;    second call overrides the output gamma without changing the default.  This
  982. ;    is easier than achieving the same effect with png_set_gamma.  You must use
  983. ;    PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will
  984. ;    fire if more than one call to png_set_alpha_mode and png_set_background is
  985. ;    made in the same read operation, however multiple calls with PNG_ALPHA_PNG
  986. ;    are ignored.
  987.  
  988. PNG_EXPORT 36, void, png_set_strip_alpha, '(png_structrp png_ptr)'
  989.  
  990. ; The values of the PNG_FILLER_ defines should NOT be changed
  991. PNG_FILLER_BEFORE equ 0
  992. PNG_FILLER_AFTER equ 1
  993.  
  994. ;#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
  995.  
  996. ; Handle alpha and tRNS by replacing with a background color.  Prior to
  997. ; libpng-1.5.4 this API must not be called before the PNG file header has been
  998. ; read.  Doing so will result in unexpected behavior and possible warnings or
  999. ; errors if the PNG file contains a bKGD chunk.
  1000.  
  1001. PNG_EXPORT 47, void, png_set_background, '(png_structrp png_ptr, png_const_color_16p background_color, int background_gamma_code, int need_expand, double background_gamma)'
  1002. PNG_EXPORT 215, void, png_set_background_fixed, '(png_structrp png_ptr, png_const_color_16p background_color, int background_gamma_code, int need_expand, png_fixed_point background_gamma)'
  1003.  
  1004. if PNG_READ_BACKGROUND_SUPPORTED eq 1
  1005. PNG_BACKGROUND_GAMMA_UNKNOWN equ 0
  1006. PNG_BACKGROUND_GAMMA_SCREEN equ 1
  1007. PNG_BACKGROUND_GAMMA_FILE   equ 2
  1008. PNG_BACKGROUND_GAMMA_UNIQUE equ 3
  1009. end if
  1010.  
  1011. ; Scale a 16-bit depth file down to 8-bit, accurately.
  1012. PNG_EXPORT 229, void, png_set_scale_16, '(png_structrp png_ptr)'
  1013.  
  1014. ;#define PNG_READ_16_TO_8_SUPPORTED /* Name prior to 1.5.4 */
  1015. ; Strip the second byte of information from a 16-bit depth file.
  1016. PNG_EXPORT 48, void, png_set_strip_16, '(png_structrp png_ptr)'
  1017.  
  1018. ; Turn on quantizing, and reduce the palette to the number of colors
  1019. ; available.
  1020.  
  1021. PNG_EXPORT 49, void, png_set_quantize, '(png_structrp png_ptr, png_colorp palette, int num_palette, int maximum_colors, png_const_uint_16p histogram, int full_quantize)'
  1022.  
  1023. ; The threshold on gamma processing is configurable but hard-wired into the
  1024. ; library.  The following is the floating point variant.
  1025.  
  1026. ;#define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001)
  1027.  
  1028. ; Handle gamma correction. Screen_gamma=(display_exponent).
  1029. ; NOTE: this API simply sets the screen and file gamma values. It will
  1030. ; therefore override the value for gamma in a PNG file if it is called after
  1031. ; the file header has been read - use with care  - call before reading the PNG
  1032. ; file for best results!
  1033.  
  1034. ; These routines accept the same gamma values as png_set_alpha_mode (described
  1035. ; above).  The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either
  1036. ; API (floating point or fixed.)  Notice, however, that the 'file_gamma' value
  1037. ; is the inverse of a 'screen gamma' value.
  1038.  
  1039. PNG_EXPORT 50, void, png_set_gamma, '(png_structrp png_ptr, double screen_gamma, double override_file_gamma)'
  1040. PNG_EXPORT 208, void, png_set_gamma_fixed, '(png_structrp png_ptr, png_fixed_point screen_gamma, png_fixed_point override_file_gamma)'
  1041.  
  1042. ; Optional update palette with requested transformations
  1043. PNG_EXPORT 53, void, png_start_read_image, '(png_structrp png_ptr)'
  1044.  
  1045. ; Optional call to update the users info structure
  1046. PNG_EXPORT 54, void, png_read_update_info, '(png_structrp png_ptr, png_inforp info_ptr)'
  1047.  
  1048. ; Read one or more rows of image data.
  1049. PNG_EXPORT 55, void, png_read_rows, '(png_structrp png_ptr, bytepp row, bytepp display_row, uint_32 num_rows)'
  1050.  
  1051. ; Read a row of data.
  1052. PNG_EXPORT 56, void, png_read_row, '(png_structrp png_ptr, bytep row, bytep display_row)'
  1053.  
  1054. ; Read the whole image into memory at once.
  1055. PNG_EXPORT 57, void, png_read_image, '(png_structrp png_ptr, bytepp image)'
  1056.  
  1057. ; Read the end of the PNG file.
  1058. PNG_EXPORT 62, void, png_read_end, '(png_structrp png_ptr, png_inforp info_ptr)'
  1059.  
  1060. ; Free any memory associated with the png_struct and the png_info_structs
  1061. PNG_EXPORT 64, void, png_destroy_read_struct, '(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)'
  1062.  
  1063. ; Set the libpng method of handling chunk CRC errors
  1064. PNG_EXPORT 66, void, png_set_crc_action, '(png_structrp png_ptr, int crit_action, int ancil_action)'
  1065.  
  1066. ; Values for png_set_crc_action() say how to handle CRC errors in
  1067. ; ancillary and critical chunks, and whether to use the data contained
  1068. ; therein.  Note that it is impossible to "discard" data in a critical
  1069. ; chunk.  For versions prior to 0.90, the action was always error/quit,
  1070. ; whereas in version 0.90 and later, the action for CRC errors in ancillary
  1071. ; chunks is warn/discard.  These values should NOT be changed.
  1072.  
  1073. ;      value                       action:critical     action:ancillary
  1074.  
  1075. PNG_CRC_DEFAULT      equ 0 ;error/quit          warn/discard data
  1076. PNG_CRC_ERROR_QUIT   equ 1 ;error/quit          error/quit
  1077. PNG_CRC_WARN_DISCARD equ 2 ;(INVALID)           warn/discard data
  1078. PNG_CRC_WARN_USE     equ 3 ;warn/use data       warn/use data
  1079. PNG_CRC_QUIET_USE    equ 4 ;quiet/use data      quiet/use data
  1080. PNG_CRC_NO_CHANGE    equ 5 ;use current value   use current value
  1081.  
  1082. ; Flags for png_set_filter() to say which filters to use.  The flags
  1083. ; are chosen so that they don't conflict with real filter types
  1084. ; below, in case they are supplied instead of the #defined constants.
  1085. ; These values should NOT be changed.
  1086.  
  1087. PNG_NO_FILTERS   equ 0x00
  1088. PNG_FILTER_NONE  equ 0x08
  1089. PNG_FILTER_SUB   equ 0x10
  1090. PNG_FILTER_UP    equ 0x20
  1091. PNG_FILTER_AVG   equ 0x40
  1092. PNG_FILTER_PAETH equ 0x80
  1093. PNG_FAST_FILTERS equ (PNG_FILTER_NONE or PNG_FILTER_SUB or PNG_FILTER_UP)
  1094. PNG_ALL_FILTERS  equ (PNG_FAST_FILTERS or PNG_FILTER_AVG or PNG_FILTER_PAETH)
  1095.  
  1096. ; Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
  1097. ; These defines should NOT be changed.
  1098.  
  1099. PNG_FILTER_VALUE_NONE equ 0
  1100. PNG_FILTER_VALUE_SUB  equ 1
  1101. PNG_FILTER_VALUE_UP   equ 2
  1102. PNG_FILTER_VALUE_AVG  equ 3
  1103. PNG_FILTER_VALUE_PAETH equ 4
  1104. PNG_FILTER_VALUE_LAST equ 5
  1105.  
  1106. ; The following are no longer used and will be removed from libpng-1.7:
  1107. PNG_FILTER_HEURISTIC_DEFAULT   equ 0 ;Currently "UNWEIGHTED"
  1108. PNG_FILTER_HEURISTIC_UNWEIGHTED equ 1 ;Used by libpng < 0.95
  1109. PNG_FILTER_HEURISTIC_WEIGHTED  equ 2 ;Experimental feature
  1110. PNG_FILTER_HEURISTIC_LAST      equ 3 ;Not a valid value
  1111.  
  1112. ; These next functions are called for input/output, memory, and error
  1113. ; handling.  They are in the file pngrio.c, pngwio.c, and pngerror.c,
  1114. ; and call standard C I/O routines such as fread(), fwrite(), and
  1115. ; fprintf().  These functions can be made to use other I/O routines
  1116. ; at run time for those applications that need to handle I/O in a
  1117. ; different manner by calling png_set_???_fn().  See libpng-manual.txt for
  1118. ; more information.
  1119.  
  1120.  
  1121. ; Replace the default data input function with a user supplied one.
  1122. PNG_EXPORT 78, void, png_set_read_fn, '(png_structrp png_ptr, voidp io_ptr, png_rw_ptr read_data_fn)'
  1123.  
  1124. PNG_EXPORT 80, void, png_set_read_status_fn, '(png_structrp png_ptr, png_read_status_ptr read_row_fn)'
  1125.  
  1126. PNG_EXPORT 84, void, png_set_read_user_transform_fn, '(png_structrp png_ptr, png_user_transform_ptr read_user_transform_fn)'
  1127.  
  1128. if PNG_PROGRESSIVE_READ_SUPPORTED eq 1
  1129. ; Sets the function callbacks for the push reader, and a pointer to a
  1130. ; user-defined structure available to the callback functions.
  1131.  
  1132. PNG_EXPORT 90, void, png_set_progressive_read_fn, '(png_structrp png_ptr, voidp progressive_ptr, png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn)'
  1133.  
  1134. ; Returns the user pointer associated with the push read functions
  1135. PNG_EXPORT 91, voidp, png_get_progressive_ptr, '(png_const_structrp png_ptr)'
  1136.  
  1137. ; Function to be called when data becomes available
  1138. PNG_EXPORT 92, void, png_process_data, '(png_structrp png_ptr, png_inforp info_ptr, bytep buffer, png_size_t buffer_size)'
  1139.  
  1140. ; A function which may be called *only* within png_process_data to stop the
  1141. ; processing of any more data.  The function returns the number of bytes
  1142. ; remaining, excluding any that libpng has cached internally.  A subsequent
  1143. ; call to png_process_data must supply these bytes again.  If the argument
  1144. ; 'save' is set to true the routine will first save all the pending data and
  1145. ; will always return 0.
  1146.  
  1147. PNG_EXPORT 219, png_size_t, png_process_data_pause, '(png_structrp, int save)'
  1148.  
  1149. ; A function which may be called *only* outside (after) a call to
  1150. ; png_process_data.  It returns the number of bytes of data to skip in the
  1151. ; input.  Normally it will return 0, but if it returns a non-zero value the
  1152. ; application must skip than number of bytes of input data and pass the
  1153. ; following data to the next call to png_process_data.
  1154.  
  1155. PNG_EXPORT 220, uint_32, png_process_data_skip, '(png_structrp)'
  1156.  
  1157. ; Function that combines rows.  'new_row' is a flag that should come from
  1158. ; the callback and be non-NULL if anything needs to be done; the library
  1159. ; stores its own version of the new data internally and ignores the passed
  1160. ; in value.
  1161.  
  1162. PNG_EXPORT 93, void, png_progressive_combine_row, '(png_const_structrp png_ptr, bytep old_row, bytep new_row)'
  1163. end if ;PROGRESSIVE_READ
  1164.  
  1165. ; Reassign responsibility for freeing existing data, whether allocated
  1166. ; by libpng or by the application; this works on the png_info structure passed
  1167. ; in, it does not change the state for other png_info structures.
  1168.  
  1169. ; It is unlikely that this function works correctly as of 1.6.0 and using it
  1170. ; may result either in memory leaks or double free of allocated data.
  1171.  
  1172. ; Assignments for png_data_freer
  1173. PNG_DESTROY_WILL_FREE_DATA equ 1
  1174. PNG_SET_WILL_FREE_DATA equ 1
  1175. PNG_USER_WILL_FREE_DATA equ 2
  1176. ; Flags for png_ptr->free_me and info_ptr->free_me
  1177. PNG_FREE_HIST equ 0x0008
  1178. PNG_FREE_ICCP equ 0x0010
  1179. PNG_FREE_SPLT equ 0x0020
  1180. PNG_FREE_ROWS equ 0x0040
  1181. PNG_FREE_PCAL equ 0x0080
  1182. PNG_FREE_SCAL equ 0x0100
  1183. if PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED eq 1
  1184.         PNG_FREE_UNKN equ 0x0200
  1185. end if
  1186. PNG_FREE_LIST equ 0x0400 ;removed in 1.6.0 because it is ignored
  1187. PNG_FREE_PLTE equ 0x1000
  1188. PNG_FREE_TRNS equ 0x2000
  1189. PNG_FREE_TEXT equ 0x4000
  1190. PNG_FREE_ALL  equ 0x7fff
  1191. PNG_FREE_MUL  equ 0x4220 ;PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN
  1192.  
  1193. ;if PNG_ERROR_TEXT_SUPPORTED
  1194. ; The same, but the chunk name is prepended to the error string.
  1195. ;PNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr,
  1196. ;    charp error_message), PNG_NORETURN);
  1197.  
  1198. ;#else
  1199. ; Fatal error in PNG image of libpng - can't continue
  1200. ;PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN);
  1201. ;#  define png_chunk_error(s1,s2) png_err(s1)
  1202. ;end if
  1203.  
  1204. ; Non-fatal error in libpng, chunk name is prepended to message.
  1205. PNG_EXPORT 106, void, png_chunk_warning, '(png_const_structrp png_ptr, charp warning_message)'
  1206. ;#else
  1207. ;#  define png_warning(s1,s2) ((void)(s1))
  1208. ;#  define png_chunk_warning(s1,s2) ((void)(s1))
  1209.  
  1210. ; Benign error in libpng.  Can continue, but may have a problem.
  1211. ; User can choose whether to handle as a fatal error or as a warning.
  1212. PNG_EXPORT 107, void, png_benign_error, '(png_const_structrp png_ptr, charp warning_message)'
  1213.  
  1214. ;if PNG_READ_SUPPORTED
  1215. ; Same, chunk name is prepended to message (only during read)
  1216. PNG_EXPORT 108, void, png_chunk_benign_error, '(png_const_structrp png_ptr, charp warning_message)'
  1217.  
  1218. ;#else
  1219. ;#  ifdef PNG_ALLOW_BENIGN_ERRORS
  1220. macro png_benign_error h,txt
  1221. {
  1222.         png_warning h,txt
  1223. }
  1224. ;#    define png_chunk_benign_error png_chunk_warning
  1225. ;#  else
  1226. ;#    define png_benign_error png_error
  1227. ;#    define png_chunk_benign_error png_chunk_error
  1228. ;#  endif
  1229. ;end if
  1230.  
  1231. ; Returns number of color channels in image.
  1232. PNG_EXPORT 114, byte, png_get_channels, '(png_const_structrp png_ptr, png_const_inforp info_ptr)'
  1233.  
  1234. ; Returns pixel aspect ratio, computed from pHYs chunk data.
  1235. PNG_EXPORT 125, float, png_get_pixel_aspect_ratio, '(png_const_structrp png_ptr, png_const_inforp info_ptr)'
  1236. PNG_EXPORT 210, png_fixed_point, png_get_pixel_aspect_ratio_fixed, '(png_const_structrp png_ptr, png_const_inforp info_ptr)'
  1237.  
  1238. ; Returns image x, y offset in pixels or microns, from oFFs chunk data.
  1239. PNG_EXPORT 126, int_32, png_get_x_offset_pixels, '(png_const_structrp png_ptr, png_const_inforp info_ptr)'
  1240. PNG_EXPORT 127, int_32, png_get_y_offset_pixels, '(png_const_structrp png_ptr, png_const_inforp info_ptr)'
  1241. PNG_EXPORT 128, int_32, png_get_x_offset_microns, '(png_const_structrp png_ptr, png_const_inforp info_ptr)'
  1242. PNG_EXPORT 129, int_32, png_get_y_offset_microns, '(png_const_structrp png_ptr, png_const_inforp info_ptr)'
  1243.  
  1244. ; Returns pointer to signature string read from PNG header
  1245. PNG_EXPORT 130, bytep, png_get_signature, '(png_const_structrp png_ptr, png_const_inforp info_ptr)'
  1246.  
  1247. PNG_EXPORT 131, uint_32, png_get_bKGD, '(png_const_structrp png_ptr, png_inforp info_ptr, png_color_16p *background)'
  1248.  
  1249. PNG_EXPORT 133, uint_32, png_get_cHRM, '(png_const_structrp png_ptr, png_const_inforp info_ptr, double *white_x, double *white_y, double *red_x, double *red_y, double *green_x, double *green_y, double *blue_x, double *blue_y)'
  1250. PNG_EXPORT 230, uint_32, png_get_cHRM_XYZ, '(png_const_structrp png_ptr, png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z, double *green_X, double *green_Y, double *green_Z, double *blue_X, double *blue_Y, double *blue_Z)'
  1251. PNG_EXPORT 134, uint_32, png_get_cHRM_fixed, '(png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_white_x, png_fixed_point *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point *int_blue_x, png_fixed_point *int_blue_y)'
  1252.  
  1253. PNG_EXPORT 137, uint_32, png_get_gAMA, '(png_const_structrp png_ptr, png_const_inforp info_ptr, double *file_gamma)'
  1254. PNG_EXPORT 138, uint_32, png_get_gAMA_fixed, '(png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_file_gamma)'
  1255.  
  1256. PNG_EXPORT 145, uint_32, png_get_oFFs, '(png_const_structrp png_ptr, png_const_inforp info_ptr, int_32 *offset_x, int_32 *offset_y, int *unit_type)'
  1257.  
  1258. PNG_EXPORT 147, uint_32, png_get_pCAL, '(png_const_structrp png_ptr, png_inforp info_ptr, charp *purpose, int_32 *X0, int_32 *X1, int *type, int *nparams, charp *units, charpp *params)'
  1259.  
  1260. PNG_EXPORT 149, uint_32, png_get_pHYs, '(png_const_structrp png_ptr, png_const_inforp info_ptr, uint_32 *res_x, uint_32 *res_y, int *unit_type)'
  1261.  
  1262. PNG_EXPORT 151, uint_32, png_get_PLTE, '(png_const_structrp png_ptr, png_inforp info_ptr, png_colorp *palette, int *num_palette)'
  1263.  
  1264. PNG_EXPORT 153, uint_32, png_get_sBIT, '(png_const_structrp png_ptr, png_inforp info_ptr, png_color_8p *sig_bit)'
  1265.  
  1266. PNG_EXPORT 155, uint_32, png_get_sRGB, '(png_const_structrp png_ptr, png_const_inforp info_ptr, int *file_srgb_intent)'
  1267.  
  1268. ; png_get_text also returns the number of text chunks in *num_text
  1269. PNG_EXPORT 162, int, png_get_text, '(png_const_structrp png_ptr, png_inforp info_ptr, png_textp *text_ptr, int *num_text)'
  1270.  
  1271. PNG_EXPORT 164, uint_32, png_get_tIME, '(png_const_structrp png_ptr, png_inforp info_ptr, png_timep *mod_time)'
  1272.  
  1273. PNG_EXPORT 166, uint_32, png_get_tRNS, '(png_const_structrp png_ptr, png_inforp info_ptr, bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)'
  1274.  
  1275. PNG_EXPORT 168, uint_32, png_get_sCAL, '(png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, double *width, double *height)'
  1276.  
  1277. ; NOTE: this API is currently implemented using floating point arithmetic,
  1278. ; consequently it can only be used on systems with floating point support.
  1279. ; In any case the range of values supported by png_fixed_point is small and it
  1280. ; is highly recommended that png_get_sCAL_s be used instead.
  1281.  
  1282. PNG_EXPORT 214, uint_32, png_get_sCAL_fixed, '(png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, png_fixed_point *width, png_fixed_point *height)'
  1283.  
  1284. PNG_EXPORT 170, void, png_set_sCAL, '(png_const_structrp png_ptr, png_inforp info_ptr, int unit, double width, double height)'
  1285. PNG_EXPORT 171, void, png_set_sCAL_s, '(png_const_structrp png_ptr, png_inforp info_ptr, int unit, charp swidth, charp sheight)'
  1286.  
  1287. ; Provide the default handling for all unknown chunks or, optionally, for
  1288. ; specific unknown chunks.
  1289.  
  1290. ; NOTE: prior to 1.6.0 the handling specified for particular chunks on read was
  1291. ; ignored and the default was used, the per-chunk setting only had an effect on
  1292. ; write.  If you wish to have chunk-specific handling on read in code that must
  1293. ; work on earlier versions you must use a user chunk callback to specify the
  1294. ; desired handling (keep or discard.)
  1295.  
  1296. ; The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below.  The
  1297. ; parameter is interpreted as follows:
  1298.  
  1299. ; READ:
  1300. ;    PNG_HANDLE_CHUNK_AS_DEFAULT:
  1301. ;       Known chunks: do normal libpng processing, do not keep the chunk (but
  1302. ;          see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
  1303. ;       Unknown chunks: for a specific chunk use the global default, when used
  1304. ;          as the default discard the chunk data.
  1305. ;    PNG_HANDLE_CHUNK_NEVER:
  1306. ;       Discard the chunk data.
  1307. ;    PNG_HANDLE_CHUNK_IF_SAFE:
  1308. ;       Keep the chunk data if the chunk is not critical else raise a chunk
  1309. ;       error.
  1310. ;    PNG_HANDLE_CHUNK_ALWAYS:
  1311. ;       Keep the chunk data.
  1312.  
  1313. ; If the chunk data is saved it can be retrieved using png_get_unknown_chunks,
  1314. ; below.  Notice that specifying "AS_DEFAULT" as a global default is equivalent
  1315. ; to specifying "NEVER", however when "AS_DEFAULT" is used for specific chunks
  1316. ; it simply resets the behavior to the libpng default.
  1317.  
  1318. ; INTERACTION WTIH USER CHUNK CALLBACKS:
  1319. ; The per-chunk handling is always used when there is a png_user_chunk_ptr
  1320. ; callback and the callback returns 0; the chunk is then always stored *unless*
  1321. ; it is critical and the per-chunk setting is other than ALWAYS.  Notice that
  1322. ; the global default is *not* used in this case.  (In effect the per-chunk
  1323. ; value is incremented to at least IF_SAFE.)
  1324.  
  1325. ; IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and
  1326. ; per-chunk defaults will be honored.  If you want to preserve the current
  1327. ; behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE
  1328. ; as the default - if you don't do this libpng 1.6 will issue a warning.
  1329.  
  1330. ; If you want unhandled unknown chunks to be discarded in libpng 1.6 and
  1331. ; earlier simply return '1' (handled).
  1332.  
  1333. ; PNG_HANDLE_AS_UNKNOWN_SUPPORTED:
  1334. ;    If this is *not* set known chunks will always be handled by libpng and
  1335. ;    will never be stored in the unknown chunk list.  Known chunks listed to
  1336. ;    png_set_keep_unknown_chunks will have no effect.  If it is set then known
  1337. ;    chunks listed with a keep other than AS_DEFAULT will *never* be processed
  1338. ;    by libpng, in addition critical chunks must either be processed by the
  1339. ;    callback or saved.
  1340.  
  1341. ;    The IHDR and IEND chunks must not be listed.  Because this turns off the
  1342. ;    default handling for chunks that would otherwise be recognized the
  1343. ;    behavior of libpng transformations may well become incorrect!
  1344.  
  1345. ; WRITE:
  1346. ;    When writing chunks the options only apply to the chunks specified by
  1347. ;    png_set_unknown_chunks (below), libpng will *always* write known chunks
  1348. ;    required by png_set_ calls and will always write the core critical chunks
  1349. ;    (as required for PLTE).
  1350.  
  1351. ;    Each chunk in the png_set_unknown_chunks list is looked up in the
  1352. ;    png_set_keep_unknown_chunks list to find the keep setting, this is then
  1353. ;    interpreted as follows:
  1354.  
  1355. ;    PNG_HANDLE_CHUNK_AS_DEFAULT:
  1356. ;       Write safe-to-copy chunks and write other chunks if the global
  1357. ;       default is set to _ALWAYS, otherwise don't write this chunk.
  1358. ;    PNG_HANDLE_CHUNK_NEVER:
  1359. ;       Do not write the chunk.
  1360. ;    PNG_HANDLE_CHUNK_IF_SAFE:
  1361. ;       Write the chunk if it is safe-to-copy, otherwise do not write it.
  1362. ;    PNG_HANDLE_CHUNK_ALWAYS:
  1363. ;       Write the chunk.
  1364.  
  1365. ; Note that the default behavior is effectively the opposite of the read case -
  1366. ; in read unknown chunks are not stored by default, in write they are written
  1367. ; by default.  Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different
  1368. ; - on write the safe-to-copy bit is checked, on read the critical bit is
  1369. ; checked and on read if the chunk is critical an error will be raised.
  1370.  
  1371. ; num_chunks:
  1372. ; ===========
  1373. ;    If num_chunks is positive, then the "keep" parameter specifies the manner
  1374. ;    for handling only those chunks appearing in the chunk_list array,
  1375. ;    otherwise the chunk list array is ignored.
  1376.  
  1377. ;    If num_chunks is 0 the "keep" parameter specifies the default behavior for
  1378. ;    unknown chunks, as described above.
  1379.  
  1380. ;    If num_chunks is negative, then the "keep" parameter specifies the manner
  1381. ;    for handling all unknown chunks plus all chunks recognized by libpng
  1382. ;    except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to
  1383. ;    be processed by libpng.
  1384.  
  1385.  
  1386. ; The "params" pointer is currently not used and is for future expansion.
  1387. PNG_EXPORT 178, void, png_read_png, '(png_structrp png_ptr, png_inforp info_ptr, int transforms, voidp params)'
  1388.  
  1389. ; For use in png_set_keep_unknown, added to version 1.2.6
  1390. PNG_HANDLE_CHUNK_AS_DEFAULT  equ 0
  1391. PNG_HANDLE_CHUNK_NEVER       equ 1
  1392. PNG_HANDLE_CHUNK_IF_SAFE     equ 2
  1393. PNG_HANDLE_CHUNK_ALWAYS      equ 3
  1394. PNG_HANDLE_CHUNK_LAST        equ 4
  1395.  
  1396. ; Removed from libpng 1.6; use png_get_io_chunk_type.
  1397. ;PNG_REMOVED(200, bytep, png_get_io_chunk_name, (png_structrp png_ptr),
  1398. ;    PNG_DEPRECATED)
  1399.  
  1400. ; The flags returned by png_get_io_state() are the following:
  1401. PNG_IO_NONE        equ 0x0000 ; no I/O at this moment
  1402. PNG_IO_READING     equ 0x0001 ; currently reading
  1403. PNG_IO_WRITING     equ 0x0002 ; currently writing
  1404. PNG_IO_SIGNATURE   equ 0x0010 ; currently at the file signature
  1405. PNG_IO_CHUNK_HDR   equ 0x0020 ; currently at the chunk header
  1406. PNG_IO_CHUNK_DATA  equ 0x0040 ; currently at the chunk data
  1407. PNG_IO_CHUNK_CRC   equ 0x0080 ; currently at the chunk crc
  1408. PNG_IO_MASK_OP     equ 0x000f ; current operation: reading/writing
  1409. PNG_IO_MASK_LOC    equ 0x00f0 ; current location: sig/hdr/data/crc
  1410. ;end if /* IO_STATE */
  1411.  
  1412. ; Interlace support.  The following macros are always defined so that if
  1413. ; libpng interlace handling is turned off the macros may be used to handle
  1414. ; interlaced images within the application.
  1415.  
  1416. ;#define PNG_INTERLACE_ADAM7_PASSES 7
  1417.  
  1418. ; Two macros to return the first row and first column of the original,
  1419. ; full, image which appears in a given pass.  'pass' is in the range 0
  1420. ; to 6 and the result is in the range 0 to 7.
  1421.  
  1422. macro PNG_PASS_START_ROW pass
  1423. {
  1424.         push ebx ecx
  1425.         mov eax,pass
  1426.         not eax
  1427.         mov ebx,pass
  1428.         and eax,1
  1429.         shr ebx,1
  1430.         mov ecx,3
  1431.         sub ecx,ebx
  1432.         shl eax,cl
  1433.         and eax,7
  1434.         pop ecx ebx
  1435. }
  1436. macro PNG_PASS_START_COL pass
  1437. {
  1438.         push ebx ecx
  1439.         mov eax,pass
  1440.         mov ebx,pass
  1441.         and eax,1
  1442.         inc ebx
  1443.         shr ebx,1
  1444.         mov ecx,3
  1445.         sub ecx,ebx
  1446.         shl eax,cl
  1447.         and eax,7
  1448.         pop ecx ebx
  1449. }
  1450.  
  1451. ; A macro to return the offset between pixels in the output row for a pair of
  1452. ; pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that
  1453. ; follows.  Note that ROW_OFFSET is the offset from one row to the next whereas
  1454. ; COL_OFFSET is from one column to the next, within a row.
  1455.  
  1456. ;#define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8)
  1457. ;#define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1))
  1458.  
  1459. ; Two macros to help evaluate the number of rows or columns in each
  1460. ; pass.  This is expressed as a shift - effectively log2 of the number or
  1461. ; rows or columns in each 8x8 tile of the original image.
  1462.  
  1463. macro PNG_PASS_ROW_SHIFT pass
  1464. {
  1465. local .end0
  1466.         mov eax,3
  1467.         cmp pass,2
  1468.         jle .end0
  1469.                 mov eax,8
  1470.                 sub eax,pass
  1471.                 shr eax,1
  1472.         .end0:
  1473. }
  1474. macro PNG_PASS_COL_SHIFT pass
  1475. {
  1476. local .end0
  1477.         mov eax,3
  1478.         cmp pass,1
  1479.         jle .end0
  1480.                 mov eax,7
  1481.                 sub eax,pass
  1482.                 shr eax,1
  1483.         .end0:
  1484. }
  1485.  
  1486. ; Hence two macros to determine the number of rows or columns in a given
  1487. ; pass of an image given its height or width.  In fact these macros may
  1488. ; return non-zero even though the sub-image is empty, because the other
  1489. ; dimension may be empty for a small image.
  1490.  
  1491. macro PNG_PASS_ROWS height, pass
  1492. {
  1493. push ecx
  1494. push ebx
  1495.         PNG_PASS_START_ROW pass
  1496.         mov ebx,eax
  1497.         PNG_PASS_ROW_SHIFT pass
  1498.         mov ecx,eax
  1499.         xor eax,eax
  1500.         inc eax
  1501.         shl eax,cl
  1502.         dec eax
  1503.         sub eax,ebx
  1504. pop ebx
  1505.         add eax,height
  1506.         shr eax,cl
  1507. pop ecx
  1508. }
  1509. macro PNG_PASS_COLS width, pass
  1510. {
  1511. push ecx
  1512. push ebx
  1513.         PNG_PASS_START_COL pass
  1514.         mov ebx,eax
  1515.         PNG_PASS_COL_SHIFT pass
  1516.         mov ecx,eax
  1517.         xor eax,eax
  1518.         inc eax
  1519.         shl eax,cl
  1520.         dec eax
  1521.         sub eax,ebx
  1522. pop ebx
  1523.         add eax,width
  1524.         shr eax,cl
  1525. pop ecx
  1526. }
  1527.  
  1528. ; For the reader row callbacks (both progressive and sequential) it is
  1529. ; necessary to find the row in the output image given a row in an interlaced
  1530. ; image, so two more macros:
  1531.  
  1532. ;#define PNG_ROW_FROM_PASS_ROW(y_in, pass) \
  1533. ;   (((y_in)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass))
  1534. ;#define PNG_COL_FROM_PASS_COL(x_in, pass) \
  1535. ;   (((x_in)<<PNG_PASS_COL_SHIFT(pass))+PNG_PASS_START_COL(pass))
  1536.  
  1537. ; Two macros which return a boolean (0 or 1) saying whether the given row
  1538. ; or column is in a particular pass.  These use a common utility macro that
  1539. ; returns a mask for a given pass - the offset 'off' selects the row or
  1540. ; column version.  The mask has the appropriate bit set for each column in
  1541. ; the tile.
  1542.  
  1543. ;#define PNG_PASS_MASK(pass,off) ( \
  1544. ;   ((0x110145AF>>(((7-(off))-(pass))<<2)) & 0xF) | \
  1545. ;   ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0))
  1546.  
  1547. ;#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \
  1548. ;   ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1)
  1549. ;#define PNG_COL_IN_INTERLACE_PASS(x, pass) \
  1550. ;   ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1)
  1551.  
  1552. ;if PNG_READ_COMPOSITE_NODIV_SUPPORTED
  1553. ; With these routines we avoid an integer divide, which will be slower on
  1554. ; most machines.  However, it does take more operations than the corresponding
  1555. ; divide method, so it may be slower on a few RISC systems.  There are two
  1556. ; shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
  1557.  
  1558. ; Note that the rounding factors are NOT supposed to be the same!  128 and
  1559. ; 32768 are correct for the NODIV code; 127 and 32767 are correct for the
  1560. ; standard method.
  1561.  
  1562. ; [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
  1563.  
  1564.  
  1565. ; fg and bg should be in `gamma 1.0' space; alpha is the opacity
  1566.  
  1567. ;#  define png_composite(composite, fg, alpha, bg)        \
  1568. ;   {                                                     \
  1569. ;      uint_16 temp = (uint_16)((uint_16)(fg) \
  1570. ;          * (uint_16)(alpha)                         \
  1571. ;          + (uint_16)(bg)*(uint_16)(255          \
  1572. ;          - (uint_16)(alpha)) + 128);                \
  1573. ;      (composite) = (byte)(((temp + (temp >> 8)) >> 8) & 0xff); \
  1574. ;   }
  1575.  
  1576. ;#  define png_composite_16(composite, fg, alpha, bg)     \
  1577. ;   {                                                     \
  1578. ;      uint_32 temp = (uint_32)((uint_32)(fg) \
  1579. ;          * (uint_32)(alpha)                         \
  1580. ;          + (uint_32)(bg)*(65535                     \
  1581. ;          - (uint_32)(alpha)) + 32768);              \
  1582. ;      (composite) = (uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); \
  1583. ;   }
  1584.  
  1585. ;#else  /* Standard method using integer division */
  1586.  
  1587. ;#  define png_composite(composite, fg, alpha, bg)                      \
  1588. ;   (composite) =                                                       \
  1589. ;       (byte)(0xff & (((uint_16)(fg) * (uint_16)(alpha) +  \
  1590. ;       (uint_16)(bg) * (uint_16)(255 - (uint_16)(alpha)) + \
  1591. ;       127) / 255))
  1592.  
  1593. ;#  define png_composite_16(composite, fg, alpha, bg)                       \
  1594. ;   (composite) =                                                           \
  1595. ;       (uint_16)(0xffff & (((uint_32)(fg) * (uint_32)(alpha) + \
  1596. ;       (uint_32)(bg)*(uint_32)(65535 - (uint_32)(alpha)) +     \
  1597. ;       32767) / 65535))
  1598. ;end if /* READ_COMPOSITE_NODIV */
  1599.  
  1600. PNG_EXPORT 201, uint_32, png_get_uint_32, '(bytep buf)'
  1601. PNG_EXPORT 202, uint_16, png_get_uint_16, '(bytep buf)'
  1602. PNG_EXPORT 203, int_32, png_get_int_32, '(bytep buf)'
  1603.  
  1604. PNG_EXPORT 204, uint_32, png_get_uint_31, '(png_const_structrp png_ptr, bytep buf)'
  1605. ; No png_get_int_16 -- may be added if there's a real need for it.
  1606.  
  1607. ;if PNG_USE_READ_MACROS
  1608. ; Inline macros to do direct reads of bytes from the input buffer.
  1609. ; The png_get_int_32() routine assumes we are using two's complement
  1610. ; format for negative values, which is almost certainly true.
  1611.  
  1612. ;#  define PNG_get_uint_32(buf) \
  1613. ;   (((uint_32)(*(buf)) << 24) + \
  1614. ;    ((uint_32)(*((buf) + 1)) << 16) + \
  1615. ;    ((uint_32)(*((buf) + 2)) << 8) + \
  1616. ;    ((uint_32)(*((buf) + 3))))
  1617.  
  1618.         ; From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
  1619.         ; function) incorrectly returned a value of type uint_32.
  1620.  
  1621. ;#  define PNG_get_uint_16(buf) \
  1622. ;   ((uint_16) \
  1623. ;    (((unsigned int)(*(buf)) << 8) + \
  1624. ;    ((unsigned int)(*((buf) + 1)))))
  1625.  
  1626. ;#  define PNG_get_int_32(buf) \
  1627. ;   ((int_32)((*(buf) & 0x80) \
  1628. ;    ? -((int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \
  1629. ;    : (int_32)png_get_uint_32(buf)))
  1630.  
  1631. ; If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h,
  1632. ; but defining a macro name prefixed with PNG_PREFIX.
  1633.  
  1634. ;#  ifndef PNG_PREFIX
  1635. ;#    define png_get_uint_32(buf) PNG_get_uint_32(buf)
  1636. ;#    define png_get_uint_16(buf) PNG_get_uint_16(buf)
  1637. ;#    define png_get_int_32(buf)  PNG_get_int_32(buf)
  1638. ;#  endif
  1639. ;#else
  1640. ;#  ifdef PNG_PREFIX
  1641.         ; No macros; revert to the (redefined) function
  1642. ;#    define PNG_get_uint_32 (png_get_uint_32)
  1643. ;#    define PNG_get_uint_16 (png_get_uint_16)
  1644. ;#    define PNG_get_int_32  (png_get_int_32)
  1645. ;#  endif
  1646. ;end if
  1647.  
  1648. ;/*******************************************************************************
  1649. ; Section 5: SIMPLIFIED API
  1650. ; *******************************************************************************
  1651.  
  1652. ; Please read the documentation in libpng-manual.txt (TODO: write said
  1653. ; documentation) if you don't understand what follows.
  1654.  
  1655. ; The simplified API hides the details of both libpng and the PNG file format
  1656. ; itself.  It allows PNG files to be read into a very limited number of
  1657. ; in-memory bitmap formats or to be written from the same formats.  If these
  1658. ; formats do not accomodate your needs then you can, and should, use the more
  1659. ; sophisticated APIs above - these support a wide variety of in-memory formats
  1660. ; and a wide variety of sophisticated transformations to those formats as well
  1661. ; as a wide variety of APIs to manipulate ancillary information.
  1662.  
  1663. ; To read a PNG file using the simplified API:
  1664.  
  1665. ; 1) Declare a 'png_image' structure (see below) on the stack, set the
  1666. ;    version field to PNG_IMAGE_VERSION and the 'opaque' pointer to NULL
  1667. ;    (this is REQUIRED, your program may crash if you don't do it.)
  1668. ; 2) Call the appropriate png_image_begin_read... function.
  1669. ; 3) Set the png_image 'format' member to the required sample format.
  1670. ; 4) Allocate a buffer for the image and, if required, the color-map.
  1671. ; 5) Call png_image_finish_read to read the image and, if required, the
  1672. ;    color-map into your buffers.
  1673.  
  1674. ; There are no restrictions on the format of the PNG input itself; all valid
  1675. ; color types, bit depths, and interlace methods are acceptable, and the
  1676. ; input image is transformed as necessary to the requested in-memory format
  1677. ; during the png_image_finish_read() step.  The only caveat is that if you
  1678. ; request a color-mapped image from a PNG that is full-color or makes
  1679. ; complex use of an alpha channel the transformation is extremely lossy and the
  1680. ; result may look terrible.
  1681.  
  1682. ; To write a PNG file using the simplified API:
  1683.  
  1684. ; 1) Declare a 'png_image' structure on the stack and memset() it to all zero.
  1685. ; 2) Initialize the members of the structure that describe the image, setting
  1686. ;    the 'format' member to the format of the image samples.
  1687. ; 3) Call the appropriate png_image_write... function with a pointer to the
  1688. ;    image and, if necessary, the color-map to write the PNG data.
  1689.  
  1690. ; png_image is a structure that describes the in-memory format of an image
  1691. ; when it is being read or defines the in-memory format of an image that you
  1692. ; need to write:
  1693.  
  1694. ;#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) || \
  1695. ;    defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
  1696.  
  1697. PNG_IMAGE_VERSION equ 1
  1698.  
  1699. struct png_image
  1700.         opaque  dd ? ;png_controlp ;Initialize to NULL, free with png_image_free
  1701.         version dd ? ;uint_32  ;Set to PNG_IMAGE_VERSION
  1702.         width   dd ? ;uint_32  ;Image width in pixels (columns)
  1703.         height  dd ? ;uint_32  ;Image height in pixels (rows)
  1704.         format  dd ? ;uint_32  ;Image format as defined below
  1705.         flags   dd ? ;uint_32  ;A bit mask containing informational flags
  1706.         colormap_entries dd ? ;uint_32 ;Number of entries in the color-map
  1707.  
  1708.         ; In the event of an error or warning the following field will be set to a
  1709.         ; non-zero value and the 'message' field will contain a '\0' terminated
  1710.         ; string with the libpng error or warning message.  If both warnings and
  1711.         ; an error were encountered, only the error is recorded.  If there
  1712.         ; are multiple warnings, only the first one is recorded.
  1713.  
  1714.         ; The upper 30 bits of this value are reserved, the low two bits contain
  1715.         ; a value as follows:
  1716.  
  1717. PNG_IMAGE_WARNING equ 1
  1718. PNG_IMAGE_ERROR equ 2
  1719.  
  1720. ; The result is a two-bit code such that a value more than 1 indicates
  1721. ; a failure in the API just called:
  1722.  
  1723. ;    0 - no warning or error
  1724. ;    1 - warning
  1725. ;    2 - error
  1726. ;    3 - error preceded by warning
  1727.  
  1728. ;#  define PNG_IMAGE_FAILED(png_cntrl) ((((png_cntrl).warning_or_error)&0x03)>1)
  1729.  
  1730.         warning_or_error dd ? ;uint_32
  1731.         message rb 64 ;char[64]
  1732. ends
  1733.  
  1734. ; The samples of the image have one to four channels whose components have
  1735. ; original values in the range 0 to 1.0:
  1736.  
  1737. ; 1: A single gray or luminance channel (G).
  1738. ; 2: A gray/luminance channel and an alpha channel (GA).
  1739. ; 3: Three red, green, blue color channels (RGB).
  1740. ; 4: Three color channels and an alpha channel (RGBA).
  1741.  
  1742. ; The components are encoded in one of two ways:
  1743.  
  1744. ; a) As a small integer, value 0..255, contained in a single byte.  For the
  1745. ; alpha channel the original value is simply value/255.  For the color or
  1746. ; luminance channels the value is encoded according to the sRGB specification
  1747. ; and matches the 8-bit format expected by typical display devices.
  1748.  
  1749. ; The color/gray channels are not scaled (pre-multiplied) by the alpha
  1750. ; channel and are suitable for passing to color management software.
  1751.  
  1752. ; b) As a value in the range 0..65535, contained in a 2-byte integer.  All
  1753. ; channels can be converted to the original value by dividing by 65535; all
  1754. ; channels are linear.  Color channels use the RGB encoding (RGB end-points) of
  1755. ; the sRGB specification.  This encoding is identified by the
  1756. ; PNG_FORMAT_FLAG_LINEAR flag below.
  1757.  
  1758. ; When the simplified API needs to convert between sRGB and linear colorspaces,
  1759. ; the actual sRGB transfer curve defined in the sRGB specification (see the
  1760. ; article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
  1761. ; approximation used elsewhere in libpng.
  1762.  
  1763. ; When an alpha channel is present it is expected to denote pixel coverage
  1764. ; of the color or luminance channels and is returned as an associated alpha
  1765. ; channel: the color/gray channels are scaled (pre-multiplied) by the alpha
  1766. ; value.
  1767.  
  1768. ; The samples are either contained directly in the image data, between 1 and 8
  1769. ; bytes per pixel according to the encoding, or are held in a color-map indexed
  1770. ; by bytes in the image data.  In the case of a color-map the color-map entries
  1771. ; are individual samples, encoded as above, and the image data has one byte per
  1772. ; pixel to select the relevant sample from the color-map.
  1773.  
  1774.  
  1775. ; PNG_FORMAT_*
  1776.  
  1777. ; #defines to be used in png_image::format.  Each #define identifies a
  1778. ; particular layout of sample data and, if present, alpha values.  There are
  1779. ; separate defines for each of the two component encodings.
  1780.  
  1781. ; A format is built up using single bit flag values.  All combinations are
  1782. ; valid.  Formats can be built up from the flag values or you can use one of
  1783. ; the predefined values below.  When testing formats always use the FORMAT_FLAG
  1784. ; macros to test for individual features - future versions of the library may
  1785. ; add new flags.
  1786.  
  1787. ; When reading or writing color-mapped images the format should be set to the
  1788. ; format of the entries in the color-map then png_image_{read,write}_colormap
  1789. ; called to read or write the color-map and set the format correctly for the
  1790. ; image data.  Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly!
  1791.  
  1792. ; NOTE: libpng can be built with particular features disabled. If you see
  1793. ; compiler errors because the definition of one of the following flags has been
  1794. ; compiled out it is because libpng does not have the required support.  It is
  1795. ; possible, however, for the libpng configuration to enable the format on just
  1796. ; read or just write; in that case you may see an error at run time.  You can
  1797. ; guard against this by checking for the definition of the appropriate
  1798. ; "_SUPPORTED" macro, one of:
  1799.  
  1800. ;    PNG_SIMPLIFIED_{READ,WRITE}_{BGR,AFIRST}_SUPPORTED
  1801.  
  1802. PNG_FORMAT_FLAG_ALPHA    equ 0x01 ;format with an alpha channel
  1803. PNG_FORMAT_FLAG_COLOR    equ 0x02 ;color format: otherwise grayscale
  1804. PNG_FORMAT_FLAG_LINEAR   equ 0x04 ;2-byte channels else 1-byte
  1805. PNG_FORMAT_FLAG_COLORMAP equ 0x08 ;image data is color-mapped
  1806.  
  1807. ;if PNG_FORMAT_BGR_SUPPORTED
  1808. PNG_FORMAT_FLAG_BGR   equ 0x10 ;BGR colors, else order is RGB
  1809. ;end if
  1810.  
  1811. ;if PNG_FORMAT_AFIRST_SUPPORTED
  1812. PNG_FORMAT_FLAG_AFIRST equ 0x20 ;alpha channel comes first
  1813. ;end if
  1814.  
  1815. ; Commonly used formats have predefined macros.
  1816.  
  1817. ; First the single byte (sRGB) formats:
  1818.  
  1819. PNG_FORMAT_GRAY equ 0
  1820. PNG_FORMAT_GA  equ PNG_FORMAT_FLAG_ALPHA
  1821. PNG_FORMAT_AG  equ (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST)
  1822. PNG_FORMAT_RGB equ PNG_FORMAT_FLAG_COLOR
  1823. PNG_FORMAT_BGR equ (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR)
  1824. PNG_FORMAT_RGBA equ (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA)
  1825. PNG_FORMAT_ARGB equ (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST)
  1826. PNG_FORMAT_BGRA equ (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA)
  1827. PNG_FORMAT_ABGR equ (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST)
  1828.  
  1829. ; Then the linear 2-byte formats.  When naming these "Y" is used to
  1830. ; indicate a luminance (gray) channel.
  1831.  
  1832. PNG_FORMAT_LINEAR_Y equ PNG_FORMAT_FLAG_LINEAR
  1833. PNG_FORMAT_LINEAR_Y_ALPHA equ (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA)
  1834. PNG_FORMAT_LINEAR_RGB equ (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR)
  1835. PNG_FORMAT_LINEAR_RGB_ALPHA equ\
  1836.         (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA)
  1837.  
  1838. ; With color-mapped formats the image data is one byte for each pixel, the byte
  1839. ; is an index into the color-map which is formatted as above.  To obtain a
  1840. ; color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP
  1841. ; to one of the above definitions, or you can use one of the definitions below.
  1842.  
  1843. PNG_FORMAT_RGB_COLORMAP equ (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP)
  1844. PNG_FORMAT_BGR_COLORMAP equ (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP)
  1845. PNG_FORMAT_RGBA_COLORMAP equ (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP)
  1846. PNG_FORMAT_ARGB_COLORMAP equ (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP)
  1847. PNG_FORMAT_BGRA_COLORMAP equ (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP)
  1848. PNG_FORMAT_ABGR_COLORMAP equ (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP)
  1849.  
  1850. ; PNG_IMAGE macros
  1851.  
  1852. ; These are convenience macros to derive information from a png_image
  1853. ; structure.  The PNG_IMAGE_SAMPLE_ macros return values appropriate to the
  1854. ; actual image sample values - either the entries in the color-map or the
  1855. ; pixels in the image.  The PNG_IMAGE_PIXEL_ macros return corresponding values
  1856. ; for the pixels and will always return 1 for color-mapped formats.  The
  1857. ; remaining macros return information about the rows in the image and the
  1858. ; complete image.
  1859.  
  1860. ; NOTE: All the macros that take a png_image::format parameter are compile time
  1861. ; constants if the format parameter is, itself, a constant.  Therefore these
  1862. ; macros can be used in array declarations and case labels where required.
  1863. ; Similarly the macros are also pre-processor constants (sizeof is not used) so
  1864. ; they can be used in #if tests.
  1865.  
  1866. ; First the information about the samples.
  1867.  
  1868. macro PNG_IMAGE_SAMPLE_CHANNELS fmt
  1869. {
  1870.         mov eax,fmt
  1871.         and eax,PNG_FORMAT_FLAG_COLOR or PNG_FORMAT_FLAG_ALPHA
  1872.         inc eax
  1873. }
  1874. ; Return the total number of channels in a given format: 1..4
  1875.  
  1876. ;#define PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)\
  1877. ;   ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1)
  1878. ;   /* Return the size in bytes of a single component of a pixel or color-map
  1879. ; entry (as appropriate) in the image: 1 or 2.
  1880.  
  1881.  
  1882. ;#define PNG_IMAGE_SAMPLE_SIZE(fmt)\
  1883. ;   (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt))
  1884. ;   /* This is the size of the sample data for one sample.  If the image is
  1885. ; color-mapped it is the size of one color-map entry (and image pixels are
  1886. ; one byte in size), otherwise it is the size of one image pixel.
  1887.  
  1888.  
  1889. ;#define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)\
  1890. ;   (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256)
  1891. ;   /* The maximum size of the color-map required by the format expressed in a
  1892. ; count of components.  This can be used to compile-time allocate a
  1893. ; color-map:
  1894.  
  1895. ; uint_16 colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(linear_fmt)];
  1896.  
  1897. ; byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)];
  1898.  
  1899. ; Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the
  1900. ; information from one of the png_image_begin_read_ APIs and dynamically
  1901. ; allocate the required memory.
  1902.  
  1903.  
  1904. ; Corresponding information about the pixels
  1905. macro PNG_IMAGE_PIXEL_ p1,fmt
  1906. {
  1907. local .end0
  1908. local .end1
  1909.         mov eax,fmt
  1910.         and eax,PNG_FORMAT_FLAG_COLORMAP
  1911.         cmp eax,0
  1912.         je .end0
  1913.                 xor eax,eax
  1914.                 inc eax
  1915.                 jmp .end1
  1916.         .end0:
  1917.                 p1 fmt
  1918.         .end1:
  1919. }
  1920.  
  1921. macro PNG_IMAGE_PIXEL_CHANNELS fmt
  1922. {
  1923.         PNG_IMAGE_PIXEL_ PNG_IMAGE_SAMPLE_CHANNELS,fmt
  1924. }
  1925. ; The number of separate channels (components) in a pixel; 1 for a
  1926. ; color-mapped image.
  1927.  
  1928.  
  1929. ;#define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\
  1930. ;   PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt)
  1931. ;   /* The size, in bytes, of each component in a pixel; 1 for a color-mapped
  1932. ; image.
  1933.  
  1934.  
  1935. ;#define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt)
  1936. ;   /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */
  1937.  
  1938. ; Information about the whole row, or whole image
  1939. ;#define PNG_IMAGE_ROW_STRIDE(image)\
  1940. ;   (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width)
  1941. ; Return the total number of components in a single row of the image; this
  1942. ; is the minimum 'row stride', the minimum count of components between each
  1943. ; row.  For a color-mapped image this is the minimum number of bytes in a
  1944. ; row.
  1945.  
  1946. ; WARNING: this macro overflows for some images with more than one component
  1947. ; and very large image widths.  libpng will refuse to process an image where
  1948. ; this macro would overflow.
  1949.  
  1950.  
  1951. ;#define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\
  1952. ;   (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride))
  1953. ; Return the size, in bytes, of an image buffer given a png_image and a row
  1954. ; stride - the number of components to leave space for in each row.
  1955.  
  1956. ; WARNING: this macro overflows a 32-bit integer for some large PNG images,
  1957. ; libpng will refuse to process an image where such an overflow would occur.
  1958.  
  1959.  
  1960. ;#define PNG_IMAGE_SIZE(image)\
  1961. ;   PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image))
  1962. ; Return the size, in bytes, of the image in memory given just a png_image;
  1963. ; the row stride is the minimum stride required for the image.
  1964.  
  1965.  
  1966. ;#define PNG_IMAGE_COLORMAP_SIZE(image)\
  1967. ;   (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries)
  1968. ; Return the size, in bytes, of the color-map of this image.  If the image
  1969. ; format is not a color-map format this will return a size sufficient for
  1970. ; 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if
  1971. ; you don't want to allocate a color-map in this case.
  1972.  
  1973.  
  1974. ; PNG_IMAGE_FLAG_*
  1975.  
  1976. ; Flags containing additional information about the image are held in the
  1977. ; 'flags' field of png_image.
  1978.  
  1979. PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB equ 0x01
  1980. ; This indicates the the RGB values of the in-memory bitmap do not
  1981. ; correspond to the red, green and blue end-points defined by sRGB.
  1982.  
  1983. PNG_IMAGE_FLAG_FAST equ 0x02
  1984. ; On write emphasise speed over compression; the resultant PNG file will be
  1985. ; larger but will be produced significantly faster, particular for large
  1986. ; images.  Do not use this option for images which will be distributed, only
  1987. ; used it when producing intermediate files that will be read back in
  1988. ; repeatedly.  For a typical 24-bit image the option will double the read
  1989. ; speed at the cost of increasing the image size by 25%, however for many
  1990. ; more compressible images the PNG file can be 10 times larger with only a
  1991. ; slight speed gain.
  1992.  
  1993. PNG_IMAGE_FLAG_16BIT_sRGB equ 0x04
  1994. ; On read if the image is a 16-bit per component image and there is no gAMA
  1995. ; or sRGB chunk assume that the components are sRGB encoded.  Notice that
  1996. ; images output by the simplified API always have gamma information; setting
  1997. ; this flag only affects the interpretation of 16-bit images from an
  1998. ; external source.  It is recommended that the application expose this flag
  1999. ; to the user; the user can normally easily recognize the difference between
  2000. ; linear and sRGB encoding.  This flag has no effect on write - the data
  2001. ; passed to the write APIs must have the correct encoding (as defined
  2002. ; above.)
  2003.  
  2004. ; If the flag is not set (the default) input 16-bit per component data is
  2005. ; assumed to be linear.
  2006.  
  2007. ; NOTE: the flag can only be set after the png_image_begin_read_ call,
  2008. ; because that call initializes the 'flags' field.
  2009.  
  2010.  
  2011. ;if PNG_SIMPLIFIED_READ_SUPPORTED
  2012. ; READ APIs
  2013. ; ---------
  2014.  
  2015. ; The png_image passed to the read APIs must have been initialized by setting
  2016. ; the png_controlp field 'opaque' to NULL (or, safer, memset the whole thing.)
  2017.  
  2018. if PNG_STDIO_SUPPORTED eq 1
  2019. PNG_EXPORT 234, int, png_image_begin_read_from_file, '(png_imagep image, const char *file_name)'
  2020. ; The named file is opened for read and the image header is filled in
  2021. ; from the PNG header in the file.
  2022.  
  2023. PNG_EXPORT 235, int, png_image_begin_read_from_stdio, '(png_imagep image, FILE* file)'
  2024. ; The PNG header is read from the stdio FILE object.
  2025. end if ;STDIO
  2026.  
  2027. PNG_EXPORT 236, int, png_image_begin_read_from_memory, '(png_imagep image, png_const_voidp memory, png_size_t size)'
  2028. ; The PNG header is read from the given memory buffer.
  2029.  
  2030. PNG_EXPORT 237, int, png_image_finish_read, '(png_imagep image, png_const_colorp background, void *buffer, int_32 row_stride, void *colormap)'
  2031. ; Finish reading the image into the supplied buffer and clean up the
  2032. ; png_image structure.
  2033.  
  2034. ; row_stride is the step, in byte or 2-byte units as appropriate,
  2035. ; between adjacent rows.  A positive stride indicates that the top-most row
  2036. ; is first in the buffer - the normal top-down arrangement.  A negative
  2037. ; stride indicates that the bottom-most row is first in the buffer.
  2038.  
  2039. ; background need only be supplied if an alpha channel must be removed from
  2040. ; a byte format and the removal is to be done by compositing on a solid
  2041. ; color; otherwise it may be NULL and any composition will be done directly
  2042. ; onto the buffer.  The value is an sRGB color to use for the background,
  2043. ; for grayscale output the green channel is used.
  2044.  
  2045. ; background must be supplied when an alpha channel must be removed from a
  2046. ; single byte color-mapped output format, in other words if:
  2047.  
  2048. ; 1) The original format from png_image_begin_read_from_* had
  2049. ;    PNG_FORMAT_FLAG_ALPHA set.
  2050. ; 2) The format set by the application does not.
  2051. ; 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and
  2052. ;    PNG_FORMAT_FLAG_LINEAR *not* set.
  2053.  
  2054. ; For linear output removing the alpha channel is always done by compositing
  2055. ; on black and background is ignored.
  2056.  
  2057. ; colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set.  It must
  2058. ; be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE.
  2059. ; image->colormap_entries will be updated to the actual number of entries
  2060. ; written to the colormap; this may be less than the original value.
  2061.  
  2062.  
  2063. ;end if /* SIMPLIFIED_READ */
  2064.  
  2065. ;if PNG_SIMPLIFIED_WRITE_SUPPORTED
  2066. ;/* WRITE APIS
  2067. ; ----------
  2068. ; For write you must initialize a png_image structure to describe the image to
  2069. ; be written.  To do this use memset to set the whole structure to 0 then
  2070. ; initialize fields describing your image.
  2071.  
  2072. ; version: must be set to PNG_IMAGE_VERSION
  2073. ; opaque: must be initialized to NULL
  2074. ; width: image width in pixels
  2075. ; height: image height in rows
  2076. ; format: the format of the data (image and color-map) you wish to write
  2077. ; flags: set to 0 unless one of the defined flags applies; set
  2078. ;    PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB
  2079. ;    values do not correspond to the colors in sRGB.
  2080. ; colormap_entries: set to the number of entries in the color-map (0 to 256)
  2081.  
  2082. ; With all write APIs if image is in one of the linear formats with 16-bit
  2083. ; data then setting convert_to_8_bit will cause the output to be an 8-bit PNG
  2084. ; gamma encoded according to the sRGB specification, otherwise a 16-bit linear
  2085. ; encoded PNG file is written.
  2086.  
  2087. ; With color-mapped data formats the colormap parameter point to a color-map
  2088. ; with at least image->colormap_entries encoded in the specified format.  If
  2089. ; the format is linear the written PNG color-map will be converted to sRGB
  2090. ; regardless of the convert_to_8_bit flag.
  2091.  
  2092. ; With all APIs row_stride is handled as in the read APIs - it is the spacing
  2093. ; from one row to the next in component sized units (1 or 2 bytes) and if
  2094. ; negative indicates a bottom-up row layout in the buffer.  If row_stride is
  2095. ; zero, libpng will calculate it for you from the image width and number of
  2096. ; channels.
  2097.  
  2098. ; Note that the write API does not support interlacing, sub-8-bit pixels or
  2099. ; most ancillary chunks.  If you need to write text chunks (e.g. for copyright
  2100. ; notices) you need to use one of the other APIs.
  2101.  
  2102.  
  2103. ;#define png_image_write_get_memory_size(image, size, convert_to_8_bit, buffer,\
  2104. ;   row_stride, colormap)\
  2105. ;   png_image_write_to_memory(&(image), 0, &(size), convert_to_8_bit, buffer,\
  2106. ;         row_stride, colormap)
  2107. ; Return the amount of memory in 'size' required to compress this image.
  2108. ; The png_image structure 'image' must be filled in as in the above
  2109. ; function and must not be changed before the actual write call, the buffer
  2110. ; and all other parameters must also be identical to that in the final
  2111. ; write call.  The 'size' variable need not be initialized.
  2112.  
  2113. ; NOTE: the macro returns true/false, if false is returned 'size' will be
  2114. ; set to zero and the write failed and probably will fail if tried again.
  2115.  
  2116. ; You can pre-allocate the buffer by making sure it is of sufficient size
  2117. ; regardless of the amount of compression achieved.  The buffer size will
  2118. ; always be bigger than the original image and it will never be filled.  The
  2119. ; following macros are provided to assist in allocating the buffer.
  2120.  
  2121. ;#define PNG_IMAGE_DATA_SIZE(image) (PNG_IMAGE_SIZE(image)+(image).height)
  2122. ; The number of uncompressed bytes in the PNG byte encoding of the image;
  2123. ; uncompressing the PNG IDAT data will give this number of bytes.
  2124.  
  2125. ; NOTE: while PNG_IMAGE_SIZE cannot overflow for an image in memory this
  2126. ; macro can because of the extra bytes used in the PNG byte encoding.  You
  2127. ; need to avoid this macro if your image size approaches 2^30 in width or
  2128. ; height.  The same goes for the remainder of these macros; they all produce
  2129. ; bigger numbers than the actual in-memory image size.
  2130.  
  2131. ;#ifndef PNG_ZLIB_MAX_SIZE
  2132. ;#  define PNG_ZLIB_MAX_SIZE(b) ((b)+(((b)+7U)>>3)+(((b)+63U)>>6)+11U)
  2133. ; An upper bound on the number of compressed bytes given 'b' uncompressed
  2134. ; bytes.  This is based on deflateBounds() in zlib; different
  2135. ; implementations of zlib compression may conceivably produce more data so
  2136. ; if your zlib implementation is not zlib itself redefine this macro
  2137. ; appropriately.
  2138.  
  2139. ;end if
  2140.  
  2141. ;#define PNG_IMAGE_COMPRESSED_SIZE_MAX(image)\
  2142. ;   PNG_ZLIB_MAX_SIZE((png_alloc_size_t)PNG_IMAGE_DATA_SIZE(image))
  2143. ;   /* An upper bound on the size of the data in the PNG IDAT chunks. */
  2144. ;
  2145. ;#define PNG_IMAGE_PNG_SIZE_MAX_(image, image_size)\
  2146. ;   ((8U/*sig*/+25U/*IHDR*/+16U/*gAMA*/+44U/*cHRM*/+12U/*IEND*/+\
  2147. ;    (((image).format&PNG_FORMAT_FLAG_COLORMAP)?/*colormap: PLTE, tRNS*/\
  2148. ;    12U+3U*(image).colormap_entries/*PLTE data*/+\
  2149. ;    (((image).format&PNG_FORMAT_FLAG_ALPHA)?\
  2150. ;    12U/*tRNS*/+(image).colormap_entries:0U):0U)+\
  2151. ;    12U)+(12U*((image_size)/PNG_ZBUF_SIZE))/*IDAT*/+(image_size))
  2152. ;   /* A helper for the following macro; if your compiler cannot handle the
  2153. ; following macro use this one with the result of
  2154. ; PNG_IMAGE_COMPRESSED_SIZE_MAX(image) as the second argument (most
  2155. ; compilers should handle this just fine.)
  2156.  
  2157.  
  2158. ;#define PNG_IMAGE_PNG_SIZE_MAX(image)\
  2159. ;   PNG_IMAGE_PNG_SIZE_MAX_(image, PNG_IMAGE_COMPRESSED_SIZE_MAX(image))
  2160. ; An upper bound on the total length of the PNG data stream for 'image'.
  2161. ; The result is of type png_alloc_size_t, on 32-bit systems this may
  2162. ; overflow even though PNG_IMAGE_DATA_SIZE does not overflow; the write will
  2163. ; run out of buffer space but return a corrected size which should work.
  2164.  
  2165. ;end if /* SIMPLIFIED_WRITE */
  2166. ;/*******************************************************************************
  2167. ;  END OF SIMPLIFIED API
  2168. ; ******************************************************************************/
  2169. ;end if /* SIMPLIFIED_{READ|WRITE} */
  2170.  
  2171. ;/*******************************************************************************
  2172. ; Section 6: IMPLEMENTATION OPTIONS
  2173. ; *******************************************************************************
  2174.  
  2175. ; Support for arbitrary implementation-specific optimizations.  The API allows
  2176. ; particular options to be turned on or off.  'Option' is the number of the
  2177. ; option and 'onoff' is 0 (off) or non-0 (on).  The value returned is given
  2178. ; by the PNG_OPTION_ defines below.
  2179.  
  2180. ; HARDWARE: normally hardware capabilites, such as the Intel SSE instructions,
  2181. ;           are detected at run time, however sometimes it may be impossible
  2182. ;           to do this in user mode, in which case it is necessary to discover
  2183. ;           the capabilities in an OS specific way.  Such capabilities are
  2184. ;           listed here when libpng has support for them and must be turned
  2185. ;           ON by the application if present.
  2186.  
  2187. ; SOFTWARE: sometimes software optimizations actually result in performance
  2188. ;           decrease on some architectures or systems, or with some sets of
  2189. ;           PNG images.  'Software' options allow such optimizations to be
  2190. ;           selected at run time.
  2191.  
  2192. if PNG_SET_OPTION_SUPPORTED eq 1
  2193. if PNG_ARM_NEON_API_SUPPORTED eq 1
  2194.         PNG_ARM_NEON  equ 0 ;HARDWARE: ARM Neon SIMD instructions supported
  2195. end if
  2196. PNG_MAXIMUM_INFLATE_WINDOW equ 2 ;SOFTWARE: force maximum window
  2197. PNG_SKIP_sRGB_CHECK_PROFILE equ 4 ;SOFTWARE: Check ICC profile for sRGB
  2198. if PNG_MIPS_MSA_API_SUPPORTED eq 1
  2199.         PNG_MIPS_MSA  equ 6 ;HARDWARE: MIPS Msa SIMD instructions supported
  2200. end if
  2201. PNG_OPTION_NEXT equ 8 ;Next option - numbers must be even
  2202.  
  2203. ; Return values: NOTE: there are four values and 'off' is *not* zero
  2204. PNG_OPTION_UNSET  equ 0 ;Unset - defaults to off
  2205. PNG_OPTION_INVALID equ 1 ;Option number out of range
  2206. PNG_OPTION_OFF    equ 2
  2207. PNG_OPTION_ON     equ 3
  2208. end if ;SET_OPTION
  2209.  
  2210. ;/*******************************************************************************
  2211. ;  END OF HARDWARE AND SOFTWARE OPTIONS
  2212. ; ******************************************************************************/
  2213.  
  2214. ; Maintainer: Put new public prototypes here ^, in libpng.3, in project
  2215. ; defs, and in scripts/symbols.def.
  2216.  
  2217.  
  2218. ; The last ordinal number (this is the *last* one already used; the next
  2219. ; one to use is one more than this.)
  2220.  
  2221. ;end if /* PNG_VERSION_INFO_ONLY */
  2222. ; Do not put anything past this line
  2223.