png.h 113 KB

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