png.h 107 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586
  1. /* png.h - header file for PNG reference library
  2. *
  3. * libpng version 1.5.26, December 17, 2015
  4. *
  5. * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
  6. * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  7. * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  8. *
  9. * This code is released under the libpng license (See LICENSE, below)
  10. *
  11. * Authors and maintainers:
  12. * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
  13. * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
  14. * libpng versions 0.97, January 1998, through 1.5.26, December 17, 2015:
  15. * Glenn Randers-Pehrson.
  16. * See also "Contributing Authors", below.
  17. */
  18. /*
  19. * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
  20. *
  21. * If you modify libpng you may insert additional notices immediately following
  22. * this sentence.
  23. *
  24. * This code is released under the libpng license.
  25. *
  26. * libpng versions 1.0.7, July 1, 2000, through 1.5.26, December 17, 2015, are
  27. * Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, are
  28. * derived from libpng-1.0.6, and are distributed according to the same
  29. * disclaimer and license as libpng-1.0.6 with the following individuals
  30. * added to the list of Contributing Authors:
  31. *
  32. * Simon-Pierre Cadieux
  33. * Eric S. Raymond
  34. * Mans Rullgard
  35. * Cosmin Truta
  36. * Gilles Vollant
  37. *
  38. * and with the following additions to the disclaimer:
  39. *
  40. * There is no warranty against interference with your enjoyment of the
  41. * library or against infringement. There is no warranty that our
  42. * efforts or the library will fulfill any of your particular purposes
  43. * or needs. This library is provided with all faults, and the entire
  44. * risk of satisfactory quality, performance, accuracy, and effort is with
  45. * the user.
  46. *
  47. * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
  48. * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
  49. * libpng-0.96, and are distributed according to the same disclaimer and
  50. * license as libpng-0.96, with the following individuals added to the list
  51. * of Contributing Authors:
  52. *
  53. * Tom Lane
  54. * Glenn Randers-Pehrson
  55. * Willem van Schaik
  56. *
  57. * libpng versions 0.89, June 1996, through 0.96, May 1997, are
  58. * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
  59. * and are distributed according to the same disclaimer and license as
  60. * libpng-0.88, with the following individuals added to the list of
  61. * Contributing Authors:
  62. *
  63. * John Bowler
  64. * Kevin Bracey
  65. * Sam Bushell
  66. * Magnus Holmgren
  67. * Greg Roelofs
  68. * Tom Tanner
  69. *
  70. * libpng versions 0.5, May 1995, through 0.88, January 1996, are
  71. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  72. *
  73. * For the purposes of this copyright and license, "Contributing Authors"
  74. * is defined as the following set of individuals:
  75. *
  76. * Andreas Dilger
  77. * Dave Martindale
  78. * Guy Eric Schalnat
  79. * Paul Schmidt
  80. * Tim Wegner
  81. *
  82. * The PNG Reference Library is supplied "AS IS". The Contributing Authors
  83. * and Group 42, Inc. disclaim all warranties, expressed or implied,
  84. * including, without limitation, the warranties of merchantability and of
  85. * fitness for any purpose. The Contributing Authors and Group 42, Inc.
  86. * assume no liability for direct, indirect, incidental, special, exemplary,
  87. * or consequential damages, which may result from the use of the PNG
  88. * Reference Library, even if advised of the possibility of such damage.
  89. *
  90. * Permission is hereby granted to use, copy, modify, and distribute this
  91. * source code, or portions hereof, for any purpose, without fee, subject
  92. * to the following restrictions:
  93. *
  94. * 1. The origin of this source code must not be misrepresented.
  95. *
  96. * 2. Altered versions must be plainly marked as such and must not
  97. * be misrepresented as being the original source.
  98. *
  99. * 3. This Copyright notice may not be removed or altered from any
  100. * source or altered source distribution.
  101. *
  102. * The Contributing Authors and Group 42, Inc. specifically permit, without
  103. * fee, and encourage the use of this source code as a component to
  104. * supporting the PNG file format in commercial products. If you use this
  105. * source code in a product, acknowledgment is not required but would be
  106. * appreciated.
  107. *
  108. * END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
  109. */
  110. /*
  111. * A "png_get_copyright" function is available, for convenient use in "about"
  112. * boxes and the like:
  113. *
  114. * printf("%s", png_get_copyright(NULL));
  115. *
  116. * Also, the PNG logo (in PNG format, of course) is supplied in the
  117. * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
  118. */
  119. /*
  120. * Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
  121. * a certification mark of the Open Source Initiative. OSI has not addressed
  122. * the additional disclaimers inserted at version 1.0.7.
  123. */
  124. /*
  125. * The contributing authors would like to thank all those who helped
  126. * with testing, bug fixes, and patience. This wouldn't have been
  127. * possible without all of you.
  128. *
  129. * Thanks to Frank J. T. Wojcik for helping with the documentation.
  130. */
  131. /* Note about libpng version numbers:
  132. *
  133. * Due to various miscommunications, unforeseen code incompatibilities
  134. * and occasional factors outside the authors' control, version numbering
  135. * on the library has not always been consistent and straightforward.
  136. * The following table summarizes matters since version 0.89c, which was
  137. * the first widely used release:
  138. *
  139. * source png.h png.h shared-lib
  140. * version string int version
  141. * ------- ------ ----- ----------
  142. * 0.89c "1.0 beta 3" 0.89 89 1.0.89
  143. * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90]
  144. * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95]
  145. * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96]
  146. * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97]
  147. * 0.97c 0.97 97 2.0.97
  148. * 0.98 0.98 98 2.0.98
  149. * 0.99 0.99 98 2.0.99
  150. * 0.99a-m 0.99 99 2.0.99
  151. * 1.00 1.00 100 2.1.0 [100 should be 10000]
  152. * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000]
  153. * 1.0.1 png.h string is 10001 2.1.0
  154. * 1.0.1a-e identical to the 10002 from here on, the shared library
  155. * 1.0.2 source version) 10002 is 2.V where V is the source code
  156. * 1.0.2a-b 10003 version, except as noted.
  157. * 1.0.3 10003
  158. * 1.0.3a-d 10004
  159. * 1.0.4 10004
  160. * 1.0.4a-f 10005
  161. * 1.0.5 (+ 2 patches) 10005
  162. * 1.0.5a-d 10006
  163. * 1.0.5e-r 10100 (not source compatible)
  164. * 1.0.5s-v 10006 (not binary compatible)
  165. * 1.0.6 (+ 3 patches) 10006 (still binary incompatible)
  166. * 1.0.6d-f 10007 (still binary incompatible)
  167. * 1.0.6g 10007
  168. * 1.0.6h 10007 10.6h (testing xy.z so-numbering)
  169. * 1.0.6i 10007 10.6i
  170. * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0)
  171. * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible)
  172. * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible)
  173. * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible)
  174. * 1.0.7 1 10007 (still compatible)
  175. * ...
  176. * 1.0.19 10 10019 10.so.0.19[.0]
  177. * ...
  178. * 1.2.53 13 10253 12.so.0.53[.0]
  179. * ...
  180. * 1.5.25 15 10525 15.so.15.25[.0]
  181. *
  182. * Henceforth the source version will match the shared-library major
  183. * and minor numbers; the shared-library major version number will be
  184. * used for changes in backward compatibility, as it is intended. The
  185. * PNG_LIBPNG_VER macro, which is not used within libpng but is available
  186. * for applications, is an unsigned integer of the form xyyzz corresponding
  187. * to the source version x.y.z (leading zeros in y and z). Beta versions
  188. * were given the previous public release number plus a letter, until
  189. * version 1.0.6j; from then on they were given the upcoming public
  190. * release number plus "betaNN" or "rcNN".
  191. *
  192. * Binary incompatibility exists only when applications make direct access
  193. * to the info_ptr or png_ptr members through png.h, and the compiled
  194. * application is loaded with a different version of the library.
  195. *
  196. * DLLNUM will change each time there are forward or backward changes
  197. * in binary compatibility (e.g., when a new feature is added).
  198. *
  199. * See libpng.txt or libpng.3 for more information. The PNG specification
  200. * is available as a W3C Recommendation and as an ISO Specification,
  201. * <http://www.w3.org/TR/2003/REC-PNG-20031110/
  202. */
  203. /*
  204. * Y2K compliance in libpng:
  205. * =========================
  206. *
  207. * December 17, 2015
  208. *
  209. * Since the PNG Development group is an ad-hoc body, we can't make
  210. * an official declaration.
  211. *
  212. * This is your unofficial assurance that libpng from version 0.71 and
  213. * upward through 1.5.26 are Y2K compliant. It is my belief that
  214. * earlier versions were also Y2K compliant.
  215. *
  216. * Libpng only has two year fields. One is a 2-byte unsigned integer
  217. * that will hold years up to 65535. The other holds the date in text
  218. * format, and will hold years up to 9999.
  219. *
  220. * The integer is
  221. * "png_uint_16 year" in png_time_struct.
  222. *
  223. * The string is
  224. * "char time_buffer[29]" in png_struct. This will be no
  225. * longer used in libpng-1.6.0 and will be removed from libpng-1.7.0.
  226. *
  227. * There are seven time-related functions:
  228. * png.c: png_convert_to_rfc_1123() in png.c
  229. * (formerly png_convert_to_rfc_1152() in error)
  230. * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
  231. * png_convert_from_time_t() in pngwrite.c
  232. * png_get_tIME() in pngget.c
  233. * png_handle_tIME() in pngrutil.c, called in pngread.c
  234. * png_set_tIME() in pngset.c
  235. * png_write_tIME() in pngwutil.c, called in pngwrite.c
  236. *
  237. * All handle dates properly in a Y2K environment. The
  238. * png_convert_from_time_t() function calls gmtime() to convert from system
  239. * clock time, which returns (year - 1900), which we properly convert to
  240. * the full 4-digit year. There is a possibility that applications using
  241. * libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
  242. * function, or that they are incorrectly passing only a 2-digit year
  243. * instead of "year - 1900" into the png_convert_from_struct_tm() function,
  244. * but this is not under our control. The libpng documentation has always
  245. * stated that it works with 4-digit years, and the APIs have been
  246. * documented as such.
  247. *
  248. * The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
  249. * integer to hold the year, and can hold years as large as 65535.
  250. *
  251. * zlib, upon which libpng depends, is also Y2K compliant. It contains
  252. * no date-related code.
  253. *
  254. * Glenn Randers-Pehrson
  255. * libpng maintainer
  256. * PNG Development Group
  257. */
  258. #ifndef PNG_H
  259. #define PNG_H
  260. /* This is not the place to learn how to use libpng. The file libpng-manual.txt
  261. * describes how to use libpng, and the file example.c summarizes it
  262. * with some code on which to build. This file is useful for looking
  263. * at the actual function definitions and structure components. If that
  264. * file has been stripped from your copy of libpng, you can find it at
  265. * <http://www.libpng.org/pub/png/libpng-manual.txt>
  266. *
  267. * If you just need to read a PNG file and don't want to read the documentation
  268. * skip to the end of this file and read the section entitled 'simplified API'.
  269. */
  270. /* Version information for png.h - this should match the version in png.c */
  271. #define PNG_LIBPNG_VER_STRING "1.5.26"
  272. #define PNG_HEADER_VERSION_STRING \
  273. " libpng version 1.5.26 - December 17, 2015\n"
  274. #define PNG_LIBPNG_VER_SONUM 15
  275. #define PNG_LIBPNG_VER_DLLNUM 15
  276. /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
  277. #define PNG_LIBPNG_VER_MAJOR 1
  278. #define PNG_LIBPNG_VER_MINOR 5
  279. #define PNG_LIBPNG_VER_RELEASE 26
  280. /* This should match the numeric part of the final component of
  281. * PNG_LIBPNG_VER_STRING, omitting any leading zero:
  282. */
  283. #define PNG_LIBPNG_VER_BUILD 0
  284. /* Release Status */
  285. #define PNG_LIBPNG_BUILD_ALPHA 1
  286. #define PNG_LIBPNG_BUILD_BETA 2
  287. #define PNG_LIBPNG_BUILD_RC 3
  288. #define PNG_LIBPNG_BUILD_STABLE 4
  289. #define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7
  290. /* Release-Specific Flags */
  291. #define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with
  292. PNG_LIBPNG_BUILD_STABLE only */
  293. #define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with
  294. PNG_LIBPNG_BUILD_SPECIAL */
  295. #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
  296. PNG_LIBPNG_BUILD_PRIVATE */
  297. #define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
  298. /* Careful here. At one time, Guy wanted to use 082, but that would be octal.
  299. * We must not include leading zeros.
  300. * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
  301. * version 1.0.0 was mis-numbered 100 instead of 10000). From
  302. * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
  303. */
  304. #define PNG_LIBPNG_VER 10526 /* 1.5.26 */
  305. /* Library configuration: these options cannot be changed after
  306. * the library has been built.
  307. */
  308. #ifndef PNGLCONF_H
  309. /* If pnglibconf.h is missing, you can
  310. * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h
  311. */
  312. # include "pnglibconf.h"
  313. #endif
  314. #ifndef PNG_VERSION_INFO_ONLY
  315. # ifndef PNG_BUILDING_SYMBOL_TABLE
  316. /*
  317. * Standard header files (not needed for the version info or while
  318. * building symbol table -- see scripts/pnglibconf.dfa)
  319. */
  320. # ifdef PNG_SETJMP_SUPPORTED
  321. # include <setjmp.h>
  322. # endif
  323. /* Need the time information for converting tIME chunks, it
  324. * defines struct tm:
  325. */
  326. # ifdef PNG_CONVERT_tIME_SUPPORTED
  327. /* "time.h" functions are not supported on all operating systems */
  328. # include <time.h>
  329. # endif
  330. # endif
  331. /* Machine specific configuration. */
  332. # include "pngconf.h"
  333. #endif /* PNG_VERSION_INFO_ONLY */
  334. /*
  335. * Added at libpng-1.2.8
  336. *
  337. * Ref MSDN: Private as priority over Special
  338. * VS_FF_PRIVATEBUILD File *was not* built using standard release
  339. * procedures. If this value is given, the StringFileInfo block must
  340. * contain a PrivateBuild string.
  341. *
  342. * VS_FF_SPECIALBUILD File *was* built by the original company using
  343. * standard release procedures but is a variation of the standard
  344. * file of the same version number. If this value is given, the
  345. * StringFileInfo block must contain a SpecialBuild string.
  346. */
  347. #ifdef PNG_USER_PRIVATEBUILD /* From pnglibconf.h */
  348. # define PNG_LIBPNG_BUILD_TYPE \
  349. (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE)
  350. #else
  351. # ifdef PNG_LIBPNG_SPECIALBUILD
  352. # define PNG_LIBPNG_BUILD_TYPE \
  353. (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL)
  354. # else
  355. # define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE)
  356. # endif
  357. #endif
  358. #ifndef PNG_VERSION_INFO_ONLY
  359. /* Inhibit C++ name-mangling for libpng functions but not for system calls. */
  360. #ifdef __cplusplus
  361. extern "C" {
  362. #endif /* __cplusplus */
  363. /* Version information for C files, stored in png.c. This had better match
  364. * the version above.
  365. */
  366. #define png_libpng_ver png_get_header_ver(NULL)
  367. /* This file is arranged in several sections:
  368. *
  369. * 1. Any configuration options that can be specified by for the application
  370. * code when it is built. (Build time configuration is in pnglibconf.h)
  371. * 2. Type definitions (base types are defined in pngconf.h), structure
  372. * definitions.
  373. * 3. Exported library functions.
  374. *
  375. * The library source code has additional files (principally pngpriv.h) that
  376. * allow configuration of the library.
  377. */
  378. /* Section 1: run time configuration
  379. * See pnglibconf.h for build time configuration
  380. *
  381. * Run time configuration allows the application to choose between
  382. * implementations of certain arithmetic APIs. The default is set
  383. * at build time and recorded in pnglibconf.h, but it is safe to
  384. * override these (and only these) settings. Note that this won't
  385. * change what the library does, only application code, and the
  386. * settings can (and probably should) be made on a per-file basis
  387. * by setting the #defines before including png.h
  388. *
  389. * Use macros to read integers from PNG data or use the exported
  390. * functions?
  391. * PNG_USE_READ_MACROS: use the macros (see below) Note that
  392. * the macros evaluate their argument multiple times.
  393. * PNG_NO_USE_READ_MACROS: call the relevant library function.
  394. *
  395. * Use the alternative algorithm for compositing alpha samples that
  396. * does not use division?
  397. * PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division'
  398. * algorithm.
  399. * PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm.
  400. *
  401. * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is
  402. * false?
  403. * PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error
  404. * APIs to png_warning.
  405. * Otherwise the calls are mapped to png_error.
  406. */
  407. /* Section 2: type definitions, including structures and compile time
  408. * constants.
  409. * See pngconf.h for base types that vary by machine/system
  410. */
  411. /* This triggers a compiler error in png.c, if png.c and png.h
  412. * do not agree upon the version number.
  413. */
  414. typedef char* png_libpng_version_1_5_26;
  415. /* Three color definitions. The order of the red, green, and blue, (and the
  416. * exact size) is not important, although the size of the fields need to
  417. * be png_byte or png_uint_16 (as defined below).
  418. */
  419. typedef struct png_color_struct
  420. {
  421. png_byte red;
  422. png_byte green;
  423. png_byte blue;
  424. } png_color;
  425. typedef png_color FAR * png_colorp;
  426. typedef PNG_CONST png_color FAR * png_const_colorp;
  427. typedef png_color FAR * FAR * png_colorpp;
  428. typedef struct png_color_16_struct
  429. {
  430. png_byte index; /* used for palette files */
  431. png_uint_16 red; /* for use in red green blue files */
  432. png_uint_16 green;
  433. png_uint_16 blue;
  434. png_uint_16 gray; /* for use in grayscale files */
  435. } png_color_16;
  436. typedef png_color_16 FAR * png_color_16p;
  437. typedef PNG_CONST png_color_16 FAR * png_const_color_16p;
  438. typedef png_color_16 FAR * FAR * png_color_16pp;
  439. typedef struct png_color_8_struct
  440. {
  441. png_byte red; /* for use in red green blue files */
  442. png_byte green;
  443. png_byte blue;
  444. png_byte gray; /* for use in grayscale files */
  445. png_byte alpha; /* for alpha channel files */
  446. } png_color_8;
  447. typedef png_color_8 FAR * png_color_8p;
  448. typedef PNG_CONST png_color_8 FAR * png_const_color_8p;
  449. typedef png_color_8 FAR * FAR * png_color_8pp;
  450. /*
  451. * The following two structures are used for the in-core representation
  452. * of sPLT chunks.
  453. */
  454. typedef struct png_sPLT_entry_struct
  455. {
  456. png_uint_16 red;
  457. png_uint_16 green;
  458. png_uint_16 blue;
  459. png_uint_16 alpha;
  460. png_uint_16 frequency;
  461. } png_sPLT_entry;
  462. typedef png_sPLT_entry FAR * png_sPLT_entryp;
  463. typedef PNG_CONST png_sPLT_entry FAR * png_const_sPLT_entryp;
  464. typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp;
  465. /* When the depth of the sPLT palette is 8 bits, the color and alpha samples
  466. * occupy the LSB of their respective members, and the MSB of each member
  467. * is zero-filled. The frequency member always occupies the full 16 bits.
  468. */
  469. typedef struct png_sPLT_struct
  470. {
  471. png_charp name; /* palette name */
  472. png_byte depth; /* depth of palette samples */
  473. png_sPLT_entryp entries; /* palette entries */
  474. png_int_32 nentries; /* number of palette entries */
  475. } png_sPLT_t;
  476. typedef png_sPLT_t FAR * png_sPLT_tp;
  477. typedef PNG_CONST png_sPLT_t FAR * png_const_sPLT_tp;
  478. typedef png_sPLT_t FAR * FAR * png_sPLT_tpp;
  479. #ifdef PNG_TEXT_SUPPORTED
  480. /* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,
  481. * and whether that contents is compressed or not. The "key" field
  482. * points to a regular zero-terminated C string. The "text" fields can be a
  483. * regular C string, an empty string, or a NULL pointer.
  484. * However, the structure returned by png_get_text() will always contain
  485. * the "text" field as a regular zero-terminated C string (possibly
  486. * empty), never a NULL pointer, so it can be safely used in printf() and
  487. * other string-handling functions. Note that the "itxt_length", "lang", and
  488. * "lang_key" members of the structure only exist when the library is built
  489. * with iTXt chunk support. Prior to libpng-1.4.0 the library was built by
  490. * default without iTXt support. Also note that when iTXt *is* supported,
  491. * the "lang" and "lang_key" fields contain NULL pointers when the
  492. * "compression" field contains * PNG_TEXT_COMPRESSION_NONE or
  493. * PNG_TEXT_COMPRESSION_zTXt. Note that the "compression value" is not the
  494. * same as what appears in the PNG tEXt/zTXt/iTXt chunk's "compression flag"
  495. * which is always 0 or 1, or its "compression method" which is always 0.
  496. */
  497. typedef struct png_text_struct
  498. {
  499. int compression; /* compression value:
  500. -1: tEXt, none
  501. 0: zTXt, deflate
  502. 1: iTXt, none
  503. 2: iTXt, deflate */
  504. png_charp key; /* keyword, 1-79 character description of "text" */
  505. png_charp text; /* comment, may be an empty string (ie "")
  506. or a NULL pointer */
  507. png_size_t text_length; /* length of the text string */
  508. png_size_t itxt_length; /* length of the itxt string */
  509. png_charp lang; /* language code, 0-79 characters
  510. or a NULL pointer */
  511. png_charp lang_key; /* keyword translated UTF-8 string, 0 or more
  512. chars or a NULL pointer */
  513. } png_text;
  514. typedef png_text FAR * png_textp;
  515. typedef PNG_CONST png_text FAR * png_const_textp;
  516. typedef png_text FAR * FAR * png_textpp;
  517. #endif
  518. /* Supported compression types for text in PNG files (tEXt, and zTXt).
  519. * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */
  520. #define PNG_TEXT_COMPRESSION_NONE_WR -3
  521. #define PNG_TEXT_COMPRESSION_zTXt_WR -2
  522. #define PNG_TEXT_COMPRESSION_NONE -1
  523. #define PNG_TEXT_COMPRESSION_zTXt 0
  524. #define PNG_ITXT_COMPRESSION_NONE 1
  525. #define PNG_ITXT_COMPRESSION_zTXt 2
  526. #define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */
  527. /* png_time is a way to hold the time in an machine independent way.
  528. * Two conversions are provided, both from time_t and struct tm. There
  529. * is no portable way to convert to either of these structures, as far
  530. * as I know. If you know of a portable way, send it to me. As a side
  531. * note - PNG has always been Year 2000 compliant!
  532. */
  533. typedef struct png_time_struct
  534. {
  535. png_uint_16 year; /* full year, as in, 1995 */
  536. png_byte month; /* month of year, 1 - 12 */
  537. png_byte day; /* day of month, 1 - 31 */
  538. png_byte hour; /* hour of day, 0 - 23 */
  539. png_byte minute; /* minute of hour, 0 - 59 */
  540. png_byte second; /* second of minute, 0 - 60 (for leap seconds) */
  541. } png_time;
  542. typedef png_time FAR * png_timep;
  543. typedef PNG_CONST png_time FAR * png_const_timep;
  544. typedef png_time FAR * FAR * png_timepp;
  545. #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
  546. defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
  547. /* png_unknown_chunk is a structure to hold queued chunks for which there is
  548. * no specific support. The idea is that we can use this to queue
  549. * up private chunks for output even though the library doesn't actually
  550. * know about their semantics.
  551. */
  552. typedef struct png_unknown_chunk_t
  553. {
  554. png_byte name[5];
  555. png_byte *data;
  556. png_size_t size;
  557. /* libpng-using applications should NOT directly modify this byte. */
  558. png_byte location; /* mode of operation at read time */
  559. }
  560. png_unknown_chunk;
  561. typedef png_unknown_chunk FAR * png_unknown_chunkp;
  562. typedef PNG_CONST png_unknown_chunk FAR * png_const_unknown_chunkp;
  563. typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;
  564. #endif
  565. /* Values for the unknown chunk location byte */
  566. #define PNG_HAVE_IHDR 0x01
  567. #define PNG_HAVE_PLTE 0x02
  568. #define PNG_AFTER_IDAT 0x08
  569. /* The complete definition of png_info has, as of libpng-1.5.0,
  570. * been moved into a separate header file that is not accessible to
  571. * applications. Read libpng-manual.txt or libpng.3 for more info.
  572. */
  573. typedef struct png_info_def png_info;
  574. typedef png_info FAR * png_infop;
  575. typedef PNG_CONST png_info FAR * png_const_infop;
  576. typedef png_info FAR * FAR * png_infopp;
  577. /* Maximum positive integer used in PNG is (2^31)-1 */
  578. #define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)
  579. #define PNG_UINT_32_MAX ((png_uint_32)(-1))
  580. #define PNG_SIZE_MAX ((png_size_t)(-1))
  581. /* These are constants for fixed point values encoded in the
  582. * PNG specification manner (x100000)
  583. */
  584. #define PNG_FP_1 100000
  585. #define PNG_FP_HALF 50000
  586. #define PNG_FP_MAX ((png_fixed_point)0x7fffffffL)
  587. #define PNG_FP_MIN (-PNG_FP_MAX)
  588. /* These describe the color_type field in png_info. */
  589. /* color type masks */
  590. #define PNG_COLOR_MASK_PALETTE 1
  591. #define PNG_COLOR_MASK_COLOR 2
  592. #define PNG_COLOR_MASK_ALPHA 4
  593. /* color types. Note that not all combinations are legal */
  594. #define PNG_COLOR_TYPE_GRAY 0
  595. #define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
  596. #define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR)
  597. #define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  598. #define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
  599. /* aliases */
  600. #define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA
  601. #define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA
  602. /* This is for compression type. PNG 1.0-1.2 only define the single type. */
  603. #define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */
  604. #define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE
  605. /* This is for filter type. PNG 1.0-1.2 only define the single type. */
  606. #define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */
  607. #define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */
  608. #define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE
  609. /* These are for the interlacing type. These values should NOT be changed. */
  610. #define PNG_INTERLACE_NONE 0 /* Non-interlaced image */
  611. #define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */
  612. #define PNG_INTERLACE_LAST 2 /* Not a valid value */
  613. /* These are for the oFFs chunk. These values should NOT be changed. */
  614. #define PNG_OFFSET_PIXEL 0 /* Offset in pixels */
  615. #define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */
  616. #define PNG_OFFSET_LAST 2 /* Not a valid value */
  617. /* These are for the pCAL chunk. These values should NOT be changed. */
  618. #define PNG_EQUATION_LINEAR 0 /* Linear transformation */
  619. #define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */
  620. #define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */
  621. #define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */
  622. #define PNG_EQUATION_LAST 4 /* Not a valid value */
  623. /* These are for the sCAL chunk. These values should NOT be changed. */
  624. #define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */
  625. #define PNG_SCALE_METER 1 /* meters per pixel */
  626. #define PNG_SCALE_RADIAN 2 /* radians per pixel */
  627. #define PNG_SCALE_LAST 3 /* Not a valid value */
  628. /* These are for the pHYs chunk. These values should NOT be changed. */
  629. #define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */
  630. #define PNG_RESOLUTION_METER 1 /* pixels/meter */
  631. #define PNG_RESOLUTION_LAST 2 /* Not a valid value */
  632. /* These are for the sRGB chunk. These values should NOT be changed. */
  633. #define PNG_sRGB_INTENT_PERCEPTUAL 0
  634. #define PNG_sRGB_INTENT_RELATIVE 1
  635. #define PNG_sRGB_INTENT_SATURATION 2
  636. #define PNG_sRGB_INTENT_ABSOLUTE 3
  637. #define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */
  638. /* This is for text chunks */
  639. #define PNG_KEYWORD_MAX_LENGTH 79
  640. /* Maximum number of entries in PLTE/sPLT/tRNS arrays */
  641. #define PNG_MAX_PALETTE_LENGTH 256
  642. /* These determine if an ancillary chunk's data has been successfully read
  643. * from the PNG header, or if the application has filled in the corresponding
  644. * data in the info_struct to be written into the output file. The values
  645. * of the PNG_INFO_<chunk> defines should NOT be changed.
  646. */
  647. #define PNG_INFO_gAMA 0x0001
  648. #define PNG_INFO_sBIT 0x0002
  649. #define PNG_INFO_cHRM 0x0004
  650. #define PNG_INFO_PLTE 0x0008
  651. #define PNG_INFO_tRNS 0x0010
  652. #define PNG_INFO_bKGD 0x0020
  653. #define PNG_INFO_hIST 0x0040
  654. #define PNG_INFO_pHYs 0x0080
  655. #define PNG_INFO_oFFs 0x0100
  656. #define PNG_INFO_tIME 0x0200
  657. #define PNG_INFO_pCAL 0x0400
  658. #define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */
  659. #define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */
  660. #define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */
  661. #define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */
  662. #define PNG_INFO_IDAT 0x8000 /* ESR, 1.0.6 */
  663. /* This is used for the transformation routines, as some of them
  664. * change these values for the row. It also should enable using
  665. * the routines for other purposes.
  666. */
  667. typedef struct png_row_info_struct
  668. {
  669. png_uint_32 width; /* width of row */
  670. png_size_t rowbytes; /* number of bytes in row */
  671. png_byte color_type; /* color type of row */
  672. png_byte bit_depth; /* bit depth of row */
  673. png_byte channels; /* number of channels (1, 2, 3, or 4) */
  674. png_byte pixel_depth; /* bits per pixel (depth * channels) */
  675. } png_row_info;
  676. typedef png_row_info FAR * png_row_infop;
  677. typedef png_row_info FAR * FAR * png_row_infopp;
  678. /* The complete definition of png_struct has, as of libpng-1.5.0,
  679. * been moved into a separate header file that is not accessible to
  680. * applications. Read libpng-manual.txt or libpng.3 for more info.
  681. */
  682. typedef struct png_struct_def png_struct;
  683. typedef PNG_CONST png_struct FAR * png_const_structp;
  684. typedef png_struct FAR * png_structp;
  685. /* These are the function types for the I/O functions and for the functions
  686. * that allow the user to override the default I/O functions with his or her
  687. * own. The png_error_ptr type should match that of user-supplied warning
  688. * and error functions, while the png_rw_ptr type should match that of the
  689. * user read/write data functions. Note that the 'write' function must not
  690. * modify the buffer it is passed. The 'read' function, on the other hand, is
  691. * expected to return the read data in the buffer.
  692. */
  693. typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp));
  694. typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t));
  695. typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp));
  696. typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32,
  697. int));
  698. typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32,
  699. int));
  700. #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
  701. typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop));
  702. typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop));
  703. /* The following callback receives png_uint_32 row_number, int pass for the
  704. * png_bytep data of the row. When transforming an interlaced image the
  705. * row number is the row number within the sub-image of the interlace pass, so
  706. * the value will increase to the height of the sub-image (not the full image)
  707. * then reset to 0 for the next pass.
  708. *
  709. * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to
  710. * find the output pixel (x,y) given an interlaced sub-image pixel
  711. * (row,col,pass). (See below for these macros.)
  712. */
  713. typedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep,
  714. png_uint_32, int));
  715. #endif
  716. #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
  717. defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
  718. typedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop,
  719. png_bytep));
  720. #endif
  721. #ifdef PNG_USER_CHUNKS_SUPPORTED
  722. typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp,
  723. png_unknown_chunkp));
  724. #endif
  725. #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
  726. typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp));
  727. #endif
  728. #ifdef PNG_SETJMP_SUPPORTED
  729. /* This must match the function definition in <setjmp.h>, and the application
  730. * must include this before png.h to obtain the definition of jmp_buf. The
  731. * function is required to be PNG_NORETURN, but this is not checked. If the
  732. * function does return the application will crash via an abort() or similar
  733. * system level call.
  734. *
  735. * If you get a warning here while building the library you may need to make
  736. * changes to ensure that pnglibconf.h records the calling convention used by
  737. * your compiler. This may be very difficult - try using a different compiler
  738. * to build the library!
  739. */
  740. PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef);
  741. #endif
  742. /* Transform masks for the high-level interface */
  743. #define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */
  744. #define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */
  745. #define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */
  746. #define PNG_TRANSFORM_PACKING 0x0004 /* read and write */
  747. #define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */
  748. #define PNG_TRANSFORM_EXPAND 0x0010 /* read only */
  749. #define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */
  750. #define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */
  751. #define PNG_TRANSFORM_BGR 0x0080 /* read and write */
  752. #define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */
  753. #define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */
  754. #define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */
  755. #define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* write only */
  756. /* Added to libpng-1.2.34 */
  757. #define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER
  758. #define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */
  759. /* Added to libpng-1.4.0 */
  760. #define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */
  761. /* Added to libpng-1.5.4 */
  762. #define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */
  763. #define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */
  764. /* Flags for MNG supported features */
  765. #define PNG_FLAG_MNG_EMPTY_PLTE 0x01
  766. #define PNG_FLAG_MNG_FILTER_64 0x04
  767. #define PNG_ALL_MNG_FEATURES 0x05
  768. /* NOTE: prior to 1.5 these functions had no 'API' style declaration,
  769. * this allowed the zlib default functions to be used on Windows
  770. * platforms. In 1.5 the zlib default malloc (which just calls malloc and
  771. * ignores the first argument) should be completely compatible with the
  772. * following.
  773. */
  774. typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp,
  775. png_alloc_size_t));
  776. typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp));
  777. typedef png_struct FAR * FAR * png_structpp;
  778. /* Section 3: exported functions
  779. * Here are the function definitions most commonly used. This is not
  780. * the place to find out how to use libpng. See libpng-manual.txt for the
  781. * full explanation, see example.c for the summary. This just provides
  782. * a simple one line description of the use of each function.
  783. *
  784. * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in
  785. * pngconf.h and in the *.dfn files in the scripts directory.
  786. *
  787. * PNG_EXPORT(ordinal, type, name, (args));
  788. *
  789. * ordinal: ordinal that is used while building
  790. * *.def files. The ordinal value is only
  791. * relevant when preprocessing png.h with
  792. * the *.dfn files for building symbol table
  793. * entries, and are removed by pngconf.h.
  794. * type: return type of the function
  795. * name: function name
  796. * args: function arguments, with types
  797. *
  798. * When we wish to append attributes to a function prototype we use
  799. * the PNG_EXPORTA() macro instead.
  800. *
  801. * PNG_EXPORTA(ordinal, type, name, (args), attributes);
  802. *
  803. * ordinal, type, name, and args: same as in PNG_EXPORT().
  804. * attributes: function attributes
  805. */
  806. /* Returns the version number of the library */
  807. PNG_EXPORT(1, png_uint_32, png_access_version_number, (void));
  808. /* Tell lib we have already handled the first <num_bytes> magic bytes.
  809. * Handling more than 8 bytes from the beginning of the file is an error.
  810. */
  811. PNG_EXPORT(2, void, png_set_sig_bytes, (png_structp png_ptr, int num_bytes));
  812. /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a
  813. * PNG file. Returns zero if the supplied bytes match the 8-byte PNG
  814. * signature, and non-zero otherwise. Having num_to_check == 0 or
  815. * start > 7 will always fail (ie return non-zero).
  816. */
  817. PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start,
  818. png_size_t num_to_check));
  819. /* Simple signature checking function. This is the same as calling
  820. * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
  821. */
  822. #define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n))
  823. /* Allocate and initialize png_ptr struct for reading, and any other memory. */
  824. PNG_EXPORTA(4, png_structp, png_create_read_struct,
  825. (png_const_charp user_png_ver, png_voidp error_ptr,
  826. png_error_ptr error_fn, png_error_ptr warn_fn),
  827. PNG_ALLOCATED);
  828. /* Allocate and initialize png_ptr struct for writing, and any other memory */
  829. PNG_EXPORTA(5, png_structp, png_create_write_struct,
  830. (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,
  831. png_error_ptr warn_fn),
  832. PNG_ALLOCATED);
  833. #ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
  834. PNG_EXPORT(6, png_size_t, png_get_compression_buffer_size,
  835. (png_const_structp png_ptr));
  836. PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structp png_ptr,
  837. png_size_t size));
  838. #endif /* WRITE_CUSTOMIZE_COMPRESSION */
  839. /* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp
  840. * match up.
  841. */
  842. #ifdef PNG_SETJMP_SUPPORTED
  843. /* This function returns the jmp_buf built in to *png_ptr. It must be
  844. * supplied with an appropriate 'longjmp' function to use on that jmp_buf
  845. * unless the default error function is overridden in which case NULL is
  846. * acceptable. The size of the jmp_buf is checked against the actual size
  847. * allocated by the library - the call will return NULL on a mismatch
  848. * indicating an ABI mismatch.
  849. */
  850. PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structp png_ptr,
  851. png_longjmp_ptr longjmp_fn, size_t jmp_buf_size));
  852. # define png_jmpbuf(png_ptr) \
  853. (*png_set_longjmp_fn((png_ptr), longjmp, sizeof (jmp_buf)))
  854. #else
  855. # define png_jmpbuf(png_ptr) \
  856. (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP)
  857. #endif
  858. /* This function should be used by libpng applications in place of
  859. * longjmp(png_ptr->jmpbuf, val). If longjmp_fn() has been set, it
  860. * will use it; otherwise it will call PNG_ABORT(). This function was
  861. * added in libpng-1.5.0.
  862. */
  863. PNG_EXPORTA(9, void, png_longjmp, (png_structp png_ptr, int val),
  864. PNG_NORETURN);
  865. #ifdef PNG_READ_SUPPORTED
  866. /* Reset the compression stream */
  867. PNG_EXPORT(10, int, png_reset_zstream, (png_structp png_ptr));
  868. #endif
  869. /* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */
  870. #ifdef PNG_USER_MEM_SUPPORTED
  871. PNG_EXPORTA(11, png_structp, png_create_read_struct_2,
  872. (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,
  873. png_error_ptr warn_fn,
  874. png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),
  875. PNG_ALLOCATED);
  876. PNG_EXPORTA(12, png_structp, png_create_write_struct_2,
  877. (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,
  878. png_error_ptr warn_fn,
  879. png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),
  880. PNG_ALLOCATED);
  881. #endif
  882. /* Write the PNG file signature. */
  883. PNG_EXPORT(13, void, png_write_sig, (png_structp png_ptr));
  884. /* Write a PNG chunk - size, type, (optional) data, CRC. */
  885. PNG_EXPORT(14, void, png_write_chunk, (png_structp png_ptr, png_const_bytep
  886. chunk_name, png_const_bytep data, png_size_t length));
  887. /* Write the start of a PNG chunk - length and chunk name. */
  888. PNG_EXPORT(15, void, png_write_chunk_start, (png_structp png_ptr,
  889. png_const_bytep chunk_name, png_uint_32 length));
  890. /* Write the data of a PNG chunk started with png_write_chunk_start(). */
  891. PNG_EXPORT(16, void, png_write_chunk_data, (png_structp png_ptr,
  892. png_const_bytep data, png_size_t length));
  893. /* Finish a chunk started with png_write_chunk_start() (includes CRC). */
  894. PNG_EXPORT(17, void, png_write_chunk_end, (png_structp png_ptr));
  895. /* Allocate and initialize the info structure */
  896. PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_structp png_ptr),
  897. PNG_ALLOCATED);
  898. PNG_EXPORT(19, void, png_info_init_3, (png_infopp info_ptr,
  899. png_size_t png_info_struct_size));
  900. /* Writes all the PNG information before the image. */
  901. PNG_EXPORT(20, void, png_write_info_before_PLTE,
  902. (png_structp png_ptr, png_infop info_ptr));
  903. PNG_EXPORT(21, void, png_write_info,
  904. (png_structp png_ptr, png_infop info_ptr));
  905. #ifdef PNG_SEQUENTIAL_READ_SUPPORTED
  906. /* Read the information before the actual image data. */
  907. PNG_EXPORT(22, void, png_read_info,
  908. (png_structp png_ptr, png_infop info_ptr));
  909. #endif
  910. #ifdef PNG_TIME_RFC1123_SUPPORTED
  911. PNG_EXPORT(23, png_const_charp, png_convert_to_rfc1123,
  912. (png_structp png_ptr,
  913. png_const_timep ptime));
  914. #endif
  915. #ifdef PNG_CONVERT_tIME_SUPPORTED
  916. /* Convert from a struct tm to png_time */
  917. PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime,
  918. PNG_CONST struct tm FAR * ttime));
  919. /* Convert from time_t to png_time. Uses gmtime() */
  920. PNG_EXPORT(25, void, png_convert_from_time_t,
  921. (png_timep ptime, time_t ttime));
  922. #endif /* PNG_CONVERT_tIME_SUPPORTED */
  923. #ifdef PNG_READ_EXPAND_SUPPORTED
  924. /* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
  925. PNG_EXPORT(26, void, png_set_expand, (png_structp png_ptr));
  926. PNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structp png_ptr));
  927. PNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structp png_ptr));
  928. PNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structp png_ptr));
  929. #endif
  930. #ifdef PNG_READ_EXPAND_16_SUPPORTED
  931. /* Expand to 16-bit channels, forces conversion of palette to RGB and expansion
  932. * of a tRNS chunk if present.
  933. */
  934. PNG_EXPORT(221, void, png_set_expand_16, (png_structp png_ptr));
  935. #endif
  936. #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
  937. /* Use blue, green, red order for pixels. */
  938. PNG_EXPORT(30, void, png_set_bgr, (png_structp png_ptr));
  939. #endif
  940. #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
  941. /* Expand the grayscale to 24-bit RGB if necessary. */
  942. PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structp png_ptr));
  943. #endif
  944. #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
  945. /* Reduce RGB to grayscale. */
  946. #define PNG_ERROR_ACTION_NONE 1
  947. #define PNG_ERROR_ACTION_WARN 2
  948. #define PNG_ERROR_ACTION_ERROR 3
  949. #define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/
  950. PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structp png_ptr,
  951. int error_action, double red, double green))
  952. PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structp png_ptr,
  953. int error_action, png_fixed_point red, png_fixed_point green))
  954. PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structp
  955. png_ptr));
  956. #endif
  957. #ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
  958. PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth,
  959. png_colorp palette));
  960. #endif
  961. #ifdef PNG_READ_ALPHA_MODE_SUPPORTED
  962. /* How the alpha channel is interpreted - this affects how the color channels of
  963. * a PNG file are returned when an alpha channel, or tRNS chunk in a palette
  964. * file, is present.
  965. *
  966. * This has no effect on the way pixels are written into a PNG output
  967. * datastream. The color samples in a PNG datastream are never premultiplied
  968. * with the alpha samples.
  969. *
  970. * The default is to return data according to the PNG specification: the alpha
  971. * channel is a linear measure of the contribution of the pixel to the
  972. * corresponding composited pixel. The gamma encoded color channels must be
  973. * scaled according to the contribution and to do this it is necessary to undo
  974. * the encoding, scale the color values, perform the composition and reencode
  975. * the values. This is the 'PNG' mode.
  976. *
  977. * The alternative is to 'associate' the alpha with the color information by
  978. * storing color channel values that have been scaled by the alpha. The
  979. * advantage is that the color channels can be resampled (the image can be
  980. * scaled) in this form. The disadvantage is that normal practice is to store
  981. * linear, not (gamma) encoded, values and this requires 16-bit channels for
  982. * still images rather than the 8-bit channels that are just about sufficient if
  983. * gamma encoding is used. In addition all non-transparent pixel values,
  984. * including completely opaque ones, must be gamma encoded to produce the final
  985. * image. This is the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' mode (the
  986. * latter being the two common names for associated alpha color channels.)
  987. *
  988. * Since it is not necessary to perform arithmetic on opaque color values so
  989. * long as they are not to be resampled and are in the final color space it is
  990. * possible to optimize the handling of alpha by storing the opaque pixels in
  991. * the PNG format (adjusted for the output color space) while storing partially
  992. * opaque pixels in the standard, linear, format. The accuracy required for
  993. * standard alpha composition is relatively low, because the pixels are
  994. * isolated, therefore typically the accuracy loss in storing 8-bit linear
  995. * values is acceptable. (This is not true if the alpha channel is used to
  996. * simulate transparency over large areas - use 16 bits or the PNG mode in
  997. * this case!) This is the 'OPTIMIZED' mode. For this mode a pixel is
  998. * treated as opaque only if the alpha value is equal to the maximum value.
  999. *
  1000. * The final choice is to gamma encode the alpha channel as well. This is
  1001. * broken because, in practice, no implementation that uses this choice
  1002. * correctly undoes the encoding before handling alpha composition. Use this
  1003. * choice only if other serious errors in the software or hardware you use
  1004. * mandate it; the typical serious error is for dark halos to appear around
  1005. * opaque areas of the composited PNG image because of arithmetic overflow.
  1006. *
  1007. * The API function png_set_alpha_mode specifies which of these choices to use
  1008. * with an enumerated 'mode' value and the gamma of the required output:
  1009. */
  1010. #define PNG_ALPHA_PNG 0 /* according to the PNG standard */
  1011. #define PNG_ALPHA_STANDARD 1 /* according to Porter/Duff */
  1012. #define PNG_ALPHA_ASSOCIATED 1 /* as above; this is the normal practice */
  1013. #define PNG_ALPHA_PREMULTIPLIED 1 /* as above */
  1014. #define PNG_ALPHA_OPTIMIZED 2 /* 'PNG' for opaque pixels, else 'STANDARD' */
  1015. #define PNG_ALPHA_BROKEN 3 /* the alpha channel is gamma encoded */
  1016. PNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structp png_ptr, int mode,
  1017. double output_gamma))
  1018. PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structp png_ptr,
  1019. int mode, png_fixed_point output_gamma))
  1020. #endif
  1021. #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED)
  1022. /* The output_gamma value is a screen gamma in libpng terminology: it expresses
  1023. * how to decode the output values, not how they are encoded. The values used
  1024. * correspond to the normal numbers used to describe the overall gamma of a
  1025. * computer display system; for example 2.2 for an sRGB conformant system. The
  1026. * values are scaled by 100000 in the _fixed version of the API (so 220000 for
  1027. * sRGB.)
  1028. *
  1029. * The inverse of the value is always used to provide a default for the PNG file
  1030. * encoding if it has no gAMA chunk and if png_set_gamma() has not been called
  1031. * to override the PNG gamma information.
  1032. *
  1033. * When the ALPHA_OPTIMIZED mode is selected the output gamma is used to encode
  1034. * opaque pixels however pixels with lower alpha values are not encoded,
  1035. * regardless of the output gamma setting.
  1036. *
  1037. * When the standard Porter Duff handling is requested with mode 1 the output
  1038. * encoding is set to be linear and the output_gamma value is only relevant
  1039. * as a default for input data that has no gamma information. The linear output
  1040. * encoding will be overridden if png_set_gamma() is called - the results may be
  1041. * highly unexpected!
  1042. *
  1043. * The following numbers are derived from the sRGB standard and the research
  1044. * behind it. sRGB is defined to be approximated by a PNG gAMA chunk value of
  1045. * 0.45455 (1/2.2) for PNG. The value implicitly includes any viewing
  1046. * correction required to take account of any differences in the color
  1047. * environment of the original scene and the intended display environment; the
  1048. * value expresses how to *decode* the image for display, not how the original
  1049. * data was *encoded*.
  1050. *
  1051. * sRGB provides a peg for the PNG standard by defining a viewing environment.
  1052. * sRGB itself, and earlier TV standards, actually use a more complex transform
  1053. * (a linear portion then a gamma 2.4 power law) than PNG can express. (PNG is
  1054. * limited to simple power laws.) By saying that an image for direct display on
  1055. * an sRGB conformant system should be stored with a gAMA chunk value of 45455
  1056. * (11.3.3.2 and 11.3.3.5 of the ISO PNG specification) the PNG specification
  1057. * makes it possible to derive values for other display systems and
  1058. * environments.
  1059. *
  1060. * The Mac value is deduced from the sRGB based on an assumption that the actual
  1061. * extra viewing correction used in early Mac display systems was implemented as
  1062. * a power 1.45 lookup table.
  1063. *
  1064. * Any system where a programmable lookup table is used or where the behavior of
  1065. * the final display device characteristics can be changed requires system
  1066. * specific code to obtain the current characteristic. However this can be
  1067. * difficult and most PNG gamma correction only requires an approximate value.
  1068. *
  1069. * By default, if png_set_alpha_mode() is not called, libpng assumes that all
  1070. * values are unencoded, linear, values and that the output device also has a
  1071. * linear characteristic. This is only very rarely correct - it is invariably
  1072. * better to call png_set_alpha_mode() with PNG_DEFAULT_sRGB than rely on the
  1073. * default if you don't know what the right answer is!
  1074. *
  1075. * The special value PNG_GAMMA_MAC_18 indicates an older Mac system (pre Mac OS
  1076. * 10.6) which used a correction table to implement a somewhat lower gamma on an
  1077. * otherwise sRGB system.
  1078. *
  1079. * Both these values are reserved (not simple gamma values) in order to allow
  1080. * more precise correction internally in the future.
  1081. *
  1082. * NOTE: the following values can be passed to either the fixed or floating
  1083. * point APIs, but the floating point API will also accept floating point
  1084. * values.
  1085. */
  1086. #define PNG_DEFAULT_sRGB -1 /* sRGB gamma and color space */
  1087. #define PNG_GAMMA_MAC_18 -2 /* Old Mac '1.8' gamma and color space */
  1088. #define PNG_GAMMA_sRGB 220000 /* Television standards--matches sRGB gamma */
  1089. #define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */
  1090. #endif
  1091. /* The following are examples of calls to png_set_alpha_mode to achieve the
  1092. * required overall gamma correction and, where necessary, alpha
  1093. * premultiplication.
  1094. *
  1095. * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);
  1096. * This is the default libpng handling of the alpha channel - it is not
  1097. * pre-multiplied into the color components. In addition the call states
  1098. * that the output is for a sRGB system and causes all PNG files without gAMA
  1099. * chunks to be assumed to be encoded using sRGB.
  1100. *
  1101. * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);
  1102. * In this case the output is assumed to be something like an sRGB conformant
  1103. * display preceeded by a power-law lookup table of power 1.45. This is how
  1104. * early Mac systems behaved.
  1105. *
  1106. * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR);
  1107. * This is the classic Jim Blinn approach and will work in academic
  1108. * environments where everything is done by the book. It has the shortcoming
  1109. * of assuming that input PNG data with no gamma information is linear - this
  1110. * is unlikely to be correct unless the PNG files where generated locally.
  1111. * Most of the time the output precision will be so low as to show
  1112. * significant banding in dark areas of the image.
  1113. *
  1114. * png_set_expand_16(pp);
  1115. * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB);
  1116. * This is a somewhat more realistic Jim Blinn inspired approach. PNG files
  1117. * are assumed to have the sRGB encoding if not marked with a gamma value and
  1118. * the output is always 16 bits per component. This permits accurate scaling
  1119. * and processing of the data. If you know that your input PNG files were
  1120. * generated locally you might need to replace PNG_DEFAULT_sRGB with the
  1121. * correct value for your system.
  1122. *
  1123. * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB);
  1124. * If you just need to composite the PNG image onto an existing background
  1125. * and if you control the code that does this you can use the optimization
  1126. * setting. In this case you just copy completely opaque pixels to the
  1127. * output. For pixels that are not completely transparent (you just skip
  1128. * those) you do the composition math using png_composite or png_composite_16
  1129. * below then encode the resultant 8-bit or 16-bit values to match the output
  1130. * encoding.
  1131. *
  1132. * Other cases
  1133. * If neither the PNG nor the standard linear encoding work for you because
  1134. * of the software or hardware you use then you have a big problem. The PNG
  1135. * case will probably result in halos around the image. The linear encoding
  1136. * will probably result in a washed out, too bright, image (it's actually too
  1137. * contrasty.) Try the ALPHA_OPTIMIZED mode above - this will probably
  1138. * substantially reduce the halos. Alternatively try:
  1139. *
  1140. * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB);
  1141. * This option will also reduce the halos, but there will be slight dark
  1142. * halos round the opaque parts of the image where the background is light.
  1143. * In the OPTIMIZED mode the halos will be light halos where the background
  1144. * is dark. Take your pick - the halos are unavoidable unless you can get
  1145. * your hardware/software fixed! (The OPTIMIZED approach is slightly
  1146. * faster.)
  1147. *
  1148. * When the default gamma of PNG files doesn't match the output gamma.
  1149. * If you have PNG files with no gamma information png_set_alpha_mode allows
  1150. * you to provide a default gamma, but it also sets the ouput gamma to the
  1151. * matching value. If you know your PNG files have a gamma that doesn't
  1152. * match the output you can take advantage of the fact that
  1153. * png_set_alpha_mode always sets the output gamma but only sets the PNG
  1154. * default if it is not already set:
  1155. *
  1156. * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);
  1157. * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);
  1158. * The first call sets both the default and the output gamma values, the
  1159. * second call overrides the output gamma without changing the default. This
  1160. * is easier than achieving the same effect with png_set_gamma. You must use
  1161. * PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will
  1162. * fire if more than one call to png_set_alpha_mode and png_set_background is
  1163. * made in the same read operation, however multiple calls with PNG_ALPHA_PNG
  1164. * are ignored.
  1165. */
  1166. #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
  1167. PNG_EXPORT(36, void, png_set_strip_alpha, (png_structp png_ptr));
  1168. #endif
  1169. #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
  1170. defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
  1171. PNG_EXPORT(37, void, png_set_swap_alpha, (png_structp png_ptr));
  1172. #endif
  1173. #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
  1174. defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
  1175. PNG_EXPORT(38, void, png_set_invert_alpha, (png_structp png_ptr));
  1176. #endif
  1177. #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
  1178. /* Add a filler byte to 8-bit Gray or 24-bit RGB images. */
  1179. PNG_EXPORT(39, void, png_set_filler, (png_structp png_ptr, png_uint_32 filler,
  1180. int flags));
  1181. /* The values of the PNG_FILLER_ defines should NOT be changed */
  1182. # define PNG_FILLER_BEFORE 0
  1183. # define PNG_FILLER_AFTER 1
  1184. /* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */
  1185. PNG_EXPORT(40, void, png_set_add_alpha,
  1186. (png_structp png_ptr, png_uint_32 filler,
  1187. int flags));
  1188. #endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */
  1189. #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
  1190. /* Swap bytes in 16-bit depth files. */
  1191. PNG_EXPORT(41, void, png_set_swap, (png_structp png_ptr));
  1192. #endif
  1193. #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
  1194. /* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */
  1195. PNG_EXPORT(42, void, png_set_packing, (png_structp png_ptr));
  1196. #endif
  1197. #if defined(PNG_READ_PACKSWAP_SUPPORTED) || \
  1198. defined(PNG_WRITE_PACKSWAP_SUPPORTED)
  1199. /* Swap packing order of pixels in bytes. */
  1200. PNG_EXPORT(43, void, png_set_packswap, (png_structp png_ptr));
  1201. #endif
  1202. #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
  1203. /* Converts files to legal bit depths. */
  1204. PNG_EXPORT(44, void, png_set_shift, (png_structp png_ptr, png_const_color_8p
  1205. true_bits));
  1206. #endif
  1207. #if defined(PNG_READ_INTERLACING_SUPPORTED) || \
  1208. defined(PNG_WRITE_INTERLACING_SUPPORTED)
  1209. /* Have the code handle the interlacing. Returns the number of passes.
  1210. * MUST be called before png_read_update_info or png_start_read_image,
  1211. * otherwise it will not have the desired effect. Note that it is still
  1212. * necessary to call png_read_row or png_read_rows png_get_image_height
  1213. * times for each pass.
  1214. */
  1215. PNG_EXPORT(45, int, png_set_interlace_handling, (png_structp png_ptr));
  1216. #endif
  1217. #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
  1218. /* Invert monochrome files */
  1219. PNG_EXPORT(46, void, png_set_invert_mono, (png_structp png_ptr));
  1220. #endif
  1221. #ifdef PNG_READ_BACKGROUND_SUPPORTED
  1222. /* Handle alpha and tRNS by replacing with a background color. Prior to
  1223. * libpng-1.5.4 this API must not be called before the PNG file header has been
  1224. * read. Doing so will result in unexpected behavior and possible warnings or
  1225. * errors if the PNG file contains a bKGD chunk.
  1226. */
  1227. PNG_FP_EXPORT(47, void, png_set_background, (png_structp png_ptr,
  1228. png_const_color_16p background_color, int background_gamma_code,
  1229. int need_expand, double background_gamma))
  1230. PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structp png_ptr,
  1231. png_const_color_16p background_color, int background_gamma_code,
  1232. int need_expand, png_fixed_point background_gamma))
  1233. #endif
  1234. #ifdef PNG_READ_BACKGROUND_SUPPORTED
  1235. # define PNG_BACKGROUND_GAMMA_UNKNOWN 0
  1236. # define PNG_BACKGROUND_GAMMA_SCREEN 1
  1237. # define PNG_BACKGROUND_GAMMA_FILE 2
  1238. # define PNG_BACKGROUND_GAMMA_UNIQUE 3
  1239. #endif
  1240. #ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
  1241. /* Scale a 16-bit depth file down to 8-bit, accurately. */
  1242. PNG_EXPORT(229, void, png_set_scale_16, (png_structp png_ptr));
  1243. #endif
  1244. #ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
  1245. #define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */
  1246. /* Strip the second byte of information from a 16-bit depth file. */
  1247. PNG_EXPORT(48, void, png_set_strip_16, (png_structp png_ptr));
  1248. #endif
  1249. #ifdef PNG_READ_QUANTIZE_SUPPORTED
  1250. /* Turn on quantizing, and reduce the palette to the number of colors
  1251. * available.
  1252. */
  1253. PNG_EXPORT(49, void, png_set_quantize,
  1254. (png_structp png_ptr, png_colorp palette,
  1255. int num_palette, int maximum_colors, png_const_uint_16p histogram,
  1256. int full_quantize));
  1257. #endif
  1258. #ifdef PNG_READ_GAMMA_SUPPORTED
  1259. /* The threshold on gamma processing is configurable but hard-wired into the
  1260. * library. The following is the floating point variant.
  1261. */
  1262. #define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001)
  1263. /* Handle gamma correction. Screen_gamma=(display_exponent).
  1264. * NOTE: this API simply sets the screen and file gamma values. It will
  1265. * therefore override the value for gamma in a PNG file if it is called after
  1266. * the file header has been read - use with care - call before reading the PNG
  1267. * file for best results!
  1268. *
  1269. * These routines accept the same gamma values as png_set_alpha_mode (described
  1270. * above). The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either
  1271. * API (floating point or fixed.) Notice, however, that the 'file_gamma' value
  1272. * is the inverse of a 'screen gamma' value.
  1273. */
  1274. PNG_FP_EXPORT(50, void, png_set_gamma,
  1275. (png_structp png_ptr, double screen_gamma,
  1276. double override_file_gamma))
  1277. PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structp png_ptr,
  1278. png_fixed_point screen_gamma, png_fixed_point override_file_gamma))
  1279. #endif
  1280. #ifdef PNG_WRITE_FLUSH_SUPPORTED
  1281. /* Set how many lines between output flushes - 0 for no flushing */
  1282. PNG_EXPORT(51, void, png_set_flush, (png_structp png_ptr, int nrows));
  1283. /* Flush the current PNG output buffer */
  1284. PNG_EXPORT(52, void, png_write_flush, (png_structp png_ptr));
  1285. #endif
  1286. /* Optional update palette with requested transformations */
  1287. PNG_EXPORT(53, void, png_start_read_image, (png_structp png_ptr));
  1288. /* Optional call to update the users info structure */
  1289. PNG_EXPORT(54, void, png_read_update_info,
  1290. (png_structp png_ptr, png_infop info_ptr));
  1291. #ifdef PNG_SEQUENTIAL_READ_SUPPORTED
  1292. /* Read one or more rows of image data. */
  1293. PNG_EXPORT(55, void, png_read_rows, (png_structp png_ptr, png_bytepp row,
  1294. png_bytepp display_row, png_uint_32 num_rows));
  1295. #endif
  1296. #ifdef PNG_SEQUENTIAL_READ_SUPPORTED
  1297. /* Read a row of data. */
  1298. PNG_EXPORT(56, void, png_read_row, (png_structp png_ptr, png_bytep row,
  1299. png_bytep display_row));
  1300. #endif
  1301. #ifdef PNG_SEQUENTIAL_READ_SUPPORTED
  1302. /* Read the whole image into memory at once. */
  1303. PNG_EXPORT(57, void, png_read_image, (png_structp png_ptr, png_bytepp image));
  1304. #endif
  1305. /* Write a row of image data */
  1306. PNG_EXPORT(58, void, png_write_row,
  1307. (png_structp png_ptr, png_const_bytep row));
  1308. /* Write a few rows of image data: (*row) is not written; however, the type
  1309. * is declared as writeable to maintain compatibility with previous versions
  1310. * of libpng and to allow the 'display_row' array from read_rows to be passed
  1311. * unchanged to write_rows.
  1312. */
  1313. PNG_EXPORT(59, void, png_write_rows, (png_structp png_ptr, png_bytepp row,
  1314. png_uint_32 num_rows));
  1315. /* Write the image data */
  1316. PNG_EXPORT(60, void, png_write_image,
  1317. (png_structp png_ptr, png_bytepp image));
  1318. /* Write the end of the PNG file. */
  1319. PNG_EXPORT(61, void, png_write_end,
  1320. (png_structp png_ptr, png_infop info_ptr));
  1321. #ifdef PNG_SEQUENTIAL_READ_SUPPORTED
  1322. /* Read the end of the PNG file. */
  1323. PNG_EXPORT(62, void, png_read_end, (png_structp png_ptr, png_infop info_ptr));
  1324. #endif
  1325. /* Free any memory associated with the png_info_struct */
  1326. PNG_EXPORT(63, void, png_destroy_info_struct, (png_structp png_ptr,
  1327. png_infopp info_ptr_ptr));
  1328. /* Free any memory associated with the png_struct and the png_info_structs */
  1329. PNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr,
  1330. png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));
  1331. /* Free any memory associated with the png_struct and the png_info_structs */
  1332. PNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr,
  1333. png_infopp info_ptr_ptr));
  1334. /* Set the libpng method of handling chunk CRC errors */
  1335. PNG_EXPORT(66, void, png_set_crc_action,
  1336. (png_structp png_ptr, int crit_action, int ancil_action));
  1337. /* Values for png_set_crc_action() say how to handle CRC errors in
  1338. * ancillary and critical chunks, and whether to use the data contained
  1339. * therein. Note that it is impossible to "discard" data in a critical
  1340. * chunk. For versions prior to 0.90, the action was always error/quit,
  1341. * whereas in version 0.90 and later, the action for CRC errors in ancillary
  1342. * chunks is warn/discard. These values should NOT be changed.
  1343. *
  1344. * value action:critical action:ancillary
  1345. */
  1346. #define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */
  1347. #define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */
  1348. #define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */
  1349. #define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */
  1350. #define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */
  1351. #define PNG_CRC_NO_CHANGE 5 /* use current value use current value */
  1352. /* These functions give the user control over the scan-line filtering in
  1353. * libpng and the compression methods used by zlib. These functions are
  1354. * mainly useful for testing, as the defaults should work with most users.
  1355. * Those users who are tight on memory or want faster performance at the
  1356. * expense of compression can modify them. See the compression library
  1357. * header file (zlib.h) for an explination of the compression functions.
  1358. */
  1359. /* Set the filtering method(s) used by libpng. Currently, the only valid
  1360. * value for "method" is 0.
  1361. */
  1362. PNG_EXPORT(67, void, png_set_filter,
  1363. (png_structp png_ptr, int method, int filters));
  1364. /* Flags for png_set_filter() to say which filters to use. The flags
  1365. * are chosen so that they don't conflict with real filter types
  1366. * below, in case they are supplied instead of the #defined constants.
  1367. * These values should NOT be changed.
  1368. */
  1369. #define PNG_NO_FILTERS 0x00
  1370. #define PNG_FILTER_NONE 0x08
  1371. #define PNG_FILTER_SUB 0x10
  1372. #define PNG_FILTER_UP 0x20
  1373. #define PNG_FILTER_AVG 0x40
  1374. #define PNG_FILTER_PAETH 0x80
  1375. #define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
  1376. PNG_FILTER_AVG | PNG_FILTER_PAETH)
  1377. /* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
  1378. * These defines should NOT be changed.
  1379. */
  1380. #define PNG_FILTER_VALUE_NONE 0
  1381. #define PNG_FILTER_VALUE_SUB 1
  1382. #define PNG_FILTER_VALUE_UP 2
  1383. #define PNG_FILTER_VALUE_AVG 3
  1384. #define PNG_FILTER_VALUE_PAETH 4
  1385. #define PNG_FILTER_VALUE_LAST 5
  1386. #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */
  1387. PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structp png_ptr,
  1388. int heuristic_method, int num_weights, png_const_doublep filter_weights,
  1389. png_const_doublep filter_costs))
  1390. PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
  1391. (png_structp png_ptr,
  1392. int heuristic_method, int num_weights, png_const_fixed_point_p
  1393. filter_weights, png_const_fixed_point_p filter_costs))
  1394. #endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
  1395. /* The following are no longer used and will be removed from libpng-1.7: */
  1396. #define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */
  1397. #define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */
  1398. #define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */
  1399. #define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */
  1400. #ifdef PNG_WRITE_SUPPORTED
  1401. /* Set the library compression level. Currently, valid values range from
  1402. * 0 - 9, corresponding directly to the zlib compression levels 0 - 9
  1403. * (0 - no compression, 9 - "maximal" compression). Note that tests have
  1404. * shown that zlib compression levels 3-6 usually perform as well as level 9
  1405. * for PNG images, and do considerably fewer caclulations. In the future,
  1406. * these values may not correspond directly to the zlib compression levels.
  1407. */
  1408. #ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
  1409. PNG_EXPORT(69, void, png_set_compression_level,
  1410. (png_structp png_ptr, int level));
  1411. PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structp png_ptr,
  1412. int mem_level));
  1413. PNG_EXPORT(71, void, png_set_compression_strategy, (png_structp png_ptr,
  1414. int strategy));
  1415. /* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
  1416. * smaller value of window_bits if it can do so safely.
  1417. */
  1418. PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structp png_ptr,
  1419. int window_bits));
  1420. PNG_EXPORT(73, void, png_set_compression_method, (png_structp png_ptr,
  1421. int method));
  1422. #endif /* WRITE_CUSTOMIZE_COMPRESSION */
  1423. #ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
  1424. /* Also set zlib parameters for compressing non-IDAT chunks */
  1425. PNG_EXPORT(222, void, png_set_text_compression_level,
  1426. (png_structp png_ptr, int level));
  1427. PNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structp png_ptr,
  1428. int mem_level));
  1429. PNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structp png_ptr,
  1430. int strategy));
  1431. /* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
  1432. * smaller value of window_bits if it can do so safely.
  1433. */
  1434. PNG_EXPORT(225, void, png_set_text_compression_window_bits, (png_structp
  1435. png_ptr, int window_bits));
  1436. PNG_EXPORT(226, void, png_set_text_compression_method, (png_structp png_ptr,
  1437. int method));
  1438. #endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */
  1439. #endif /* WRITE */
  1440. /* These next functions are called for input/output, memory, and error
  1441. * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c,
  1442. * and call standard C I/O routines such as fread(), fwrite(), and
  1443. * fprintf(). These functions can be made to use other I/O routines
  1444. * at run time for those applications that need to handle I/O in a
  1445. * different manner by calling png_set_???_fn(). See libpng-manual.txt for
  1446. * more information.
  1447. */
  1448. #ifdef PNG_STDIO_SUPPORTED
  1449. /* Initialize the input/output for the PNG file to the default functions. */
  1450. PNG_EXPORT(74, void, png_init_io, (png_structp png_ptr, png_FILE_p fp));
  1451. #endif
  1452. /* Replace the (error and abort), and warning functions with user
  1453. * supplied functions. If no messages are to be printed you must still
  1454. * write and use replacement functions. The replacement error_fn should
  1455. * still do a longjmp to the last setjmp location if you are using this
  1456. * method of error handling. If error_fn or warning_fn is NULL, the
  1457. * default function will be used.
  1458. */
  1459. PNG_EXPORT(75, void, png_set_error_fn,
  1460. (png_structp png_ptr, png_voidp error_ptr,
  1461. png_error_ptr error_fn, png_error_ptr warning_fn));
  1462. /* Return the user pointer associated with the error functions */
  1463. PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structp png_ptr));
  1464. /* Replace the default data output functions with a user supplied one(s).
  1465. * If buffered output is not used, then output_flush_fn can be set to NULL.
  1466. * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time
  1467. * output_flush_fn will be ignored (and thus can be NULL).
  1468. * It is probably a mistake to use NULL for output_flush_fn if
  1469. * write_data_fn is not also NULL unless you have built libpng with
  1470. * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's
  1471. * default flush function, which uses the standard *FILE structure, will
  1472. * be used.
  1473. */
  1474. PNG_EXPORT(77, void, png_set_write_fn, (png_structp png_ptr, png_voidp io_ptr,
  1475. png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));
  1476. /* Replace the default data input function with a user supplied one. */
  1477. PNG_EXPORT(78, void, png_set_read_fn, (png_structp png_ptr, png_voidp io_ptr,
  1478. png_rw_ptr read_data_fn));
  1479. /* Return the user pointer associated with the I/O functions */
  1480. PNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_structp png_ptr));
  1481. PNG_EXPORT(80, void, png_set_read_status_fn, (png_structp png_ptr,
  1482. png_read_status_ptr read_row_fn));
  1483. PNG_EXPORT(81, void, png_set_write_status_fn, (png_structp png_ptr,
  1484. png_write_status_ptr write_row_fn));
  1485. #ifdef PNG_USER_MEM_SUPPORTED
  1486. /* Replace the default memory allocation functions with user supplied one(s). */
  1487. PNG_EXPORT(82, void, png_set_mem_fn, (png_structp png_ptr, png_voidp mem_ptr,
  1488. png_malloc_ptr malloc_fn, png_free_ptr free_fn));
  1489. /* Return the user pointer associated with the memory functions */
  1490. PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structp png_ptr));
  1491. #endif
  1492. #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
  1493. PNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structp png_ptr,
  1494. png_user_transform_ptr read_user_transform_fn));
  1495. #endif
  1496. #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
  1497. PNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structp png_ptr,
  1498. png_user_transform_ptr write_user_transform_fn));
  1499. #endif
  1500. #ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
  1501. PNG_EXPORT(86, void, png_set_user_transform_info, (png_structp png_ptr,
  1502. png_voidp user_transform_ptr, int user_transform_depth,
  1503. int user_transform_channels));
  1504. /* Return the user pointer associated with the user transform functions */
  1505. PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr,
  1506. (png_const_structp png_ptr));
  1507. #endif
  1508. #ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED
  1509. /* Return information about the row currently being processed. Note that these
  1510. * APIs do not fail but will return unexpected results if called outside a user
  1511. * transform callback. Also note that when transforming an interlaced image the
  1512. * row number is the row number within the sub-image of the interlace pass, so
  1513. * the value will increase to the height of the sub-image (not the full image)
  1514. * then reset to 0 for the next pass.
  1515. *
  1516. * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to
  1517. * find the output pixel (x,y) given an interlaced sub-image pixel
  1518. * (row,col,pass). (See below for these macros.)
  1519. */
  1520. PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structp));
  1521. PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structp));
  1522. #endif
  1523. #ifdef PNG_USER_CHUNKS_SUPPORTED
  1524. PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structp png_ptr,
  1525. png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));
  1526. PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structp png_ptr));
  1527. #endif
  1528. #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
  1529. /* Sets the function callbacks for the push reader, and a pointer to a
  1530. * user-defined structure available to the callback functions.
  1531. */
  1532. PNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structp png_ptr,
  1533. png_voidp progressive_ptr, png_progressive_info_ptr info_fn,
  1534. png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn));
  1535. /* Returns the user pointer associated with the push read functions */
  1536. PNG_EXPORT(91, png_voidp, png_get_progressive_ptr, (png_const_structp png_ptr));
  1537. /* Function to be called when data becomes available */
  1538. PNG_EXPORT(92, void, png_process_data,
  1539. (png_structp png_ptr, png_infop info_ptr,
  1540. png_bytep buffer, png_size_t buffer_size));
  1541. /* A function which may be called *only* within png_process_data to stop the
  1542. * processing of any more data. The function returns the number of bytes
  1543. * remaining, excluding any that libpng has cached internally. A subsequent
  1544. * call to png_process_data must supply these bytes again. If the argument
  1545. * 'save' is set to true the routine will first save all the pending data and
  1546. * will always return 0.
  1547. */
  1548. PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structp, int save));
  1549. /* A function which may be called *only* outside (after) a call to
  1550. * png_process_data. It returns the number of bytes of data to skip in the
  1551. * input. Normally it will return 0, but if it returns a non-zero value the
  1552. * application must skip than number of bytes of input data and pass the
  1553. * following data to the next call to png_process_data.
  1554. */
  1555. PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structp));
  1556. #ifdef PNG_READ_INTERLACING_SUPPORTED
  1557. /* Function that combines rows. 'new_row' is a flag that should come from
  1558. * the callback and be non-NULL if anything needs to be done; the library
  1559. * stores its own version of the new data internally and ignores the passed
  1560. * in value.
  1561. */
  1562. PNG_EXPORT(93, void, png_progressive_combine_row, (png_structp png_ptr,
  1563. png_bytep old_row, png_const_bytep new_row));
  1564. #endif /* PNG_READ_INTERLACING_SUPPORTED */
  1565. #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
  1566. PNG_EXPORTA(94, png_voidp, png_malloc,
  1567. (png_structp png_ptr, png_alloc_size_t size),
  1568. PNG_ALLOCATED);
  1569. /* Added at libpng version 1.4.0 */
  1570. PNG_EXPORTA(95, png_voidp, png_calloc,
  1571. (png_structp png_ptr, png_alloc_size_t size),
  1572. PNG_ALLOCATED);
  1573. /* Added at libpng version 1.2.4 */
  1574. PNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_structp png_ptr,
  1575. png_alloc_size_t size), PNG_ALLOCATED);
  1576. /* Frees a pointer allocated by png_malloc() */
  1577. PNG_EXPORT(97, void, png_free, (png_structp png_ptr, png_voidp ptr));
  1578. /* Free data that was allocated internally */
  1579. PNG_EXPORT(98, void, png_free_data,
  1580. (png_structp png_ptr, png_infop info_ptr, png_uint_32 free_me, int num));
  1581. /* Reassign responsibility for freeing existing data, whether allocated
  1582. * by libpng or by the application */
  1583. PNG_EXPORT(99, void, png_data_freer,
  1584. (png_structp png_ptr, png_infop info_ptr, int freer, png_uint_32 mask));
  1585. /* Assignments for png_data_freer */
  1586. #define PNG_DESTROY_WILL_FREE_DATA 1
  1587. #define PNG_SET_WILL_FREE_DATA 1
  1588. #define PNG_USER_WILL_FREE_DATA 2
  1589. /* Flags for png_ptr->free_me and info_ptr->free_me */
  1590. #define PNG_FREE_HIST 0x0008
  1591. #define PNG_FREE_ICCP 0x0010
  1592. #define PNG_FREE_SPLT 0x0020
  1593. #define PNG_FREE_ROWS 0x0040
  1594. #define PNG_FREE_PCAL 0x0080
  1595. #define PNG_FREE_SCAL 0x0100
  1596. #define PNG_FREE_UNKN 0x0200
  1597. #define PNG_FREE_LIST 0x0400
  1598. #define PNG_FREE_PLTE 0x1000
  1599. #define PNG_FREE_TRNS 0x2000
  1600. #define PNG_FREE_TEXT 0x4000
  1601. #define PNG_FREE_ALL 0x7fff
  1602. #define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
  1603. #ifdef PNG_USER_MEM_SUPPORTED
  1604. PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_structp png_ptr,
  1605. png_alloc_size_t size), PNG_ALLOCATED);
  1606. PNG_EXPORT(101, void, png_free_default, (png_structp png_ptr, png_voidp ptr));
  1607. #endif
  1608. #ifdef PNG_ERROR_TEXT_SUPPORTED
  1609. /* Fatal error in PNG image of libpng - can't continue */
  1610. PNG_EXPORTA(102, void, png_error,
  1611. (png_structp png_ptr, png_const_charp error_message),
  1612. PNG_NORETURN);
  1613. /* The same, but the chunk name is prepended to the error string. */
  1614. PNG_EXPORTA(103, void, png_chunk_error, (png_structp png_ptr,
  1615. png_const_charp error_message), PNG_NORETURN);
  1616. #else
  1617. /* Fatal error in PNG image of libpng - can't continue */
  1618. PNG_EXPORTA(104, void, png_err, (png_structp png_ptr), PNG_NORETURN);
  1619. # define png_error(s1,s2) png_err(s1)
  1620. # define png_chunk_error(s1,s2) png_err(s1)
  1621. #endif
  1622. #ifdef PNG_WARNINGS_SUPPORTED
  1623. /* Non-fatal error in libpng. Can continue, but may have a problem. */
  1624. PNG_EXPORT(105, void, png_warning, (png_structp png_ptr,
  1625. png_const_charp warning_message));
  1626. /* Non-fatal error in libpng, chunk name is prepended to message. */
  1627. PNG_EXPORT(106, void, png_chunk_warning, (png_structp png_ptr,
  1628. png_const_charp warning_message));
  1629. #else
  1630. # define png_warning(s1,s2) ((void)(s1))
  1631. # define png_chunk_warning(s1,s2) ((void)(s1))
  1632. #endif
  1633. #ifdef PNG_BENIGN_ERRORS_SUPPORTED
  1634. /* Benign error in libpng. Can continue, but may have a problem.
  1635. * User can choose whether to handle as a fatal error or as a warning. */
  1636. # undef png_benign_error
  1637. PNG_EXPORT(107, void, png_benign_error, (png_structp png_ptr,
  1638. png_const_charp warning_message));
  1639. /* Same, chunk name is prepended to message. */
  1640. # undef png_chunk_benign_error
  1641. PNG_EXPORT(108, void, png_chunk_benign_error, (png_structp png_ptr,
  1642. png_const_charp warning_message));
  1643. PNG_EXPORT(109, void, png_set_benign_errors,
  1644. (png_structp png_ptr, int allowed));
  1645. #else
  1646. # ifdef PNG_ALLOW_BENIGN_ERRORS
  1647. # define png_benign_error png_warning
  1648. # define png_chunk_benign_error png_chunk_warning
  1649. # else
  1650. # define png_benign_error png_error
  1651. # define png_chunk_benign_error png_chunk_error
  1652. # endif
  1653. #endif
  1654. /* The png_set_<chunk> functions are for storing values in the png_info_struct.
  1655. * Similarly, the png_get_<chunk> calls are used to read values from the
  1656. * png_info_struct, either storing the parameters in the passed variables, or
  1657. * setting pointers into the png_info_struct where the data is stored. The
  1658. * png_get_<chunk> functions return a non-zero value if the data was available
  1659. * in info_ptr, or return zero and do not change any of the parameters if the
  1660. * data was not available.
  1661. *
  1662. * These functions should be used instead of directly accessing png_info
  1663. * to avoid problems with future changes in the size and internal layout of
  1664. * png_info_struct.
  1665. */
  1666. /* Returns "flag" if chunk data is valid in info_ptr. */
  1667. PNG_EXPORT(110, png_uint_32, png_get_valid,
  1668. (png_const_structp png_ptr, png_const_infop info_ptr,
  1669. png_uint_32 flag));
  1670. /* Returns number of bytes needed to hold a transformed row. */
  1671. PNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structp png_ptr,
  1672. png_const_infop info_ptr));
  1673. #ifdef PNG_INFO_IMAGE_SUPPORTED
  1674. /* Returns row_pointers, which is an array of pointers to scanlines that was
  1675. * returned from png_read_png().
  1676. */
  1677. PNG_EXPORT(112, png_bytepp, png_get_rows,
  1678. (png_const_structp png_ptr, png_const_infop info_ptr));
  1679. /* Set row_pointers, which is an array of pointers to scanlines for use
  1680. * by png_write_png().
  1681. */
  1682. PNG_EXPORT(113, void, png_set_rows, (png_structp png_ptr,
  1683. png_infop info_ptr, png_bytepp row_pointers));
  1684. #endif
  1685. /* Returns number of color channels in image. */
  1686. PNG_EXPORT(114, png_byte, png_get_channels,
  1687. (png_const_structp png_ptr, png_const_infop info_ptr));
  1688. #ifdef PNG_EASY_ACCESS_SUPPORTED
  1689. /* Returns image width in pixels. */
  1690. PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structp png_ptr,
  1691. png_const_infop info_ptr));
  1692. /* Returns image height in pixels. */
  1693. PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structp png_ptr,
  1694. png_const_infop info_ptr));
  1695. /* Returns image bit_depth. */
  1696. PNG_EXPORT(117, png_byte, png_get_bit_depth,
  1697. (png_const_structp png_ptr, png_const_infop info_ptr));
  1698. /* Returns image color_type. */
  1699. PNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structp png_ptr,
  1700. png_const_infop info_ptr));
  1701. /* Returns image filter_type. */
  1702. PNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structp png_ptr,
  1703. png_const_infop info_ptr));
  1704. /* Returns image interlace_type. */
  1705. PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structp png_ptr,
  1706. png_const_infop info_ptr));
  1707. /* Returns image compression_type. */
  1708. PNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structp png_ptr,
  1709. png_const_infop info_ptr));
  1710. /* Returns image resolution in pixels per meter, from pHYs chunk data. */
  1711. PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter,
  1712. (png_const_structp png_ptr, png_const_infop info_ptr));
  1713. PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter,
  1714. (png_const_structp png_ptr, png_const_infop info_ptr));
  1715. PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter,
  1716. (png_const_structp png_ptr, png_const_infop info_ptr));
  1717. /* Returns pixel aspect ratio, computed from pHYs chunk data. */
  1718. PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio,
  1719. (png_const_structp png_ptr, png_const_infop info_ptr))
  1720. PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed,
  1721. (png_const_structp png_ptr, png_const_infop info_ptr))
  1722. /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
  1723. PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels,
  1724. (png_const_structp png_ptr, png_const_infop info_ptr));
  1725. PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels,
  1726. (png_const_structp png_ptr, png_const_infop info_ptr));
  1727. PNG_EXPORT(128, png_int_32, png_get_x_offset_microns,
  1728. (png_const_structp png_ptr, png_const_infop info_ptr));
  1729. PNG_EXPORT(129, png_int_32, png_get_y_offset_microns,
  1730. (png_const_structp png_ptr, png_const_infop info_ptr));
  1731. #endif /* PNG_EASY_ACCESS_SUPPORTED */
  1732. /* Returns pointer to signature string read from PNG header */
  1733. PNG_EXPORT(130, png_const_bytep, png_get_signature,
  1734. (png_const_structp png_ptr, png_infop info_ptr));
  1735. #ifdef PNG_bKGD_SUPPORTED
  1736. PNG_EXPORT(131, png_uint_32, png_get_bKGD,
  1737. (png_const_structp png_ptr, png_infop info_ptr,
  1738. png_color_16p *background));
  1739. #endif
  1740. #ifdef PNG_bKGD_SUPPORTED
  1741. PNG_EXPORT(132, void, png_set_bKGD, (png_structp png_ptr, png_infop info_ptr,
  1742. png_const_color_16p background));
  1743. #endif
  1744. #ifdef PNG_cHRM_SUPPORTED
  1745. PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structp png_ptr,
  1746. png_const_infop info_ptr, double *white_x, double *white_y, double *red_x,
  1747. double *red_y, double *green_x, double *green_y, double *blue_x,
  1748. double *blue_y))
  1749. PNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_structp png_ptr,
  1750. png_const_infop info_ptr, double *red_X, double *red_Y, double *red_Z,
  1751. double *green_X, double *green_Y, double *green_Z, double *blue_X,
  1752. double *blue_Y, double *blue_Z))
  1753. #ifdef PNG_FIXED_POINT_SUPPORTED /* Otherwise not implemented */
  1754. PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,
  1755. (png_const_structp png_ptr,
  1756. png_const_infop info_ptr, png_fixed_point *int_white_x,
  1757. png_fixed_point *int_white_y, png_fixed_point *int_red_x,
  1758. png_fixed_point *int_red_y, png_fixed_point *int_green_x,
  1759. png_fixed_point *int_green_y, png_fixed_point *int_blue_x,
  1760. png_fixed_point *int_blue_y))
  1761. #endif
  1762. PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed,
  1763. (png_structp png_ptr, png_const_infop info_ptr,
  1764. png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
  1765. png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
  1766. png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
  1767. png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
  1768. png_fixed_point *int_blue_Z))
  1769. #endif
  1770. #ifdef PNG_cHRM_SUPPORTED
  1771. PNG_FP_EXPORT(135, void, png_set_cHRM,
  1772. (png_structp png_ptr, png_infop info_ptr,
  1773. double white_x, double white_y, double red_x, double red_y, double green_x,
  1774. double green_y, double blue_x, double blue_y))
  1775. PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_structp png_ptr,
  1776. png_infop info_ptr, double red_X, double red_Y, double red_Z,
  1777. double green_X, double green_Y, double green_Z, double blue_X,
  1778. double blue_Y, double blue_Z))
  1779. PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_structp png_ptr,
  1780. png_infop info_ptr, png_fixed_point int_white_x,
  1781. png_fixed_point int_white_y, png_fixed_point int_red_x,
  1782. png_fixed_point int_red_y, png_fixed_point int_green_x,
  1783. png_fixed_point int_green_y, png_fixed_point int_blue_x,
  1784. png_fixed_point int_blue_y))
  1785. PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_structp png_ptr,
  1786. png_infop info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y,
  1787. png_fixed_point int_red_Z, png_fixed_point int_green_X,
  1788. png_fixed_point int_green_Y, png_fixed_point int_green_Z,
  1789. png_fixed_point int_blue_X, png_fixed_point int_blue_Y,
  1790. png_fixed_point int_blue_Z))
  1791. #endif
  1792. #ifdef PNG_gAMA_SUPPORTED
  1793. PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA,
  1794. (png_const_structp png_ptr, png_const_infop info_ptr,
  1795. double *file_gamma))
  1796. PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed,
  1797. (png_const_structp png_ptr, png_const_infop info_ptr,
  1798. png_fixed_point *int_file_gamma))
  1799. #endif
  1800. #ifdef PNG_gAMA_SUPPORTED
  1801. PNG_FP_EXPORT(139, void, png_set_gAMA, (png_structp png_ptr,
  1802. png_infop info_ptr, double file_gamma))
  1803. PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_structp png_ptr,
  1804. png_infop info_ptr, png_fixed_point int_file_gamma))
  1805. #endif
  1806. #ifdef PNG_hIST_SUPPORTED
  1807. PNG_EXPORT(141, png_uint_32, png_get_hIST,
  1808. (png_const_structp png_ptr, png_const_infop info_ptr,
  1809. png_uint_16p *hist));
  1810. #endif
  1811. #ifdef PNG_hIST_SUPPORTED
  1812. PNG_EXPORT(142, void, png_set_hIST, (png_structp png_ptr,
  1813. png_infop info_ptr, png_const_uint_16p hist));
  1814. #endif
  1815. PNG_EXPORT(143, png_uint_32, png_get_IHDR,
  1816. (png_structp png_ptr, png_infop info_ptr,
  1817. png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type,
  1818. int *interlace_method, int *compression_method, int *filter_method));
  1819. PNG_EXPORT(144, void, png_set_IHDR,
  1820. (png_structp png_ptr, png_infop info_ptr,
  1821. png_uint_32 width, png_uint_32 height, int bit_depth, int color_type,
  1822. int interlace_method, int compression_method, int filter_method));
  1823. #ifdef PNG_oFFs_SUPPORTED
  1824. PNG_EXPORT(145, png_uint_32, png_get_oFFs,
  1825. (png_const_structp png_ptr, png_const_infop info_ptr,
  1826. png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type));
  1827. #endif
  1828. #ifdef PNG_oFFs_SUPPORTED
  1829. PNG_EXPORT(146, void, png_set_oFFs,
  1830. (png_structp png_ptr, png_infop info_ptr,
  1831. png_int_32 offset_x, png_int_32 offset_y, int unit_type));
  1832. #endif
  1833. #ifdef PNG_pCAL_SUPPORTED
  1834. PNG_EXPORT(147, png_uint_32, png_get_pCAL,
  1835. (png_const_structp png_ptr, png_const_infop info_ptr,
  1836. png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type,
  1837. int *nparams,
  1838. png_charp *units, png_charpp *params));
  1839. #endif
  1840. #ifdef PNG_pCAL_SUPPORTED
  1841. PNG_EXPORT(148, void, png_set_pCAL, (png_structp png_ptr,
  1842. png_infop info_ptr,
  1843. png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type,
  1844. int nparams, png_const_charp units, png_charpp params));
  1845. #endif
  1846. #ifdef PNG_pHYs_SUPPORTED
  1847. PNG_EXPORT(149, png_uint_32, png_get_pHYs,
  1848. (png_const_structp png_ptr, png_const_infop info_ptr,
  1849. png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
  1850. #endif
  1851. #ifdef PNG_pHYs_SUPPORTED
  1852. PNG_EXPORT(150, void, png_set_pHYs,
  1853. (png_structp png_ptr, png_infop info_ptr,
  1854. png_uint_32 res_x, png_uint_32 res_y, int unit_type));
  1855. #endif
  1856. PNG_EXPORT(151, png_uint_32, png_get_PLTE,
  1857. (png_const_structp png_ptr, png_const_infop info_ptr,
  1858. png_colorp *palette, int *num_palette));
  1859. PNG_EXPORT(152, void, png_set_PLTE,
  1860. (png_structp png_ptr, png_infop info_ptr,
  1861. png_const_colorp palette, int num_palette));
  1862. #ifdef PNG_sBIT_SUPPORTED
  1863. PNG_EXPORT(153, png_uint_32, png_get_sBIT,
  1864. (png_const_structp png_ptr, png_infop info_ptr,
  1865. png_color_8p *sig_bit));
  1866. #endif
  1867. #ifdef PNG_sBIT_SUPPORTED
  1868. PNG_EXPORT(154, void, png_set_sBIT,
  1869. (png_structp png_ptr, png_infop info_ptr, png_const_color_8p sig_bit));
  1870. #endif
  1871. #ifdef PNG_sRGB_SUPPORTED
  1872. PNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structp png_ptr,
  1873. png_const_infop info_ptr, int *file_srgb_intent));
  1874. #endif
  1875. #ifdef PNG_sRGB_SUPPORTED
  1876. PNG_EXPORT(156, void, png_set_sRGB,
  1877. (png_structp png_ptr, png_infop info_ptr, int srgb_intent));
  1878. PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_structp png_ptr,
  1879. png_infop info_ptr, int srgb_intent));
  1880. #endif
  1881. #ifdef PNG_iCCP_SUPPORTED
  1882. PNG_EXPORT(158, png_uint_32, png_get_iCCP,
  1883. (png_const_structp png_ptr, png_const_infop info_ptr,
  1884. png_charpp name, int *compression_type, png_bytepp profile,
  1885. png_uint_32 *proflen));
  1886. #endif
  1887. #ifdef PNG_iCCP_SUPPORTED
  1888. PNG_EXPORT(159, void, png_set_iCCP,
  1889. (png_structp png_ptr, png_infop info_ptr,
  1890. png_const_charp name, int compression_type, png_const_bytep profile,
  1891. png_uint_32 proflen));
  1892. #endif
  1893. #ifdef PNG_sPLT_SUPPORTED
  1894. PNG_EXPORT(160, png_uint_32, png_get_sPLT,
  1895. (png_const_structp png_ptr, png_const_infop info_ptr,
  1896. png_sPLT_tpp entries));
  1897. #endif
  1898. #ifdef PNG_sPLT_SUPPORTED
  1899. PNG_EXPORT(161, void, png_set_sPLT,
  1900. (png_structp png_ptr, png_infop info_ptr,
  1901. png_const_sPLT_tp entries, int nentries));
  1902. #endif
  1903. #ifdef PNG_TEXT_SUPPORTED
  1904. /* png_get_text also returns the number of text chunks in *num_text */
  1905. PNG_EXPORT(162, png_uint_32, png_get_text,
  1906. (png_const_structp png_ptr, png_const_infop info_ptr,
  1907. png_textp *text_ptr, int *num_text));
  1908. #endif
  1909. /* Note while png_set_text() will accept a structure whose text,
  1910. * language, and translated keywords are NULL pointers, the structure
  1911. * returned by png_get_text will always contain regular
  1912. * zero-terminated C strings. They might be empty strings but
  1913. * they will never be NULL pointers.
  1914. */
  1915. #ifdef PNG_TEXT_SUPPORTED
  1916. PNG_EXPORT(163, void, png_set_text,
  1917. (png_structp png_ptr, png_infop info_ptr,
  1918. png_const_textp text_ptr, int num_text));
  1919. #endif
  1920. #ifdef PNG_tIME_SUPPORTED
  1921. PNG_EXPORT(164, png_uint_32, png_get_tIME,
  1922. (png_const_structp png_ptr, png_infop info_ptr, png_timep *mod_time));
  1923. #endif
  1924. #ifdef PNG_tIME_SUPPORTED
  1925. PNG_EXPORT(165, void, png_set_tIME,
  1926. (png_structp png_ptr, png_infop info_ptr, png_const_timep mod_time));
  1927. #endif
  1928. #ifdef PNG_tRNS_SUPPORTED
  1929. PNG_EXPORT(166, png_uint_32, png_get_tRNS,
  1930. (png_const_structp png_ptr, png_infop info_ptr,
  1931. png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color));
  1932. #endif
  1933. #ifdef PNG_tRNS_SUPPORTED
  1934. PNG_EXPORT(167, void, png_set_tRNS,
  1935. (png_structp png_ptr, png_infop info_ptr,
  1936. png_const_bytep trans_alpha, int num_trans,
  1937. png_const_color_16p trans_color));
  1938. #endif
  1939. #ifdef PNG_sCAL_SUPPORTED
  1940. PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL,
  1941. (png_const_structp png_ptr, png_const_infop info_ptr,
  1942. int *unit, double *width, double *height))
  1943. #ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
  1944. /* NOTE: this API is currently implemented using floating point arithmetic,
  1945. * consequently it can only be used on systems with floating point support.
  1946. * In any case the range of values supported by png_fixed_point is small and it
  1947. * is highly recommended that png_get_sCAL_s be used instead.
  1948. */
  1949. PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed,
  1950. (png_structp png_ptr, png_const_infop info_ptr, int *unit,
  1951. png_fixed_point *width,
  1952. png_fixed_point *height))
  1953. #endif
  1954. PNG_EXPORT(169, png_uint_32, png_get_sCAL_s,
  1955. (png_const_structp png_ptr, png_const_infop info_ptr,
  1956. int *unit, png_charpp swidth, png_charpp sheight));
  1957. PNG_FP_EXPORT(170, void, png_set_sCAL,
  1958. (png_structp png_ptr, png_infop info_ptr,
  1959. int unit, double width, double height))
  1960. PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_structp png_ptr,
  1961. png_infop info_ptr, int unit, png_fixed_point width,
  1962. png_fixed_point height))
  1963. PNG_EXPORT(171, void, png_set_sCAL_s,
  1964. (png_structp png_ptr, png_infop info_ptr,
  1965. int unit, png_const_charp swidth, png_const_charp sheight));
  1966. #endif /* PNG_sCAL_SUPPORTED */
  1967. #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
  1968. /* Provide a list of chunks and how they are to be handled, if the built-in
  1969. handling or default unknown chunk handling is not desired. Any chunks not
  1970. listed will be handled in the default manner. The IHDR and IEND chunks
  1971. must not be listed. Because this turns off the default handling for chunks
  1972. that would otherwise be recognized the behavior of libpng transformations may
  1973. well become incorrect!
  1974. keep = 0: PNG_HANDLE_CHUNK_AS_DEFAULT: follow default behavior
  1975. = 1: PNG_HANDLE_CHUNK_NEVER: do not keep
  1976. = 2: PNG_HANDLE_CHUNK_IF_SAFE: keep only if safe-to-copy
  1977. = 3: PNG_HANDLE_CHUNK_ALWAYS: keep even if unsafe-to-copy
  1978. */
  1979. PNG_EXPORT(172, void, png_set_keep_unknown_chunks,
  1980. (png_structp png_ptr, int keep,
  1981. png_const_bytep chunk_list, int num_chunks));
  1982. /* The handling code is returned; the result is therefore true (non-zero) if
  1983. * special handling is required, false for the default handling.
  1984. */
  1985. PNG_EXPORT(173, int, png_handle_as_unknown, (png_structp png_ptr,
  1986. png_const_bytep chunk_name));
  1987. #endif
  1988. #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
  1989. PNG_EXPORT(174, void, png_set_unknown_chunks, (png_structp png_ptr,
  1990. png_infop info_ptr, png_const_unknown_chunkp unknowns,
  1991. int num_unknowns));
  1992. PNG_EXPORT(175, void, png_set_unknown_chunk_location,
  1993. (png_structp png_ptr, png_infop info_ptr, int chunk, int location));
  1994. PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structp png_ptr,
  1995. png_const_infop info_ptr, png_unknown_chunkpp entries));
  1996. #endif
  1997. /* Png_free_data() will turn off the "valid" flag for anything it frees.
  1998. * If you need to turn it off for a chunk that your application has freed,
  1999. * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK);
  2000. */
  2001. PNG_EXPORT(177, void, png_set_invalid,
  2002. (png_structp png_ptr, png_infop info_ptr, int mask));
  2003. #ifdef PNG_INFO_IMAGE_SUPPORTED
  2004. /* The "params" pointer is currently not used and is for future expansion. */
  2005. PNG_EXPORT(178, void, png_read_png, (png_structp png_ptr, png_infop info_ptr,
  2006. int transforms, png_voidp params));
  2007. PNG_EXPORT(179, void, png_write_png, (png_structp png_ptr, png_infop info_ptr,
  2008. int transforms, png_voidp params));
  2009. #endif
  2010. PNG_EXPORT(180, png_const_charp, png_get_copyright,
  2011. (png_const_structp png_ptr));
  2012. PNG_EXPORT(181, png_const_charp, png_get_header_ver,
  2013. (png_const_structp png_ptr));
  2014. PNG_EXPORT(182, png_const_charp, png_get_header_version,
  2015. (png_const_structp png_ptr));
  2016. PNG_EXPORT(183, png_const_charp, png_get_libpng_ver,
  2017. (png_const_structp png_ptr));
  2018. #ifdef PNG_MNG_FEATURES_SUPPORTED
  2019. PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structp png_ptr,
  2020. png_uint_32 mng_features_permitted));
  2021. #endif
  2022. /* For use in png_set_keep_unknown, added to version 1.2.6 */
  2023. #define PNG_HANDLE_CHUNK_AS_DEFAULT 0
  2024. #define PNG_HANDLE_CHUNK_NEVER 1
  2025. #define PNG_HANDLE_CHUNK_IF_SAFE 2
  2026. #define PNG_HANDLE_CHUNK_ALWAYS 3
  2027. /* Strip the prepended error numbers ("#nnn ") from error and warning
  2028. * messages before passing them to the error or warning handler.
  2029. */
  2030. #ifdef PNG_ERROR_NUMBERS_SUPPORTED
  2031. PNG_EXPORT(185, void, png_set_strip_error_numbers,
  2032. (png_structp png_ptr,
  2033. png_uint_32 strip_mode));
  2034. #endif
  2035. /* Added in libpng-1.2.6 */
  2036. #ifdef PNG_SET_USER_LIMITS_SUPPORTED
  2037. PNG_EXPORT(186, void, png_set_user_limits, (png_structp png_ptr,
  2038. png_uint_32 user_width_max, png_uint_32 user_height_max));
  2039. PNG_EXPORT(187, png_uint_32, png_get_user_width_max,
  2040. (png_const_structp png_ptr));
  2041. PNG_EXPORT(188, png_uint_32, png_get_user_height_max,
  2042. (png_const_structp png_ptr));
  2043. /* Added in libpng-1.4.0 */
  2044. PNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structp png_ptr,
  2045. png_uint_32 user_chunk_cache_max));
  2046. PNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max,
  2047. (png_const_structp png_ptr));
  2048. /* Added in libpng-1.4.1 */
  2049. PNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structp png_ptr,
  2050. png_alloc_size_t user_chunk_cache_max));
  2051. PNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max,
  2052. (png_const_structp png_ptr));
  2053. #endif
  2054. #if defined(PNG_INCH_CONVERSIONS_SUPPORTED)
  2055. PNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch,
  2056. (png_const_structp png_ptr, png_const_infop info_ptr));
  2057. PNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch,
  2058. (png_const_structp png_ptr, png_const_infop info_ptr));
  2059. PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch,
  2060. (png_const_structp png_ptr, png_const_infop info_ptr));
  2061. PNG_FP_EXPORT(196, float, png_get_x_offset_inches,
  2062. (png_const_structp png_ptr, png_const_infop info_ptr))
  2063. #ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */
  2064. PNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed,
  2065. (png_structp png_ptr, png_const_infop info_ptr))
  2066. #endif
  2067. PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structp png_ptr,
  2068. png_const_infop info_ptr))
  2069. #ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */
  2070. PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed,
  2071. (png_structp png_ptr, png_const_infop info_ptr))
  2072. #endif
  2073. # ifdef PNG_pHYs_SUPPORTED
  2074. PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structp png_ptr,
  2075. png_const_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,
  2076. int *unit_type));
  2077. # endif /* PNG_pHYs_SUPPORTED */
  2078. #endif /* PNG_INCH_CONVERSIONS_SUPPORTED */
  2079. /* Added in libpng-1.4.0 */
  2080. #ifdef PNG_IO_STATE_SUPPORTED
  2081. PNG_EXPORT(199, png_uint_32, png_get_io_state, (png_structp png_ptr));
  2082. PNG_EXPORTA(200, png_const_bytep, png_get_io_chunk_name,
  2083. (png_structp png_ptr), PNG_DEPRECATED);
  2084. PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
  2085. (png_const_structp png_ptr));
  2086. /* The flags returned by png_get_io_state() are the following: */
  2087. # define PNG_IO_NONE 0x0000 /* no I/O at this moment */
  2088. # define PNG_IO_READING 0x0001 /* currently reading */
  2089. # define PNG_IO_WRITING 0x0002 /* currently writing */
  2090. # define PNG_IO_SIGNATURE 0x0010 /* currently at the file signature */
  2091. # define PNG_IO_CHUNK_HDR 0x0020 /* currently at the chunk header */
  2092. # define PNG_IO_CHUNK_DATA 0x0040 /* currently at the chunk data */
  2093. # define PNG_IO_CHUNK_CRC 0x0080 /* currently at the chunk crc */
  2094. # define PNG_IO_MASK_OP 0x000f /* current operation: reading/writing */
  2095. # define PNG_IO_MASK_LOC 0x00f0 /* current location: sig/hdr/data/crc */
  2096. #endif /* ?PNG_IO_STATE_SUPPORTED */
  2097. /* Interlace support. The following macros are always defined so that if
  2098. * libpng interlace handling is turned off the macros may be used to handle
  2099. * interlaced images within the application.
  2100. */
  2101. #define PNG_INTERLACE_ADAM7_PASSES 7
  2102. /* Two macros to return the first row and first column of the original,
  2103. * full, image which appears in a given pass. 'pass' is in the range 0
  2104. * to 6 and the result is in the range 0 to 7.
  2105. */
  2106. #define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7)
  2107. #define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7)
  2108. /* A macro to return the offset between pixels in the output row for a pair of
  2109. * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that
  2110. * follows. Note that ROW_OFFSET is the offset from one row to the next whereas
  2111. * COL_OFFSET is from one column to the next, within a row.
  2112. */
  2113. #define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8)
  2114. #define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1))
  2115. /* Two macros to help evaluate the number of rows or columns in each
  2116. * pass. This is expressed as a shift - effectively log2 of the number or
  2117. * rows or columns in each 8x8 tile of the original image.
  2118. */
  2119. #define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3)
  2120. #define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3)
  2121. /* Hence two macros to determine the number of rows or columns in a given
  2122. * pass of an image given its height or width. In fact these macros may
  2123. * return non-zero even though the sub-image is empty, because the other
  2124. * dimension may be empty for a small image.
  2125. */
  2126. #define PNG_PASS_ROWS(height, pass) (((height)+(((1<<PNG_PASS_ROW_SHIFT(pass))\
  2127. -1)-PNG_PASS_START_ROW(pass)))>>PNG_PASS_ROW_SHIFT(pass))
  2128. #define PNG_PASS_COLS(width, pass) (((width)+(((1<<PNG_PASS_COL_SHIFT(pass))\
  2129. -1)-PNG_PASS_START_COL(pass)))>>PNG_PASS_COL_SHIFT(pass))
  2130. /* For the reader row callbacks (both progressive and sequential) it is
  2131. * necessary to find the row in the output image given a row in an interlaced
  2132. * image, so two more macros:
  2133. */
  2134. #define PNG_ROW_FROM_PASS_ROW(yIn, pass) \
  2135. (((yIn)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass))
  2136. #define PNG_COL_FROM_PASS_COL(xIn, pass) \
  2137. (((xIn)<<PNG_PASS_COL_SHIFT(pass))+PNG_PASS_START_COL(pass))
  2138. /* Two macros which return a boolean (0 or 1) saying whether the given row
  2139. * or column is in a particular pass. These use a common utility macro that
  2140. * returns a mask for a given pass - the offset 'off' selects the row or
  2141. * column version. The mask has the appropriate bit set for each column in
  2142. * the tile.
  2143. */
  2144. #define PNG_PASS_MASK(pass,off) ( \
  2145. ((0x110145AF>>(((7-(off))-(pass))<<2)) & 0xF) | \
  2146. ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0))
  2147. #define PNG_ROW_IN_INTERLACE_PASS(y, pass) \
  2148. ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1)
  2149. #define PNG_COL_IN_INTERLACE_PASS(x, pass) \
  2150. ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1)
  2151. #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
  2152. /* With these routines we avoid an integer divide, which will be slower on
  2153. * most machines. However, it does take more operations than the corresponding
  2154. * divide method, so it may be slower on a few RISC systems. There are two
  2155. * shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
  2156. *
  2157. * Note that the rounding factors are NOT supposed to be the same! 128 and
  2158. * 32768 are correct for the NODIV code; 127 and 32767 are correct for the
  2159. * standard method.
  2160. *
  2161. * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
  2162. */
  2163. /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
  2164. # define png_composite(composite, fg, alpha, bg) \
  2165. { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \
  2166. * (png_uint_16)(alpha) \
  2167. + (png_uint_16)(bg)*(png_uint_16)(255 \
  2168. - (png_uint_16)(alpha)) + 128); \
  2169. (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
  2170. # define png_composite_16(composite, fg, alpha, bg) \
  2171. { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \
  2172. * (png_uint_32)(alpha) \
  2173. + (png_uint_32)(bg)*(65535 \
  2174. - (png_uint_32)(alpha)) + 32768); \
  2175. (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
  2176. #else /* Standard method using integer division */
  2177. # define png_composite(composite, fg, alpha, bg) \
  2178. (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \
  2179. (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
  2180. 127) / 255)
  2181. # define png_composite_16(composite, fg, alpha, bg) \
  2182. (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
  2183. (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \
  2184. 32767) / 65535)
  2185. #endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
  2186. #ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
  2187. PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));
  2188. PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf));
  2189. PNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf));
  2190. #endif
  2191. PNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_structp png_ptr,
  2192. png_const_bytep buf));
  2193. /* No png_get_int_16 -- may be added if there's a real need for it. */
  2194. /* Place a 32-bit number into a buffer in PNG byte order (big-endian). */
  2195. #ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED
  2196. PNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i));
  2197. #endif
  2198. #ifdef PNG_SAVE_INT_32_SUPPORTED
  2199. PNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i));
  2200. #endif
  2201. /* Place a 16-bit number into a buffer in PNG byte order.
  2202. * The parameter is declared unsigned int, not png_uint_16,
  2203. * just to avoid potential problems on pre-ANSI C compilers.
  2204. */
  2205. #ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED
  2206. PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
  2207. /* No png_save_int_16 -- may be added if there's a real need for it. */
  2208. #endif
  2209. #ifdef PNG_USE_READ_MACROS
  2210. /* Inline macros to do direct reads of bytes from the input buffer.
  2211. * The png_get_int_32() routine assumes we are using two's complement
  2212. * format for negative values, which is almost certainly true.
  2213. */
  2214. # define png_get_uint_32(buf) \
  2215. (((png_uint_32)(*(buf)) << 24) + \
  2216. ((png_uint_32)(*((buf) + 1)) << 16) + \
  2217. ((png_uint_32)(*((buf) + 2)) << 8) + \
  2218. ((png_uint_32)(*((buf) + 3))))
  2219. /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
  2220. * function) incorrectly returned a value of type png_uint_32.
  2221. */
  2222. # define png_get_uint_16(buf) \
  2223. ((png_uint_16) \
  2224. (((unsigned int)(*(buf)) << 8) + \
  2225. ((unsigned int)(*((buf) + 1)))))
  2226. # define png_get_int_32(buf) \
  2227. ((png_int_32)((*(buf) & 0x80) \
  2228. ? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \
  2229. : (png_int_32)png_get_uint_32(buf)))
  2230. #endif
  2231. #ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
  2232. PNG_EXPORT(234, void, png_set_check_for_invalid_index, (png_structp png_ptr,
  2233. int allowed));
  2234. # ifdef PNG_GET_PALETTE_MAX_SUPPORTED
  2235. PNG_EXPORT(235, int, png_get_palette_max, (png_const_structp png_ptr,
  2236. png_const_infop info_ptr));
  2237. # endif
  2238. #endif /* CHECK_FOR_INVALID_INDEX */
  2239. /*******************************************************************************
  2240. * IMPLEMENTATION OPTIONS
  2241. *******************************************************************************
  2242. *
  2243. * Support for arbitrary implementation-specific optimizations. The API allows
  2244. * particular options to be turned on or off. 'Option' is the number of the
  2245. * option and 'onoff' is 0 (off) or non-0 (on). The value returned is given
  2246. * by the PNG_OPTION_ defines below.
  2247. *
  2248. * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions,
  2249. * are detected at run time, however sometimes it may be impossible
  2250. * to do this in user mode, in which case it is necessary to discover
  2251. * the capabilities in an OS specific way. Such capabilities are
  2252. * listed here when libpng has support for them and must be turned
  2253. * ON by the application if present.
  2254. *
  2255. * SOFTWARE: sometimes software optimizations actually result in performance
  2256. * decrease on some architectures or systems, or with some sets of
  2257. * PNG images. 'Software' options allow such optimizations to be
  2258. * selected at run time.
  2259. */
  2260. #ifdef PNG_SET_OPTION_SUPPORTED
  2261. #ifdef PNG_ARM_NEON_API_SUPPORTED
  2262. # define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */
  2263. #endif
  2264. #define PNG_OPTION_NEXT 2 /* Next option - numbers must be even */
  2265. /* Return values: NOTE: there are four values and 'off' is *not* zero */
  2266. #define PNG_OPTION_UNSET 0 /* Unset - defaults to off */
  2267. #define PNG_OPTION_INVALID 1 /* Option number out of range */
  2268. #define PNG_OPTION_OFF 2
  2269. #define PNG_OPTION_ON 3
  2270. PNG_EXPORT(236, int, png_set_option, (png_structp png_ptr, int option,
  2271. int onoff));
  2272. #endif
  2273. /*******************************************************************************
  2274. * END OF HARDWARE OPTIONS
  2275. ******************************************************************************/
  2276. /* Maintainer: Put new public prototypes here ^, in libpng.3, and project
  2277. * defs
  2278. */
  2279. /* The last ordinal number (this is the *last* one already used; the next
  2280. * one to use is one more than this.) Maintainer, remember to add an entry to
  2281. * scripts/symbols.def as well.
  2282. */
  2283. #ifdef PNG_EXPORT_LAST_ORDINAL
  2284. PNG_EXPORT_LAST_ORDINAL(236);
  2285. #endif
  2286. #ifdef __cplusplus
  2287. }
  2288. #endif
  2289. #endif /* PNG_VERSION_INFO_ONLY */
  2290. /* Do not put anything past this line */
  2291. #endif /* PNG_H */