libpng.3 161 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022
  1. .TH LIBPNG 3 "December 3, 2004"
  2. .SH NAME
  3. libpng \- Portable Network Graphics (PNG) Reference Library 1.2.8
  4. .SH SYNOPSIS
  5. \fI\fB
  6. \fB#include <png.h>\fP
  7. \fI\fB
  8. \fBpng_uint_32 png_access_version_number \fI(void\fP\fB);\fP
  9. \fI\fB
  10. \fBint png_check_sig (png_bytep \fP\fIsig\fP\fB, int \fInum\fP\fB);\fP
  11. \fI\fB
  12. \fBvoid png_chunk_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP
  13. \fI\fB
  14. \fBvoid png_chunk_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP
  15. \fI\fB
  16. \fBvoid png_convert_from_struct_tm (png_timep \fP\fIptime\fP\fB, struct tm FAR * \fIttime\fP\fB);\fP
  17. \fI\fB
  18. \fBvoid png_convert_from_time_t (png_timep \fP\fIptime\fP\fB, time_t \fIttime\fP\fB);\fP
  19. \fI\fB
  20. \fBpng_charp png_convert_to_rfc1123 (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fIptime\fP\fB);\fP
  21. \fI\fB
  22. \fBpng_infop png_create_info_struct (png_structp \fIpng_ptr\fP\fB);\fP
  23. \fI\fB
  24. \fBpng_structp png_create_read_struct (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarn_fn\fP\fB);\fP
  25. \fI\fB
  26. \fBpng_structp png_create_read_struct_2(png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fP\fIwarn_fn\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP
  27. \fI\fB
  28. \fBpng_structp png_create_write_struct (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarn_fn\fP\fB);\fP
  29. \fI\fB
  30. \fBpng_structp png_create_write_struct_2(png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fP\fIwarn_fn\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP
  31. \fI\fB
  32. \fBint png_debug(int \fP\fIlevel\fP\fB, png_const_charp \fImessage\fP\fB);\fP
  33. \fI\fB
  34. \fBint png_debug1(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fIp1\fP\fB);\fP
  35. \fI\fB
  36. \fBint png_debug2(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fP\fIp1\fP\fB, \fIp2\fP\fB);\fP
  37. \fI\fB
  38. \fBvoid png_destroy_info_struct (png_structp \fP\fIpng_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP
  39. \fI\fB
  40. \fBvoid png_destroy_read_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fP\fIinfo_ptr_ptr\fP\fB, png_infopp \fIend_info_ptr_ptr\fP\fB);\fP
  41. \fI\fB
  42. \fBvoid png_destroy_write_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP
  43. \fI\fB
  44. \fBvoid png_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP
  45. \fI\fB
  46. \fBvoid png_free (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP
  47. \fI\fB
  48. \fBvoid png_free_chunk_list (png_structp \fIpng_ptr\fP\fB);\fP
  49. \fI\fB
  50. \fBvoid png_free_default(png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP
  51. \fI\fB
  52. \fBvoid png_free_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fInum\fP\fB);\fP
  53. \fI\fB
  54. \fBpng_byte png_get_bit_depth (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  55. \fI\fB
  56. \fBpng_uint_32 png_get_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fI*background\fP\fB);\fP
  57. \fI\fB
  58. \fBpng_byte png_get_channels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  59. \fI\fB
  60. \fBpng_uint_32 png_get_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fI*white_x\fP\fB, double \fP\fI*white_y\fP\fB, double \fP\fI*red_x\fP\fB, double \fP\fI*red_y\fP\fB, double \fP\fI*green_x\fP\fB, double \fP\fI*green_y\fP\fB, double \fP\fI*blue_x\fP\fB, double \fI*blue_y\fP\fB);\fP
  61. \fI\fB
  62. \fBpng_uint_32 png_get_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*white_x\fP\fB, png_uint_32 \fP\fI*white_y\fP\fB, png_uint_32 \fP\fI*red_x\fP\fB, png_uint_32 \fP\fI*red_y\fP\fB, png_uint_32 \fP\fI*green_x\fP\fB, png_uint_32 \fP\fI*green_y\fP\fB, png_uint_32 \fP\fI*blue_x\fP\fB, png_uint_32 \fI*blue_y\fP\fB);\fP
  63. \fI\fB
  64. \fBpng_byte png_get_color_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  65. \fI\fB
  66. \fBpng_byte png_get_compression_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  67. \fI\fB
  68. \fBpng_byte png_get_copyright (png_structp \fIpng_ptr\fP\fB);\fP
  69. \fI\fB
  70. \fBpng_voidp png_get_error_ptr (png_structp \fIpng_ptr\fP\fB);\fP
  71. \fI\fB
  72. \fBpng_byte png_get_filter_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  73. \fI\fB
  74. \fBpng_uint_32 png_get_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fI*file_gamma\fP\fB);\fP
  75. \fI\fB
  76. \fBpng_uint_32 png_get_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fI*int_file_gamma\fP\fB);\fP
  77. \fI\fB
  78. \fBpng_byte png_get_header_ver (png_structp \fIpng_ptr\fP\fB);\fP
  79. \fI\fB
  80. \fBpng_byte png_get_header_version (png_structp \fIpng_ptr\fP\fB);\fP
  81. \fI\fB
  82. \fBpng_uint_32 png_get_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fI*hist\fP\fB);\fP
  83. \fI\fB
  84. \fBpng_uint_32 png_get_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charpp \fP\fIname\fP\fB, int \fP\fI*compression_type\fP\fB, png_charpp \fP\fIprofile\fP\fB, png_uint_32 \fI*proflen\fP\fB);\fP
  85. \fI\fB
  86. \fBpng_uint_32 png_get_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*width\fP\fB, png_uint_32 \fP\fI*height\fP\fB, int \fP\fI*bit_depth\fP\fB, int \fP\fI*color_type\fP\fB, int \fP\fI*interlace_type\fP\fB, int \fP\fI*compression_type\fP\fB, int \fI*filter_type\fP\fB);\fP
  87. \fI\fB
  88. \fBpng_uint_32 png_get_image_height (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  89. \fI\fB
  90. \fBpng_uint_32 png_get_image_width (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  91. \fI\fB
  92. \fBpng_byte png_get_interlace_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  93. \fI\fB
  94. \fBpng_voidp png_get_io_ptr (png_structp \fIpng_ptr\fP\fB);\fP
  95. \fI\fB
  96. \fBpng_byte png_get_libpng_ver (png_structp \fIpng_ptr\fP\fB);\fP
  97. \fI\fB
  98. \fBpng_voidp png_get_mem_ptr(png_structp \fIpng_ptr\fP\fB);\fP
  99. \fI\fB
  100. \fBpng_uint_32 png_get_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*offset_x\fP\fB, png_uint_32 \fP\fI*offset_y\fP\fB, int \fI*unit_type\fP\fB);\fP
  101. \fI\fB
  102. \fBpng_uint_32 png_get_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fI*purpose\fP\fB, png_int_32 \fP\fI*X0\fP\fB, png_int_32 \fP\fI*X1\fP\fB, int \fP\fI*type\fP\fB, int \fP\fI*nparams\fP\fB, png_charp \fP\fI*units\fP\fB, png_charpp \fI*params\fP\fB);\fP
  103. \fI\fB
  104. \fBpng_uint_32 png_get_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*res_x\fP\fB, png_uint_32 \fP\fI*res_y\fP\fB, int \fI*unit_type\fP\fB);\fP
  105. \fI\fB
  106. \fBfloat png_get_pixel_aspect_ratio (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  107. \fI\fB
  108. \fBpng_uint_32 png_get_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  109. \fI\fB
  110. \fBpng_voidp png_get_progressive_ptr (png_structp \fIpng_ptr\fP\fB);\fP
  111. \fI\fB
  112. \fBpng_uint_32 png_get_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fI*palette\fP\fB, int \fI*num_palette\fP\fB);\fP
  113. \fI\fB
  114. \fBpng_byte png_get_rgb_to_gray_status (png_structp \fIpng_ptr)
  115. \fBpng_uint_32 png_get_rowbytes (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  116. \fI\fB
  117. \fBpng_bytepp png_get_rows (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  118. \fI\fB
  119. \fBpng_uint_32 png_get_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fI*sig_bit\fP\fB);\fP
  120. \fI\fB
  121. \fBpng_bytep png_get_signature (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  122. \fI\fB
  123. \fBpng_uint_32 png_get_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fI*splt_ptr\fP\fB);\fP
  124. \fI\fB
  125. \fBpng_uint_32 png_get_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fI*intent\fP\fB);\fP
  126. \fI\fB
  127. \fBpng_uint_32 png_get_text (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fI*text_ptr\fP\fB, int \fI*num_text\fP\fB);\fP
  128. \fI\fB
  129. \fBpng_uint_32 png_get_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fI*mod_time\fP\fB);\fP
  130. \fI\fB
  131. \fBpng_uint_32 png_get_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fI*trans\fP\fB, int \fP\fI*num_trans\fP\fB, png_color_16p \fI*trans_values\fP\fB);\fP
  132. \fI\fB
  133. \fBpng_uint_32 png_get_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkpp \fIunknowns\fP\fB);\fP
  134. \fI\fB
  135. \fBpng_voidp png_get_user_chunk_ptr (png_structp \fIpng_ptr\fP\fB);\fP
  136. \fI\fB
  137. \fBpng_uint_32 png_get_user_height_max( png_structp \fIpng_ptr\fP\fB);\fP
  138. \fI\fB
  139. \fBpng_voidp png_get_user_transform_ptr (png_structp \fIpng_ptr\fP\fB);\fP
  140. \fI\fB
  141. \fBpng_uint_32 png_get_user_width_max (png_structp \fIpng_ptr\fP\fB);\fP
  142. \fI\fB
  143. \fBpng_uint_32 png_get_valid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIflag\fP\fB);\fP
  144. \fI\fB
  145. \fBpng_int_32 png_get_x_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  146. \fI\fB
  147. \fBpng_int_32 png_get_x_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  148. \fI\fB
  149. \fBpng_uint_32 png_get_x_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  150. \fI\fB
  151. \fBpng_int_32 png_get_y_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  152. \fI\fB
  153. \fBpng_int_32 png_get_y_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  154. \fI\fB
  155. \fBpng_uint_32 png_get_y_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  156. \fI\fB
  157. \fBpng_uint_32 png_get_compression_buffer_size (png_structp \fIpng_ptr\fP\fB);\fP
  158. \fI\fB
  159. \fBint png_handle_as_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP
  160. \fI\fB
  161. \fBvoid png_init_io (png_structp \fP\fIpng_ptr\fP\fB, FILE \fI*fp\fP\fB);\fP
  162. \fI\fB
  163. \fBDEPRECATED: void png_info_init (png_infop \fIinfo_ptr\fP\fB);\fP
  164. \fI\fB
  165. \fBDEPRECATED: void png_info_init_2 (png_infopp \fP\fIptr_ptr\fP\fB, png_size_t \fIpng_info_struct_size\fP\fB);\fP
  166. \fI\fB
  167. \fBpng_voidp png_malloc (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
  168. \fI\fB
  169. \fBpng_voidp png_malloc_default(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
  170. \fI\fB
  171. \fBvoidp png_memcpy (png_voidp \fP\fIs1\fP\fB, png_voidp \fP\fIs2\fP\fB, png_size_t \fIsize\fP\fB);\fP
  172. \fI\fB
  173. \fBpng_voidp png_memcpy_check (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIs1\fP\fB, png_voidp \fP\fIs2\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
  174. \fI\fB
  175. \fBvoidp png_memset (png_voidp \fP\fIs1\fP\fB, int \fP\fIvalue\fP\fB, png_size_t \fIsize\fP\fB);\fP
  176. \fI\fB
  177. \fBpng_voidp png_memset_check (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIs1\fP\fB, int \fP\fIvalue\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
  178. \fI\fB
  179. \fBDEPRECATED: void png_permit_empty_plte (png_structp \fP\fIpng_ptr\fP\fB, int \fIempty_plte_permitted\fP\fB);\fP
  180. \fI\fB
  181. \fBvoid png_process_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_size\fP\fB);\fP
  182. \fI\fB
  183. \fBvoid png_progressive_combine_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIold_row\fP\fB, png_bytep \fInew_row\fP\fB);\fP
  184. \fI\fB
  185. \fBvoid png_read_destroy (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_infop \fIend_info_ptr\fP\fB);\fP
  186. \fI\fB
  187. \fBvoid png_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  188. \fI\fB
  189. \fBvoid png_read_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP
  190. \fI\fB
  191. \fBDEPRECATED: void png_read_init (png_structp \fIpng_ptr\fP\fB);\fP
  192. \fI\fB
  193. \fBDEPRECATED: void png_read_init_2 (png_structpp \fP\fIptr_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP
  194. \fI\fB
  195. \fBvoid png_read_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  196. \fI\fB
  197. \fBvoid png_read_png (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fItransforms\fP\fB, png_voidp \fIparams\fP\fB);\fP
  198. \fI\fB
  199. \fBvoid png_read_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fIdisplay_row\fP\fB);\fP
  200. \fI\fB
  201. \fBvoid png_read_rows (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fP\fIrow\fP\fB, png_bytepp \fP\fIdisplay_row\fP\fB, png_uint_32 \fInum_rows\fP\fB);\fP
  202. \fI\fB
  203. \fBvoid png_read_update_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  204. \fI\fB
  205. \fB#if \fI!defined(PNG_1_0_X)
  206. \fBvoid png_set_add_alpha (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP
  207. \fI\fB#endif
  208. \fI\fB
  209. \fBvoid png_set_background (png_structp \fP\fIpng_ptr\fP\fB, png_color_16p \fP\fIbackground_color\fP\fB, int \fP\fIbackground_gamma_code\fP\fB, int \fP\fIneed_expand\fP\fB, double \fIbackground_gamma\fP\fB);\fP
  210. \fI\fB
  211. \fBvoid png_set_bgr (png_structp \fIpng_ptr\fP\fB);\fP
  212. \fI\fB
  213. \fBvoid png_set_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fIbackground\fP\fB);\fP
  214. \fI\fB
  215. \fBvoid png_set_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP
  216. \fI\fB
  217. \fBvoid png_set_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIwhite_x\fP\fB, png_uint_32 \fP\fIwhite_y\fP\fB, png_uint_32 \fP\fIred_x\fP\fB, png_uint_32 \fP\fIred_y\fP\fB, png_uint_32 \fP\fIgreen_x\fP\fB, png_uint_32 \fP\fIgreen_y\fP\fB, png_uint_32 \fP\fIblue_x\fP\fB, png_uint_32 \fIblue_y\fP\fB);\fP
  218. \fI\fB
  219. \fBvoid png_set_compression_level (png_structp \fP\fIpng_ptr\fP\fB, int \fIlevel\fP\fB);\fP
  220. \fI\fB
  221. \fBvoid png_set_compression_mem_level (png_structp \fP\fIpng_ptr\fP\fB, int \fImem_level\fP\fB);\fP
  222. \fI\fB
  223. \fBvoid png_set_compression_method (png_structp \fP\fIpng_ptr\fP\fB, int \fImethod\fP\fB);\fP
  224. \fI\fB
  225. \fBvoid png_set_compression_strategy (png_structp \fP\fIpng_ptr\fP\fB, int \fIstrategy\fP\fB);\fP
  226. \fI\fB
  227. \fBvoid png_set_compression_window_bits (png_structp \fP\fIpng_ptr\fP\fB, int \fIwindow_bits\fP\fB);\fP
  228. \fI\fB
  229. \fBvoid png_set_crc_action (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcrit_action\fP\fB, int \fIancil_action\fP\fB);\fP
  230. \fI\fB
  231. \fBvoid png_set_dither (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fP\fInum_palette\fP\fB, int \fP\fImaximum_colors\fP\fB, png_uint_16p \fP\fIhistogram\fP\fB, int \fIfull_dither\fP\fB);\fP
  232. \fI\fB
  233. \fBvoid png_set_error_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarning_fn\fP\fB);\fP
  234. \fI\fB
  235. \fBvoid png_set_expand (png_structp \fIpng_ptr\fP\fB);\fP
  236. \fI\fB
  237. \fBvoid png_set_filler (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP
  238. \fI\fB
  239. \fBvoid png_set_filter (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fImethod\fP\fB, int \fIfilters\fP\fB);\fP
  240. \fI\fB
  241. \fBvoid png_set_filter_heuristics (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIheuristic_method\fP\fB, int \fP\fInum_weights\fP\fB, png_doublep \fP\fIfilter_weights\fP\fB, png_doublep \fIfilter_costs\fP\fB);\fP
  242. \fI\fB
  243. \fBvoid png_set_flush (png_structp \fP\fIpng_ptr\fP\fB, int \fInrows\fP\fB);\fP
  244. \fI\fB
  245. \fBvoid png_set_gamma (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIscreen_gamma\fP\fB, double \fIdefault_file_gamma\fP\fB);\fP
  246. \fI\fB
  247. \fBvoid png_set_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP
  248. \fI\fB
  249. \fBvoid png_set_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIfile_gamma\fP\fB);\fP
  250. \fI\fB
  251. \fBvoid png_set_gray_1_2_4_to_8(png_structp \fIpng_ptr\fP\fB);\fP
  252. \fI\fB
  253. \fBvoid png_set_gray_to_rgb (png_structp \fIpng_ptr\fP\fB);\fP
  254. \fI\fB
  255. \fBvoid png_set_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fIhist\fP\fB);\fP
  256. \fI\fB
  257. \fBvoid png_set_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_charp \fP\fIprofile\fP\fB, png_uint_32 \fIproflen\fP\fB);\fP
  258. \fI\fB
  259. \fBint png_set_interlace_handling (png_structp \fIpng_ptr\fP\fB);\fP
  260. \fI\fB
  261. \fBvoid png_set_invalid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fImask\fP\fB);\fP
  262. \fI\fB
  263. \fBvoid png_set_invert_alpha (png_structp \fIpng_ptr\fP\fB);\fP
  264. \fI\fB
  265. \fBvoid png_set_invert_mono (png_structp \fIpng_ptr\fP\fB);\fP
  266. \fI\fB
  267. \fBvoid png_set_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIwidth\fP\fB, png_uint_32 \fP\fIheight\fP\fB, int \fP\fIbit_depth\fP\fB, int \fP\fIcolor_type\fP\fB, int \fP\fIinterlace_type\fP\fB, int \fP\fIcompression_type\fP\fB, int \fIfilter_type\fP\fB);\fP
  268. \fI\fB
  269. \fBvoid png_set_keep_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIkeep\fP\fB, png_bytep \fP\fIchunk_list\fP\fB, int \fInum_chunks\fP\fB);\fP
  270. \fI\fB
  271. \fBvoid png_set_mem_fn(png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP
  272. \fI\fB
  273. \fBvoid png_set_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIoffset_x\fP\fB, png_uint_32 \fP\fIoffset_y\fP\fB, int \fIunit_type\fP\fB);\fP
  274. \fI\fB
  275. \fBvoid png_set_packing (png_structp \fIpng_ptr\fP\fB);\fP
  276. \fI\fB
  277. \fBvoid png_set_packswap (png_structp \fIpng_ptr\fP\fB);\fP
  278. \fI\fB
  279. \fBvoid png_set_palette_to_rgb(png_structp \fIpng_ptr\fP\fB);\fP
  280. \fI\fB
  281. \fBvoid png_set_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIpurpose\fP\fB, png_int_32 \fP\fIX0\fP\fB, png_int_32 \fP\fIX1\fP\fB, int \fP\fItype\fP\fB, int \fP\fInparams\fP\fB, png_charp \fP\fIunits\fP\fB, png_charpp \fIparams\fP\fB);\fP
  282. \fI\fB
  283. \fBvoid png_set_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIres_x\fP\fB, png_uint_32 \fP\fIres_y\fP\fB, int \fIunit_type\fP\fB);\fP
  284. \fI\fB
  285. \fBvoid png_set_progressive_read_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIprogressive_ptr\fP\fB, png_progressive_info_ptr \fP\fIinfo_fn\fP\fB, png_progressive_row_ptr \fP\fIrow_fn\fP\fB, png_progressive_end_ptr \fIend_fn\fP\fB);\fP
  286. \fI\fB
  287. \fBvoid png_set_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fInum_palette\fP\fB);\fP
  288. \fI\fB
  289. \fBvoid png_set_read_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIio_ptr\fP\fB, png_rw_ptr \fIread_data_fn\fP\fB);\fP
  290. \fI\fB
  291. \fBvoid png_set_read_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_read_status_ptr \fIread_row_fn\fP\fB);\fP
  292. \fI\fB
  293. \fBvoid png_set_read_user_transform_fn (png_structp \fP\fIpng_ptr\fP\fB, png_user_transform_ptr \fIread_user_transform_fn\fP\fB);\fP
  294. \fI\fB
  295. \fBvoid png_set_rgb_to_gray (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIerror_action\fP\fB, double \fP\fIred\fP\fB, double \fIgreen\fP\fB);\fP
  296. \fI\fB
  297. \fBvoid png_set_rgb_to_gray_fixed (png_structp \fP\fIpng_ptr\fP\fB, int error_action png_fixed_point \fP\fIred\fP\fB, png_fixed_point \fIgreen\fP\fB);\fP
  298. \fI\fB
  299. \fBvoid png_set_rows (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytepp \fIrow_pointers\fP\fB);\fP
  300. \fI\fB
  301. \fBvoid png_set_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fIsig_bit\fP\fB);\fP
  302. \fI\fB
  303. \fBvoid png_set_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP
  304. \fI\fB
  305. \fBvoid png_set_shift (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fItrue_bits\fP\fB);\fP
  306. \fI\fB
  307. \fBvoid png_set_sig_bytes (png_structp \fP\fIpng_ptr\fP\fB, int \fInum_bytes\fP\fB);\fP
  308. \fI\fB
  309. \fBvoid png_set_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fP\fIsplt_ptr\fP\fB, int \fInum_spalettes\fP\fB);\fP
  310. \fI\fB
  311. \fBvoid png_set_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIintent\fP\fB);\fP
  312. \fI\fB
  313. \fBvoid png_set_sRGB_gAMA_and_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIintent\fP\fB);\fP
  314. \fI\fB
  315. \fBvoid png_set_strip_16 (png_structp \fIpng_ptr\fP\fB);\fP
  316. \fI\fB
  317. \fBvoid png_set_strip_alpha (png_structp \fIpng_ptr\fP\fB);\fP
  318. \fI\fB
  319. \fBvoid png_set_swap (png_structp \fIpng_ptr\fP\fB);\fP
  320. \fI\fB
  321. \fBvoid png_set_swap_alpha (png_structp \fIpng_ptr\fP\fB);\fP
  322. \fI\fB
  323. \fBvoid png_set_text (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fItext_ptr\fP\fB, int \fInum_text\fP\fB);\fP
  324. \fI\fB
  325. \fBvoid png_set_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fImod_time\fP\fB);\fP
  326. \fI\fB
  327. \fBvoid png_set_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fItrans\fP\fB, int \fP\fInum_trans\fP\fB, png_color_16p \fItrans_values\fP\fB);\fP
  328. \fI\fB
  329. \fBvoid png_set_tRNS_to_alpha(png_structp \fIpng_ptr\fP\fB);\fP
  330. \fI\fB
  331. \fBpng_uint_32 png_set_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkp \fP\fIunknowns\fP\fB, int \fP\fInum\fP\fB, int \fIlocation\fP\fB);\fP
  332. \fI\fB
  333. \fBvoid png_set_unknown_chunk_location(png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIchunk\fP\fB, int \fIlocation\fP\fB);\fP
  334. \fI\fB
  335. \fBvoid png_set_read_user_chunk_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIuser_chunk_ptr\fP\fB, png_user_chunk_ptr \fIread_user_chunk_fn\fP\fB);\fP
  336. \fI\fB
  337. \fBvoid png_set_user_limits (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIuser_width_max\fP\fB, png_uint_32 \fIuser_height_max\fP\fB);\fP
  338. \fI\fB
  339. \fBvoid png_set_user_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIuser_transform_ptr\fP\fB, int \fP\fIuser_transform_depth\fP\fB, int \fIuser_transform_channels\fP\fB);\fP
  340. \fI\fB
  341. \fBvoid png_set_write_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIio_ptr\fP\fB, png_rw_ptr \fP\fIwrite_data_fn\fP\fB, png_flush_ptr \fIoutput_flush_fn\fP\fB);\fP
  342. \fI\fB
  343. \fBvoid png_set_write_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_write_status_ptr \fIwrite_row_fn\fP\fB);\fP
  344. \fI\fB
  345. \fBvoid png_set_write_user_transform_fn (png_structp \fP\fIpng_ptr\fP\fB, png_user_transform_ptr \fIwrite_user_transform_fn\fP\fB);\fP
  346. \fI\fB
  347. \fBvoid png_set_compression_buffer_size(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
  348. \fI\fB
  349. \fBint png_sig_cmp (png_bytep \fP\fIsig\fP\fB, png_size_t \fP\fIstart\fP\fB, png_size_t \fInum_to_check\fP\fB);\fP
  350. \fI\fB
  351. \fBvoid png_start_read_image (png_structp \fIpng_ptr\fP\fB);\fP
  352. \fI\fB
  353. \fBvoid png_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP
  354. \fI\fB
  355. \fBvoid png_write_chunk (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIchunk_name\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP
  356. \fI\fB
  357. \fBvoid png_write_chunk_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP
  358. \fI\fB
  359. \fBvoid png_write_chunk_end (png_structp \fIpng_ptr\fP\fB);\fP
  360. \fI\fB
  361. \fBvoid png_write_chunk_start (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIchunk_name\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
  362. \fI\fB
  363. \fBvoid png_write_destroy (png_structp \fIpng_ptr\fP\fB);\fP
  364. \fI\fB
  365. \fBvoid png_write_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  366. \fI\fB
  367. \fBvoid png_write_flush (png_structp \fIpng_ptr\fP\fB);\fP
  368. \fI\fB
  369. \fBvoid png_write_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP
  370. \fI\fB
  371. \fBDEPRECATED: void png_write_init (png_structp \fIpng_ptr\fP\fB);\fP
  372. \fI\fB
  373. \fBDEPRECATED: void png_write_init_2 (png_structpp \fP\fIptr_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP
  374. \fI\fB
  375. \fBvoid png_write_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  376. \fI\fB
  377. \fBvoid png_write_info_before_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
  378. \fI\fB
  379. \fBvoid png_write_png (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fItransforms\fP\fB, png_voidp \fIparams\fP\fB);\fP
  380. \fI\fB
  381. \fBvoid png_write_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP
  382. \fI\fB
  383. \fBvoid png_write_rows (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fP\fIrow\fP\fB, png_uint_32 \fInum_rows\fP\fB);\fP
  384. \fI\fB
  385. \fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP
  386. \fI\fB
  387. \fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP
  388. \fI\fB
  389. .SH DESCRIPTION
  390. The
  391. .I libpng
  392. library supports encoding, decoding, and various manipulations of
  393. the Portable Network Graphics (PNG) format image files. It uses the
  394. .IR zlib(3)
  395. compression library.
  396. Following is a copy of the libpng.txt file that accompanies libpng.
  397. .SH LIBPNG.TXT
  398. libpng.txt - A description on how to use and modify libpng
  399. libpng version 1.2.8 - December 3, 2004
  400. Updated and distributed by Glenn Randers-Pehrson
  401. <glennrp at users.sourceforge.net>
  402. Copyright (c) 1998-2004 Glenn Randers-Pehrson
  403. For conditions of distribution and use, see copyright
  404. notice in png.h.
  405. based on:
  406. libpng 1.0 beta 6 version 0.96 May 28, 1997
  407. Updated and distributed by Andreas Dilger
  408. Copyright (c) 1996, 1997 Andreas Dilger
  409. libpng 1.0 beta 2 - version 0.88 January 26, 1996
  410. For conditions of distribution and use, see copyright
  411. notice in png.h. Copyright (c) 1995, 1996 Guy Eric
  412. Schalnat, Group 42, Inc.
  413. Updated/rewritten per request in the libpng FAQ
  414. Copyright (c) 1995, 1996 Frank J. T. Wojcik
  415. December 18, 1995 & January 20, 1996
  416. .SH I. Introduction
  417. This file describes how to use and modify the PNG reference library
  418. (known as libpng) for your own use. There are five sections to this
  419. file: introduction, structures, reading, writing, and modification and
  420. configuration notes for various special platforms. In addition to this
  421. file, example.c is a good starting point for using the library, as
  422. it is heavily commented and should include everything most people
  423. will need. We assume that libpng is already installed; see the
  424. INSTALL file for instructions on how to install libpng.
  425. Libpng was written as a companion to the PNG specification, as a way
  426. of reducing the amount of time and effort it takes to support the PNG
  427. file format in application programs.
  428. The PNG specification (second edition), November 2003, is available as
  429. a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at
  430. <http://www.w3.org/TR/2003/REC-PNG-20031110/
  431. The W3C and ISO documents have identical technical content.
  432. The PNG-1.2 specification is available at
  433. <http://www.libpng.org/pub/png/documents/>
  434. The PNG-1.0 specification is available
  435. as RFC 2083 <http://www.libpng.org/pub/png/documents/> and as a
  436. W3C Recommendation <http://www.w3.org/TR/REC.png.html>. Some
  437. additional chunks are described in the special-purpose public chunks
  438. documents at <http://www.libpng.org/pub/png/documents/>.
  439. Other information
  440. about PNG, and the latest version of libpng, can be found at the PNG home
  441. page, <http://www.libpng.org/pub/png/>.
  442. Most users will not have to modify the library significantly; advanced
  443. users may want to modify it more. All attempts were made to make it as
  444. complete as possible, while keeping the code easy to understand.
  445. Currently, this library only supports C. Support for other languages
  446. is being considered.
  447. Libpng has been designed to handle multiple sessions at one time,
  448. to be easily modifiable, to be portable to the vast majority of
  449. machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy
  450. to use. The ultimate goal of libpng is to promote the acceptance of
  451. the PNG file format in whatever way possible. While there is still
  452. work to be done (see the TODO file), libpng should cover the
  453. majority of the needs of its users.
  454. Libpng uses zlib for its compression and decompression of PNG files.
  455. Further information about zlib, and the latest version of zlib, can
  456. be found at the zlib home page, <http://www.info-zip.org/pub/infozip/zlib/>.
  457. The zlib compression utility is a general purpose utility that is
  458. useful for more than PNG files, and can be used without libpng.
  459. See the documentation delivered with zlib for more details.
  460. You can usually find the source files for the zlib utility wherever you
  461. find the libpng source files.
  462. Libpng is thread safe, provided the threads are using different
  463. instances of the structures. Each thread should have its own
  464. png_struct and png_info instances, and thus its own image.
  465. Libpng does not protect itself against two threads using the
  466. same instance of a structure. Note: thread safety may be defeated
  467. by use of some of the MMX assembler code in pnggccrd.c, which is only
  468. compiled when the user defines PNG_THREAD_UNSAFE_OK.
  469. .SH II. Structures
  470. There are two main structures that are important to libpng, png_struct
  471. and png_info. The first, png_struct, is an internal structure that
  472. will not, for the most part, be used by a user except as the first
  473. variable passed to every libpng function call.
  474. The png_info structure is designed to provide information about the
  475. PNG file. At one time, the fields of png_info were intended to be
  476. directly accessible to the user. However, this tended to cause problems
  477. with applications using dynamically loaded libraries, and as a result
  478. a set of interface functions for png_info (the png_get_*() and png_set_*()
  479. functions) was developed. The fields of png_info are still available for
  480. older applications, but it is suggested that applications use the new
  481. interfaces if at all possible.
  482. Applications that do make direct access to the members of png_struct (except
  483. for png_ptr->jmpbuf) must be recompiled whenever the library is updated,
  484. and applications that make direct access to the members of png_info must
  485. be recompiled if they were compiled or loaded with libpng version 1.0.6,
  486. in which the members were in a different order. In version 1.0.7, the
  487. members of the png_info structure reverted to the old order, as they were
  488. in versions 0.97c through 1.0.5. Starting with version 2.0.0, both
  489. structures are going to be hidden, and the contents of the structures will
  490. only be accessible through the png_get/png_set functions.
  491. The png.h header file is an invaluable reference for programming with libpng.
  492. And while I'm on the topic, make sure you include the libpng header file:
  493. #include <png.h>
  494. .SH III. Reading
  495. We'll now walk you through the possible functions to call when reading
  496. in a PNG file sequentially, briefly explaining the syntax and purpose
  497. of each one. See example.c and png.h for more detail. While
  498. progressive reading is covered in the next section, you will still
  499. need some of the functions discussed in this section to read a PNG
  500. file.
  501. .SS Setup
  502. You will want to do the I/O initialization(*) before you get into libpng,
  503. so if it doesn't work, you don't have much to undo. Of course, you
  504. will also want to insure that you are, in fact, dealing with a PNG
  505. file. Libpng provides a simple check to see if a file is a PNG file.
  506. To use it, pass in the first 1 to 8 bytes of the file to the function
  507. png_sig_cmp(), and it will return 0 if the bytes match the corresponding
  508. bytes of the PNG signature, or nonzero otherwise. Of course, the more bytes
  509. you pass in, the greater the accuracy of the prediction.
  510. If you are intending to keep the file pointer open for use in libpng,
  511. you must ensure you don't read more than 8 bytes from the beginning
  512. of the file, and you also have to make a call to png_set_sig_bytes_read()
  513. with the number of bytes you read from the beginning. Libpng will
  514. then only check the bytes (if any) that your program didn't read.
  515. (*): If you are not using the standard I/O functions, you will need
  516. to replace them with custom functions. See the discussion under
  517. Customizing libpng.
  518. FILE *fp = fopen(file_name, "rb");
  519. if (!fp)
  520. {
  521. return (ERROR);
  522. }
  523. fread(header, 1, number, fp);
  524. is_png = !png_sig_cmp(header, 0, number);
  525. if (!is_png)
  526. {
  527. return (NOT_PNG);
  528. }
  529. Next, png_struct and png_info need to be allocated and initialized. In
  530. order to ensure that the size of these structures is correct even with a
  531. dynamically linked libpng, there are functions to initialize and
  532. allocate the structures. We also pass the library version, optional
  533. pointers to error handling functions, and a pointer to a data struct for
  534. use by the error functions, if necessary (the pointer and functions can
  535. be NULL if the default error handlers are to be used). See the section
  536. on Changes to Libpng below regarding the old initialization functions.
  537. The structure allocation functions quietly return NULL if they fail to
  538. create the structure, so your application should check for that.
  539. png_structp png_ptr = png_create_read_struct
  540. (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
  541. user_error_fn, user_warning_fn);
  542. if (!png_ptr)
  543. return (ERROR);
  544. png_infop info_ptr = png_create_info_struct(png_ptr);
  545. if (!info_ptr)
  546. {
  547. png_destroy_read_struct(&png_ptr,
  548. (png_infopp)NULL, (png_infopp)NULL);
  549. return (ERROR);
  550. }
  551. png_infop end_info = png_create_info_struct(png_ptr);
  552. if (!end_info)
  553. {
  554. png_destroy_read_struct(&png_ptr, &info_ptr,
  555. (png_infopp)NULL);
  556. return (ERROR);
  557. }
  558. If you want to use your own memory allocation routines,
  559. define PNG_USER_MEM_SUPPORTED and use
  560. png_create_read_struct_2() instead of png_create_read_struct():
  561. png_structp png_ptr = png_create_read_struct_2
  562. (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
  563. user_error_fn, user_warning_fn, (png_voidp)
  564. user_mem_ptr, user_malloc_fn, user_free_fn);
  565. The error handling routines passed to png_create_read_struct()
  566. and the memory alloc/free routines passed to png_create_struct_2()
  567. are only necessary if you are not using the libpng supplied error
  568. handling and memory alloc/free functions.
  569. When libpng encounters an error, it expects to longjmp back
  570. to your routine. Therefore, you will need to call setjmp and pass
  571. your png_jmpbuf(png_ptr). If you read the file from different
  572. routines, you will need to update the jmpbuf field every time you enter
  573. a new routine that will call a png_*() function.
  574. See your documentation of setjmp/longjmp for your compiler for more
  575. information on setjmp/longjmp. See the discussion on libpng error
  576. handling in the Customizing Libpng section below for more information
  577. on the libpng error handling. If an error occurs, and libpng longjmp's
  578. back to your setjmp, you will want to call png_destroy_read_struct() to
  579. free any memory.
  580. if (setjmp(png_jmpbuf(png_ptr)))
  581. {
  582. png_destroy_read_struct(&png_ptr, &info_ptr,
  583. &end_info);
  584. fclose(fp);
  585. return (ERROR);
  586. }
  587. If you would rather avoid the complexity of setjmp/longjmp issues,
  588. you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case
  589. errors will result in a call to PNG_ABORT() which defaults to abort().
  590. Now you need to set up the input code. The default for libpng is to
  591. use the C function fread(). If you use this, you will need to pass a
  592. valid FILE * in the function png_init_io(). Be sure that the file is
  593. opened in binary mode. If you wish to handle reading data in another
  594. way, you need not call the png_init_io() function, but you must then
  595. implement the libpng I/O methods discussed in the Customizing Libpng
  596. section below.
  597. png_init_io(png_ptr, fp);
  598. If you had previously opened the file and read any of the signature from
  599. the beginning in order to see if this was a PNG file, you need to let
  600. libpng know that there are some bytes missing from the start of the file.
  601. png_set_sig_bytes(png_ptr, number);
  602. .SS Setting up callback code
  603. You can set up a callback function to handle any unknown chunks in the
  604. input stream. You must supply the function
  605. read_chunk_callback(png_ptr ptr,
  606. png_unknown_chunkp chunk);
  607. {
  608. /* The unknown chunk structure contains your
  609. chunk data: */
  610. png_byte name[5];
  611. png_byte *data;
  612. png_size_t size;
  613. /* Note that libpng has already taken care of
  614. the CRC handling */
  615. /* put your code here. Return one of the
  616. following: */
  617. return (-n); /* chunk had an error */
  618. return (0); /* did not recognize */
  619. return (n); /* success */
  620. }
  621. (You can give your function another name that you like instead of
  622. "read_chunk_callback")
  623. To inform libpng about your function, use
  624. png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr,
  625. read_chunk_callback);
  626. This names not only the callback function, but also a user pointer that
  627. you can retrieve with
  628. png_get_user_chunk_ptr(png_ptr);
  629. At this point, you can set up a callback function that will be
  630. called after each row has been read, which you can use to control
  631. a progress meter or the like. It's demonstrated in pngtest.c.
  632. You must supply a function
  633. void read_row_callback(png_ptr ptr, png_uint_32 row,
  634. int pass);
  635. {
  636. /* put your code here */
  637. }
  638. (You can give it another name that you like instead of "read_row_callback")
  639. To inform libpng about your function, use
  640. png_set_read_status_fn(png_ptr, read_row_callback);
  641. .SS Width and height limits
  642. The PNG specification allows the width and height of an image to be as
  643. large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns.
  644. Since very few applications really need to process such large images,
  645. we have imposed an arbitrary 1-million limit on rows and columns.
  646. Larger images will be rejected immediately with a png_error() call. If
  647. you wish to override this limit, you can use
  648. png_set_user_limits(png_ptr, width_max, height_max);
  649. to set your own limits, or use width_max = height_max = 0x7fffffffL
  650. to allow all valid dimensions (libpng may reject some very large images
  651. anyway because of potential buffer overflow conditions).
  652. You should put this statement after you create the PNG structure and
  653. before calling png_read_info(), png_read_png(), or png_process_data().
  654. If you need to retrieve the limits that are being applied, use
  655. width_max = png_get_user_width_max(png_ptr);
  656. height_max = png_get_user_height_max(png_ptr);
  657. .SS Unknown-chunk handling
  658. Now you get to set the way the library processes unknown chunks in the
  659. input PNG stream. Both known and unknown chunks will be read. Normal
  660. behavior is that known chunks will be parsed into information in
  661. various info_ptr members; unknown chunks will be discarded. To change
  662. this, you can call:
  663. png_set_keep_unknown_chunks(png_ptr, keep,
  664. chunk_list, num_chunks);
  665. keep - 0: do not handle as unknown
  666. 1: do not keep
  667. 2: keep only if safe-to-copy
  668. 3: keep even if unsafe-to-copy
  669. You can use these definitions:
  670. PNG_HANDLE_CHUNK_AS_DEFAULT 0
  671. PNG_HANDLE_CHUNK_NEVER 1
  672. PNG_HANDLE_CHUNK_IF_SAFE 2
  673. PNG_HANDLE_CHUNK_ALWAYS 3
  674. chunk_list - list of chunks affected (a byte string,
  675. five bytes per chunk, NULL or '\0' if
  676. num_chunks is 0)
  677. num_chunks - number of chunks affected; if 0, all
  678. unknown chunks are affected. If nonzero,
  679. only the chunks in the list are affected
  680. Unknown chunks declared in this way will be saved as raw data onto a
  681. list of png_unknown_chunk structures. If a chunk that is normally
  682. known to libpng is named in the list, it will be handled as unknown,
  683. according to the "keep" directive. If a chunk is named in successive
  684. instances of png_set_keep_unknown_chunks(), the final instance will
  685. take precedence. The IHDR and IEND chunks should not be named in
  686. chunk_list; if they are, libpng will process them normally anyway.
  687. .SS The high-level read interface
  688. At this point there are two ways to proceed; through the high-level
  689. read interface, or through a sequence of low-level read operations.
  690. You can use the high-level interface if (a) you are willing to read
  691. the entire image into memory, and (b) the input transformations
  692. you want to do are limited to the following set:
  693. PNG_TRANSFORM_IDENTITY No transformation
  694. PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to
  695. 8 bits
  696. PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel
  697. PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit
  698. samples to bytes
  699. PNG_TRANSFORM_PACKSWAP Change order of packed
  700. pixels to LSB first
  701. PNG_TRANSFORM_EXPAND Perform set_expand()
  702. PNG_TRANSFORM_INVERT_MONO Invert monochrome images
  703. PNG_TRANSFORM_SHIFT Normalize pixels to the
  704. sBIT depth
  705. PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA
  706. to BGRA
  707. PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA
  708. to AG
  709. PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity
  710. to transparency
  711. PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples
  712. (This excludes setting a background color, doing gamma transformation,
  713. dithering, and setting filler.) If this is the case, simply do this:
  714. png_read_png(png_ptr, info_ptr, png_transforms, NULL)
  715. where png_transforms is an integer containing the logical OR of
  716. some set of transformation flags. This call is equivalent to png_read_info(),
  717. followed the set of transformations indicated by the transform mask,
  718. then png_read_image(), and finally png_read_end().
  719. (The final parameter of this call is not yet used. Someday it might point
  720. to transformation parameters required by some future input transform.)
  721. You must use png_transforms and not call any png_set_transform() functions
  722. when you use png_read_png().
  723. After you have called png_read_png(), you can retrieve the image data
  724. with
  725. row_pointers = png_get_rows(png_ptr, info_ptr);
  726. where row_pointers is an array of pointers to the pixel data for each row:
  727. png_bytep row_pointers[height];
  728. If you know your image size and pixel size ahead of time, you can allocate
  729. row_pointers prior to calling png_read_png() with
  730. if (height > PNG_UINT_32_MAX/png_sizeof(png_byte))
  731. png_error (png_ptr,
  732. "Image is too tall to process in memory");
  733. if (width > PNG_UINT_32_MAX/pixel_size)
  734. png_error (png_ptr,
  735. "Image is too wide to process in memory");
  736. row_pointers = png_malloc(png_ptr,
  737. height*png_sizeof(png_bytep));
  738. for (int i=0; i<height, i++)
  739. row_pointers[i]=png_malloc(png_ptr,
  740. width*pixel_size);
  741. png_set_rows(png_ptr, info_ptr, &row_pointers);
  742. Alternatively you could allocate your image in one big block and define
  743. row_pointers[i] to point into the proper places in your block.
  744. If you use png_set_rows(), the application is responsible for freeing
  745. row_pointers (and row_pointers[i], if they were separately allocated).
  746. If you don't allocate row_pointers ahead of time, png_read_png() will
  747. do it, and it'll be free'ed when you call png_destroy_*().
  748. .SS The low-level read interface
  749. If you are going the low-level route, you are now ready to read all
  750. the file information up to the actual image data. You do this with a
  751. call to png_read_info().
  752. png_read_info(png_ptr, info_ptr);
  753. This will process all chunks up to but not including the image data.
  754. .SS Querying the info structure
  755. Functions are used to get the information from the info_ptr once it
  756. has been read. Note that these fields may not be completely filled
  757. in until png_read_end() has read the chunk data following the image.
  758. png_get_IHDR(png_ptr, info_ptr, &width, &height,
  759. &bit_depth, &color_type, &interlace_type,
  760. &compression_type, &filter_method);
  761. width - holds the width of the image
  762. in pixels (up to 2^31).
  763. height - holds the height of the image
  764. in pixels (up to 2^31).
  765. bit_depth - holds the bit depth of one of the
  766. image channels. (valid values are
  767. 1, 2, 4, 8, 16 and depend also on
  768. the color_type. See also
  769. significant bits (sBIT) below).
  770. color_type - describes which color/alpha channels
  771. are present.
  772. PNG_COLOR_TYPE_GRAY
  773. (bit depths 1, 2, 4, 8, 16)
  774. PNG_COLOR_TYPE_GRAY_ALPHA
  775. (bit depths 8, 16)
  776. PNG_COLOR_TYPE_PALETTE
  777. (bit depths 1, 2, 4, 8)
  778. PNG_COLOR_TYPE_RGB
  779. (bit_depths 8, 16)
  780. PNG_COLOR_TYPE_RGB_ALPHA
  781. (bit_depths 8, 16)
  782. PNG_COLOR_MASK_PALETTE
  783. PNG_COLOR_MASK_COLOR
  784. PNG_COLOR_MASK_ALPHA
  785. filter_method - (must be PNG_FILTER_TYPE_BASE
  786. for PNG 1.0, and can also be
  787. PNG_INTRAPIXEL_DIFFERENCING if
  788. the PNG datastream is embedded in
  789. a MNG-1.0 datastream)
  790. compression_type - (must be PNG_COMPRESSION_TYPE_BASE
  791. for PNG 1.0)
  792. interlace_type - (PNG_INTERLACE_NONE or
  793. PNG_INTERLACE_ADAM7)
  794. Any or all of interlace_type, compression_type, of
  795. filter_method can be NULL if you are
  796. not interested in their values.
  797. channels = png_get_channels(png_ptr, info_ptr);
  798. channels - number of channels of info for the
  799. color type (valid values are 1 (GRAY,
  800. PALETTE), 2 (GRAY_ALPHA), 3 (RGB),
  801. 4 (RGB_ALPHA or RGB + filler byte))
  802. rowbytes = png_get_rowbytes(png_ptr, info_ptr);
  803. rowbytes - number of bytes needed to hold a row
  804. signature = png_get_signature(png_ptr, info_ptr);
  805. signature - holds the signature read from the
  806. file (if any). The data is kept in
  807. the same offset it would be if the
  808. whole signature were read (i.e. if an
  809. application had already read in 4
  810. bytes of signature before starting
  811. libpng, the remaining 4 bytes would
  812. be in signature[4] through signature[7]
  813. (see png_set_sig_bytes())).
  814. width = png_get_image_width(png_ptr,
  815. info_ptr);
  816. height = png_get_image_height(png_ptr,
  817. info_ptr);
  818. bit_depth = png_get_bit_depth(png_ptr,
  819. info_ptr);
  820. color_type = png_get_color_type(png_ptr,
  821. info_ptr);
  822. filter_method = png_get_filter_type(png_ptr,
  823. info_ptr);
  824. compression_type = png_get_compression_type(png_ptr,
  825. info_ptr);
  826. interlace_type = png_get_interlace_type(png_ptr,
  827. info_ptr);
  828. These are also important, but their validity depends on whether the chunk
  829. has been read. The png_get_valid(png_ptr, info_ptr, PNG_INFO_<chunk>) and
  830. png_get_<chunk>(png_ptr, info_ptr, ...) functions return non-zero if the
  831. data has been read, or zero if it is missing. The parameters to the
  832. png_get_<chunk> are set directly if they are simple data types, or a pointer
  833. into the info_ptr is returned for any complex types.
  834. png_get_PLTE(png_ptr, info_ptr, &palette,
  835. &num_palette);
  836. palette - the palette for the file
  837. (array of png_color)
  838. num_palette - number of entries in the palette
  839. png_get_gAMA(png_ptr, info_ptr, &gamma);
  840. gamma - the gamma the file is written
  841. at (PNG_INFO_gAMA)
  842. png_get_sRGB(png_ptr, info_ptr, &srgb_intent);
  843. srgb_intent - the rendering intent (PNG_INFO_sRGB)
  844. The presence of the sRGB chunk
  845. means that the pixel data is in the
  846. sRGB color space. This chunk also
  847. implies specific values of gAMA and
  848. cHRM.
  849. png_get_iCCP(png_ptr, info_ptr, &name,
  850. &compression_type, &profile, &proflen);
  851. name - The profile name.
  852. compression - The compression type; always
  853. PNG_COMPRESSION_TYPE_BASE for PNG 1.0.
  854. You may give NULL to this argument to
  855. ignore it.
  856. profile - International Color Consortium color
  857. profile data. May contain NULs.
  858. proflen - length of profile data in bytes.
  859. png_get_sBIT(png_ptr, info_ptr, &sig_bit);
  860. sig_bit - the number of significant bits for
  861. (PNG_INFO_sBIT) each of the gray,
  862. red, green, and blue channels,
  863. whichever are appropriate for the
  864. given color type (png_color_16)
  865. png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans,
  866. &trans_values);
  867. trans - array of transparent entries for
  868. palette (PNG_INFO_tRNS)
  869. trans_values - graylevel or color sample values of
  870. the single transparent color for
  871. non-paletted images (PNG_INFO_tRNS)
  872. num_trans - number of transparent entries
  873. (PNG_INFO_tRNS)
  874. png_get_hIST(png_ptr, info_ptr, &hist);
  875. (PNG_INFO_hIST)
  876. hist - histogram of palette (array of
  877. png_uint_16)
  878. png_get_tIME(png_ptr, info_ptr, &mod_time);
  879. mod_time - time image was last modified
  880. (PNG_VALID_tIME)
  881. png_get_bKGD(png_ptr, info_ptr, &background);
  882. background - background color (PNG_VALID_bKGD)
  883. valid 16-bit red, green and blue
  884. values, regardless of color_type
  885. num_comments = png_get_text(png_ptr, info_ptr,
  886. &text_ptr, &num_text);
  887. num_comments - number of comments
  888. text_ptr - array of png_text holding image
  889. comments
  890. text_ptr[i].compression - type of compression used
  891. on "text" PNG_TEXT_COMPRESSION_NONE
  892. PNG_TEXT_COMPRESSION_zTXt
  893. PNG_ITXT_COMPRESSION_NONE
  894. PNG_ITXT_COMPRESSION_zTXt
  895. text_ptr[i].key - keyword for comment. Must contain
  896. 1-79 characters.
  897. text_ptr[i].text - text comments for current
  898. keyword. Can be empty.
  899. text_ptr[i].text_length - length of text string,
  900. after decompression, 0 for iTXt
  901. text_ptr[i].itxt_length - length of itxt string,
  902. after decompression, 0 for tEXt/zTXt
  903. text_ptr[i].lang - language of comment (empty
  904. string for unknown).
  905. text_ptr[i].lang_key - keyword in UTF-8
  906. (empty string for unknown).
  907. num_text - number of comments (same as
  908. num_comments; you can put NULL here
  909. to avoid the duplication)
  910. Note while png_set_text() will accept text, language,
  911. and translated keywords that can be NULL pointers, the
  912. structure returned by png_get_text will always contain
  913. regular zero-terminated C strings. They might be
  914. empty strings but they will never be NULL pointers.
  915. num_spalettes = png_get_sPLT(png_ptr, info_ptr,
  916. &palette_ptr);
  917. palette_ptr - array of palette structures holding
  918. contents of one or more sPLT chunks
  919. read.
  920. num_spalettes - number of sPLT chunks read.
  921. png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y,
  922. &unit_type);
  923. offset_x - positive offset from the left edge
  924. of the screen
  925. offset_y - positive offset from the top edge
  926. of the screen
  927. unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
  928. png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y,
  929. &unit_type);
  930. res_x - pixels/unit physical resolution in
  931. x direction
  932. res_y - pixels/unit physical resolution in
  933. x direction
  934. unit_type - PNG_RESOLUTION_UNKNOWN,
  935. PNG_RESOLUTION_METER
  936. png_get_sCAL(png_ptr, info_ptr, &unit, &width,
  937. &height)
  938. unit - physical scale units (an integer)
  939. width - width of a pixel in physical scale units
  940. height - height of a pixel in physical scale units
  941. (width and height are doubles)
  942. png_get_sCAL_s(png_ptr, info_ptr, &unit, &width,
  943. &height)
  944. unit - physical scale units (an integer)
  945. width - width of a pixel in physical scale units
  946. height - height of a pixel in physical scale units
  947. (width and height are strings like "2.54")
  948. num_unknown_chunks = png_get_unknown_chunks(png_ptr,
  949. info_ptr, &unknowns)
  950. unknowns - array of png_unknown_chunk
  951. structures holding unknown chunks
  952. unknowns[i].name - name of unknown chunk
  953. unknowns[i].data - data of unknown chunk
  954. unknowns[i].size - size of unknown chunk's data
  955. unknowns[i].location - position of chunk in file
  956. The value of "i" corresponds to the order in which the
  957. chunks were read from the PNG file or inserted with the
  958. png_set_unknown_chunks() function.
  959. The data from the pHYs chunk can be retrieved in several convenient
  960. forms:
  961. res_x = png_get_x_pixels_per_meter(png_ptr,
  962. info_ptr)
  963. res_y = png_get_y_pixels_per_meter(png_ptr,
  964. info_ptr)
  965. res_x_and_y = png_get_pixels_per_meter(png_ptr,
  966. info_ptr)
  967. res_x = png_get_x_pixels_per_inch(png_ptr,
  968. info_ptr)
  969. res_y = png_get_y_pixels_per_inch(png_ptr,
  970. info_ptr)
  971. res_x_and_y = png_get_pixels_per_inch(png_ptr,
  972. info_ptr)
  973. aspect_ratio = png_get_pixel_aspect_ratio(png_ptr,
  974. info_ptr)
  975. (Each of these returns 0 [signifying "unknown"] if
  976. the data is not present or if res_x is 0;
  977. res_x_and_y is 0 if res_x != res_y)
  978. The data from the oFFs chunk can be retrieved in several convenient
  979. forms:
  980. x_offset = png_get_x_offset_microns(png_ptr, info_ptr);
  981. y_offset = png_get_y_offset_microns(png_ptr, info_ptr);
  982. x_offset = png_get_x_offset_inches(png_ptr, info_ptr);
  983. y_offset = png_get_y_offset_inches(png_ptr, info_ptr);
  984. (Each of these returns 0 [signifying "unknown" if both
  985. x and y are 0] if the data is not present or if the
  986. chunk is present but the unit is the pixel)
  987. For more information, see the png_info definition in png.h and the
  988. PNG specification for chunk contents. Be careful with trusting
  989. rowbytes, as some of the transformations could increase the space
  990. needed to hold a row (expand, filler, gray_to_rgb, etc.).
  991. See png_read_update_info(), below.
  992. A quick word about text_ptr and num_text. PNG stores comments in
  993. keyword/text pairs, one pair per chunk, with no limit on the number
  994. of text chunks, and a 2^31 byte limit on their size. While there are
  995. suggested keywords, there is no requirement to restrict the use to these
  996. strings. It is strongly suggested that keywords and text be sensible
  997. to humans (that's the point), so don't use abbreviations. Non-printing
  998. symbols are not allowed. See the PNG specification for more details.
  999. There is also no requirement to have text after the keyword.
  1000. Keywords should be limited to 79 Latin-1 characters without leading or
  1001. trailing spaces, but non-consecutive spaces are allowed within the
  1002. keyword. It is possible to have the same keyword any number of times.
  1003. The text_ptr is an array of png_text structures, each holding a
  1004. pointer to a language string, a pointer to a keyword and a pointer to
  1005. a text string. The text string, language code, and translated
  1006. keyword may be empty or NULL pointers. The keyword/text
  1007. pairs are put into the array in the order that they are received.
  1008. However, some or all of the text chunks may be after the image, so, to
  1009. make sure you have read all the text chunks, don't mess with these
  1010. until after you read the stuff after the image. This will be
  1011. mentioned again below in the discussion that goes with png_read_end().
  1012. .SS Input transformations
  1013. After you've read the header information, you can set up the library
  1014. to handle any special transformations of the image data. The various
  1015. ways to transform the data will be described in the order that they
  1016. should occur. This is important, as some of these change the color
  1017. type and/or bit depth of the data, and some others only work on
  1018. certain color types and bit depths. Even though each transformation
  1019. checks to see if it has data that it can do something with, you should
  1020. make sure to only enable a transformation if it will be valid for the
  1021. data. For example, don't swap red and blue on grayscale data.
  1022. The colors used for the background and transparency values should be
  1023. supplied in the same format/depth as the current image data. They
  1024. are stored in the same format/depth as the image data in a bKGD or tRNS
  1025. chunk, so this is what libpng expects for this data. The colors are
  1026. transformed to keep in sync with the image data when an application
  1027. calls the png_read_update_info() routine (see below).
  1028. Data will be decoded into the supplied row buffers packed into bytes
  1029. unless the library has been told to transform it into another format.
  1030. For example, 4 bit/pixel paletted or grayscale data will be returned
  1031. 2 pixels/byte with the leftmost pixel in the high-order bits of the
  1032. byte, unless png_set_packing() is called. 8-bit RGB data will be stored
  1033. in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha()
  1034. is called to insert filler bytes, either before or after each RGB triplet.
  1035. 16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant
  1036. byte of the color value first, unless png_set_strip_16() is called to
  1037. transform it to regular RGB RGB triplets, or png_set_filler() or
  1038. png_set_add alpha() is called to insert filler bytes, either before or
  1039. after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can
  1040. be modified with
  1041. png_set_filler(), png_set_add_alpha(), or png_set_strip_16().
  1042. The following code transforms grayscale images of less than 8 to 8 bits,
  1043. changes paletted images to RGB, and adds a full alpha channel if there is
  1044. transparency information in a tRNS chunk. This is most useful on
  1045. grayscale images with bit depths of 2 or 4 or if there is a multiple-image
  1046. viewing application that wishes to treat all images in the same way.
  1047. if (color_type == PNG_COLOR_TYPE_PALETTE)
  1048. png_set_palette_to_rgb(png_ptr);
  1049. if (color_type == PNG_COLOR_TYPE_GRAY &&
  1050. bit_depth < 8) png_set_gray_1_2_4_to_8(png_ptr);
  1051. if (png_get_valid(png_ptr, info_ptr,
  1052. PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr);
  1053. These three functions are actually aliases for png_set_expand(), added
  1054. in libpng version 1.0.4, with the function names expanded to improve code
  1055. readability. In some future version they may actually do different
  1056. things.
  1057. PNG can have files with 16 bits per channel. If you only can handle
  1058. 8 bits per channel, this will strip the pixels down to 8 bit.
  1059. if (bit_depth == 16)
  1060. png_set_strip_16(png_ptr);
  1061. If, for some reason, you don't need the alpha channel on an image,
  1062. and you want to remove it rather than combining it with the background
  1063. (but the image author certainly had in mind that you *would* combine
  1064. it with the background, so that's what you should probably do):
  1065. if (color_type & PNG_COLOR_MASK_ALPHA)
  1066. png_set_strip_alpha(png_ptr);
  1067. In PNG files, the alpha channel in an image
  1068. is the level of opacity. If you need the alpha channel in an image to
  1069. be the level of transparency instead of opacity, you can invert the
  1070. alpha channel (or the tRNS chunk data) after it's read, so that 0 is
  1071. fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit
  1072. images) is fully transparent, with
  1073. png_set_invert_alpha(png_ptr);
  1074. PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
  1075. they can, resulting in, for example, 8 pixels per byte for 1 bit
  1076. files. This code expands to 1 pixel per byte without changing the
  1077. values of the pixels:
  1078. if (bit_depth < 8)
  1079. png_set_packing(png_ptr);
  1080. PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels
  1081. stored in a PNG image have been "scaled" or "shifted" up to the next
  1082. higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to
  1083. 8 bits/sample in the range [0, 255]). However, it is also possible to
  1084. convert the PNG pixel data back to the original bit depth of the image.
  1085. This call reduces the pixels back down to the original bit depth:
  1086. png_color_8p sig_bit;
  1087. if (png_get_sBIT(png_ptr, info_ptr, &sig_bit))
  1088. png_set_shift(png_ptr, sig_bit);
  1089. PNG files store 3-color pixels in red, green, blue order. This code
  1090. changes the storage of the pixels to blue, green, red:
  1091. if (color_type == PNG_COLOR_TYPE_RGB ||
  1092. color_type == PNG_COLOR_TYPE_RGB_ALPHA)
  1093. png_set_bgr(png_ptr);
  1094. PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them
  1095. into 4 or 8 bytes for windowing systems that need them in this format:
  1096. if (color_type == PNG_COLOR_TYPE_RGB)
  1097. png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE);
  1098. where "filler" is the 8 or 16-bit number to fill with, and the location is
  1099. either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether
  1100. you want the filler before the RGB or after. This transformation
  1101. does not affect images that already have full alpha channels. To add an
  1102. opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which
  1103. will generate RGBA pixels.
  1104. Note that png_set_filler() does not change the color type. If you want
  1105. to do that, you can add a true alpha channel with
  1106. if (color_type == PNG_COLOR_TYPE_RGB ||
  1107. color_type == PNG_COLOR_TYPE_GRAY)
  1108. png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER);
  1109. where "filler" contains the alpha value to assign to each pixel.
  1110. This function was added in libpng-1.2.7.
  1111. If you are reading an image with an alpha channel, and you need the
  1112. data as ARGB instead of the normal PNG format RGBA:
  1113. if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
  1114. png_set_swap_alpha(png_ptr);
  1115. For some uses, you may want a grayscale image to be represented as
  1116. RGB. This code will do that conversion:
  1117. if (color_type == PNG_COLOR_TYPE_GRAY ||
  1118. color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
  1119. png_set_gray_to_rgb(png_ptr);
  1120. Conversely, you can convert an RGB or RGBA image to grayscale or grayscale
  1121. with alpha.
  1122. if (color_type == PNG_COLOR_TYPE_RGB ||
  1123. color_type == PNG_COLOR_TYPE_RGB_ALPHA)
  1124. png_set_rgb_to_gray_fixed(png_ptr, error_action,
  1125. int red_weight, int green_weight);
  1126. error_action = 1: silently do the conversion
  1127. error_action = 2: issue a warning if the original
  1128. image has any pixel where
  1129. red != green or red != blue
  1130. error_action = 3: issue an error and abort the
  1131. conversion if the original
  1132. image has any pixel where
  1133. red != green or red != blue
  1134. red_weight: weight of red component times 100000
  1135. green_weight: weight of green component times 100000
  1136. If either weight is negative, default
  1137. weights (21268, 71514) are used.
  1138. If you have set error_action = 1 or 2, you can
  1139. later check whether the image really was gray, after processing
  1140. the image rows, with the png_get_rgb_to_gray_status(png_ptr) function.
  1141. It will return a png_byte that is zero if the image was gray or
  1142. 1 if there were any non-gray pixels. bKGD and sBIT data
  1143. will be silently converted to grayscale, using the green channel
  1144. data, regardless of the error_action setting.
  1145. With red_weight+green_weight<=100000,
  1146. the normalized graylevel is computed:
  1147. int rw = red_weight * 65536;
  1148. int gw = green_weight * 65536;
  1149. int bw = 65536 - (rw + gw);
  1150. gray = (rw*red + gw*green + bw*blue)/65536;
  1151. The default values approximate those recommended in the Charles
  1152. Poynton's Color FAQ, <http://www.inforamp.net/~poynton/>
  1153. Copyright (c) 1998-01-04 Charles Poynton <poynton at inforamp.net>
  1154. Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
  1155. Libpng approximates this with
  1156. Y = 0.21268 * R + 0.7151 * G + 0.07217 * B
  1157. which can be expressed with integers as
  1158. Y = (6969 * R + 23434 * G + 2365 * B)/32768
  1159. The calculation is done in a linear colorspace, if the image gamma
  1160. is known.
  1161. If you have a grayscale and you are using png_set_expand_depth(),
  1162. png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to
  1163. a higher bit-depth, you must either supply the background color as a gray
  1164. value at the original file bit-depth (need_expand = 1) or else supply the
  1165. background color as an RGB triplet at the final, expanded bit depth
  1166. (need_expand = 0). Similarly, if you are reading a paletted image, you
  1167. must either supply the background color as a palette index (need_expand = 1)
  1168. or as an RGB triplet that may or may not be in the palette (need_expand = 0).
  1169. png_color_16 my_background;
  1170. png_color_16p image_background;
  1171. if (png_get_bKGD(png_ptr, info_ptr, &image_background))
  1172. png_set_background(png_ptr, image_background,
  1173. PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
  1174. else
  1175. png_set_background(png_ptr, &my_background,
  1176. PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
  1177. The png_set_background() function tells libpng to composite images
  1178. with alpha or simple transparency against the supplied background
  1179. color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
  1180. you may use this color, or supply another color more suitable for
  1181. the current display (e.g., the background color from a web page). You
  1182. need to tell libpng whether the color is in the gamma space of the
  1183. display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file
  1184. (PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one
  1185. that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't
  1186. know why anyone would use this, but it's here).
  1187. To properly display PNG images on any kind of system, the application needs
  1188. to know what the display gamma is. Ideally, the user will know this, and
  1189. the application will allow them to set it. One method of allowing the user
  1190. to set the display gamma separately for each system is to check for a
  1191. SCREEN_GAMMA or DISPLAY_GAMMA environment variable, which will hopefully be
  1192. correctly set.
  1193. Note that display_gamma is the overall gamma correction required to produce
  1194. pleasing results, which depends on the lighting conditions in the surrounding
  1195. environment. In a dim or brightly lit room, no compensation other than
  1196. the physical gamma exponent of the monitor is needed, while in a dark room
  1197. a slightly smaller exponent is better.
  1198. double gamma, screen_gamma;
  1199. if (/* We have a user-defined screen
  1200. gamma value */)
  1201. {
  1202. screen_gamma = user_defined_screen_gamma;
  1203. }
  1204. /* One way that applications can share the same
  1205. screen gamma value */
  1206. else if ((gamma_str = getenv("SCREEN_GAMMA"))
  1207. != NULL)
  1208. {
  1209. screen_gamma = (double)atof(gamma_str);
  1210. }
  1211. /* If we don't have another value */
  1212. else
  1213. {
  1214. screen_gamma = 2.2; /* A good guess for a
  1215. PC monitor in a bright office or a dim room */
  1216. screen_gamma = 2.0; /* A good guess for a
  1217. PC monitor in a dark room */
  1218. screen_gamma = 1.7 or 1.0; /* A good
  1219. guess for Mac systems */
  1220. }
  1221. The png_set_gamma() function handles gamma transformations of the data.
  1222. Pass both the file gamma and the current screen_gamma. If the file does
  1223. not have a gamma value, you can pass one anyway if you have an idea what
  1224. it is (usually 0.45455 is a good guess for GIF images on PCs). Note
  1225. that file gammas are inverted from screen gammas. See the discussions
  1226. on gamma in the PNG specification for an excellent description of what
  1227. gamma is, and why all applications should support it. It is strongly
  1228. recommended that PNG viewers support gamma correction.
  1229. if (png_get_gAMA(png_ptr, info_ptr, &gamma))
  1230. png_set_gamma(png_ptr, screen_gamma, gamma);
  1231. else
  1232. png_set_gamma(png_ptr, screen_gamma, 0.45455);
  1233. If you need to reduce an RGB file to a paletted file, or if a paletted
  1234. file has more entries then will fit on your screen, png_set_dither()
  1235. will do that. Note that this is a simple match dither that merely
  1236. finds the closest color available. This should work fairly well with
  1237. optimized palettes, and fairly badly with linear color cubes. If you
  1238. pass a palette that is larger then maximum_colors, the file will
  1239. reduce the number of colors in the palette so it will fit into
  1240. maximum_colors. If there is a histogram, it will use it to make
  1241. more intelligent choices when reducing the palette. If there is no
  1242. histogram, it may not do as good a job.
  1243. if (color_type & PNG_COLOR_MASK_COLOR)
  1244. {
  1245. if (png_get_valid(png_ptr, info_ptr,
  1246. PNG_INFO_PLTE))
  1247. {
  1248. png_uint_16p histogram = NULL;
  1249. png_get_hIST(png_ptr, info_ptr,
  1250. &histogram);
  1251. png_set_dither(png_ptr, palette, num_palette,
  1252. max_screen_colors, histogram, 1);
  1253. }
  1254. else
  1255. {
  1256. png_color std_color_cube[MAX_SCREEN_COLORS] =
  1257. { ... colors ... };
  1258. png_set_dither(png_ptr, std_color_cube,
  1259. MAX_SCREEN_COLORS, MAX_SCREEN_COLORS,
  1260. NULL,0);
  1261. }
  1262. }
  1263. PNG files describe monochrome as black being zero and white being one.
  1264. The following code will reverse this (make black be one and white be
  1265. zero):
  1266. if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY)
  1267. png_set_invert_mono(png_ptr);
  1268. This function can also be used to invert grayscale and gray-alpha images:
  1269. if (color_type == PNG_COLOR_TYPE_GRAY ||
  1270. color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
  1271. png_set_invert_mono(png_ptr);
  1272. PNG files store 16 bit pixels in network byte order (big-endian,
  1273. ie. most significant bits first). This code changes the storage to the
  1274. other way (little-endian, i.e. least significant bits first, the
  1275. way PCs store them):
  1276. if (bit_depth == 16)
  1277. png_set_swap(png_ptr);
  1278. If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you
  1279. need to change the order the pixels are packed into bytes, you can use:
  1280. if (bit_depth < 8)
  1281. png_set_packswap(png_ptr);
  1282. Finally, you can write your own transformation function if none of
  1283. the existing ones meets your needs. This is done by setting a callback
  1284. with
  1285. png_set_read_user_transform_fn(png_ptr,
  1286. read_transform_fn);
  1287. You must supply the function
  1288. void read_transform_fn(png_ptr ptr, row_info_ptr
  1289. row_info, png_bytep data)
  1290. See pngtest.c for a working example. Your function will be called
  1291. after all of the other transformations have been processed.
  1292. You can also set up a pointer to a user structure for use by your
  1293. callback function, and you can inform libpng that your transform
  1294. function will change the number of channels or bit depth with the
  1295. function
  1296. png_set_user_transform_info(png_ptr, user_ptr,
  1297. user_depth, user_channels);
  1298. The user's application, not libpng, is responsible for allocating and
  1299. freeing any memory required for the user structure.
  1300. You can retrieve the pointer via the function
  1301. png_get_user_transform_ptr(). For example:
  1302. voidp read_user_transform_ptr =
  1303. png_get_user_transform_ptr(png_ptr);
  1304. The last thing to handle is interlacing; this is covered in detail below,
  1305. but you must call the function here if you want libpng to handle expansion
  1306. of the interlaced image.
  1307. number_of_passes = png_set_interlace_handling(png_ptr);
  1308. After setting the transformations, libpng can update your png_info
  1309. structure to reflect any transformations you've requested with this
  1310. call. This is most useful to update the info structure's rowbytes
  1311. field so you can use it to allocate your image memory. This function
  1312. will also update your palette with the correct screen_gamma and
  1313. background if these have been given with the calls above.
  1314. png_read_update_info(png_ptr, info_ptr);
  1315. After you call png_read_update_info(), you can allocate any
  1316. memory you need to hold the image. The row data is simply
  1317. raw byte data for all forms of images. As the actual allocation
  1318. varies among applications, no example will be given. If you
  1319. are allocating one large chunk, you will need to build an
  1320. array of pointers to each row, as it will be needed for some
  1321. of the functions below.
  1322. .SS Reading image data
  1323. After you've allocated memory, you can read the image data.
  1324. The simplest way to do this is in one function call. If you are
  1325. allocating enough memory to hold the whole image, you can just
  1326. call png_read_image() and libpng will read in all the image data
  1327. and put it in the memory area supplied. You will need to pass in
  1328. an array of pointers to each row.
  1329. This function automatically handles interlacing, so you don't need
  1330. to call png_set_interlace_handling() or call this function multiple
  1331. times, or any of that other stuff necessary with png_read_rows().
  1332. png_read_image(png_ptr, row_pointers);
  1333. where row_pointers is:
  1334. png_bytep row_pointers[height];
  1335. You can point to void or char or whatever you use for pixels.
  1336. If you don't want to read in the whole image at once, you can
  1337. use png_read_rows() instead. If there is no interlacing (check
  1338. interlace_type == PNG_INTERLACE_NONE), this is simple:
  1339. png_read_rows(png_ptr, row_pointers, NULL,
  1340. number_of_rows);
  1341. where row_pointers is the same as in the png_read_image() call.
  1342. If you are doing this just one row at a time, you can do this with
  1343. a single row_pointer instead of an array of row_pointers:
  1344. png_bytep row_pointer = row;
  1345. png_read_row(png_ptr, row_pointer, NULL);
  1346. If the file is interlaced (interlace_type != 0 in the IHDR chunk), things
  1347. get somewhat harder. The only current (PNG Specification version 1.2)
  1348. interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7)
  1349. is a somewhat complicated 2D interlace scheme, known as Adam7, that
  1350. breaks down an image into seven smaller images of varying size, based
  1351. on an 8x8 grid.
  1352. libpng can fill out those images or it can give them to you "as is".
  1353. If you want them filled out, there are two ways to do that. The one
  1354. mentioned in the PNG specification is to expand each pixel to cover
  1355. those pixels that have not been read yet (the "rectangle" method).
  1356. This results in a blocky image for the first pass, which gradually
  1357. smooths out as more pixels are read. The other method is the "sparkle"
  1358. method, where pixels are drawn only in their final locations, with the
  1359. rest of the image remaining whatever colors they were initialized to
  1360. before the start of the read. The first method usually looks better,
  1361. but tends to be slower, as there are more pixels to put in the rows.
  1362. If you don't want libpng to handle the interlacing details, just call
  1363. png_read_rows() seven times to read in all seven images. Each of the
  1364. images is a valid image by itself, or they can all be combined on an
  1365. 8x8 grid to form a single image (although if you intend to combine them
  1366. you would be far better off using the libpng interlace handling).
  1367. The first pass will return an image 1/8 as wide as the entire image
  1368. (every 8th column starting in column 0) and 1/8 as high as the original
  1369. (every 8th row starting in row 0), the second will be 1/8 as wide
  1370. (starting in column 4) and 1/8 as high (also starting in row 0). The
  1371. third pass will be 1/4 as wide (every 4th pixel starting in column 0) and
  1372. 1/8 as high (every 8th row starting in row 4), and the fourth pass will
  1373. be 1/4 as wide and 1/4 as high (every 4th column starting in column 2,
  1374. and every 4th row starting in row 0). The fifth pass will return an
  1375. image 1/2 as wide, and 1/4 as high (starting at column 0 and row 2),
  1376. while the sixth pass will be 1/2 as wide and 1/2 as high as the original
  1377. (starting in column 1 and row 0). The seventh and final pass will be as
  1378. wide as the original, and 1/2 as high, containing all of the odd
  1379. numbered scanlines. Phew!
  1380. If you want libpng to expand the images, call this before calling
  1381. png_start_read_image() or png_read_update_info():
  1382. if (interlace_type == PNG_INTERLACE_ADAM7)
  1383. number_of_passes
  1384. = png_set_interlace_handling(png_ptr);
  1385. This will return the number of passes needed. Currently, this
  1386. is seven, but may change if another interlace type is added.
  1387. This function can be called even if the file is not interlaced,
  1388. where it will return one pass.
  1389. If you are not going to display the image after each pass, but are
  1390. going to wait until the entire image is read in, use the sparkle
  1391. effect. This effect is faster and the end result of either method
  1392. is exactly the same. If you are planning on displaying the image
  1393. after each pass, the "rectangle" effect is generally considered the
  1394. better looking one.
  1395. If you only want the "sparkle" effect, just call png_read_rows() as
  1396. normal, with the third parameter NULL. Make sure you make pass over
  1397. the image number_of_passes times, and you don't change the data in the
  1398. rows between calls. You can change the locations of the data, just
  1399. not the data. Each pass only writes the pixels appropriate for that
  1400. pass, and assumes the data from previous passes is still valid.
  1401. png_read_rows(png_ptr, row_pointers, NULL,
  1402. number_of_rows);
  1403. If you only want the first effect (the rectangles), do the same as
  1404. before except pass the row buffer in the third parameter, and leave
  1405. the second parameter NULL.
  1406. png_read_rows(png_ptr, NULL, row_pointers,
  1407. number_of_rows);
  1408. .SS Finishing a sequential read
  1409. After you are finished reading the image through either the high- or
  1410. low-level interfaces, you can finish reading the file. If you are
  1411. interested in comments or time, which may be stored either before or
  1412. after the image data, you should pass the separate png_info struct if
  1413. you want to keep the comments from before and after the image
  1414. separate. If you are not interested, you can pass NULL.
  1415. png_read_end(png_ptr, end_info);
  1416. When you are done, you can free all memory allocated by libpng like this:
  1417. png_destroy_read_struct(&png_ptr, &info_ptr,
  1418. &end_info);
  1419. It is also possible to individually free the info_ptr members that
  1420. point to libpng-allocated storage with the following function:
  1421. png_free_data(png_ptr, info_ptr, mask, seq)
  1422. mask - identifies data to be freed, a mask
  1423. containing the logical OR of one or
  1424. more of
  1425. PNG_FREE_PLTE, PNG_FREE_TRNS,
  1426. PNG_FREE_HIST, PNG_FREE_ICCP,
  1427. PNG_FREE_PCAL, PNG_FREE_ROWS,
  1428. PNG_FREE_SCAL, PNG_FREE_SPLT,
  1429. PNG_FREE_TEXT, PNG_FREE_UNKN,
  1430. or simply PNG_FREE_ALL
  1431. seq - sequence number of item to be freed
  1432. (-1 for all items)
  1433. This function may be safely called when the relevant storage has
  1434. already been freed, or has not yet been allocated, or was allocated
  1435. by the user and not by libpng, and will in those
  1436. cases do nothing. The "seq" parameter is ignored if only one item
  1437. of the selected data type, such as PLTE, is allowed. If "seq" is not
  1438. -1, and multiple items are allowed for the data type identified in
  1439. the mask, such as text or sPLT, only the n'th item in the structure
  1440. is freed, where n is "seq".
  1441. The default behavior is only to free data that was allocated internally
  1442. by libpng. This can be changed, so that libpng will not free the data,
  1443. or so that it will free data that was allocated by the user with png_malloc()
  1444. or png_zalloc() and passed in via a png_set_*() function, with
  1445. png_data_freer(png_ptr, info_ptr, freer, mask)
  1446. mask - which data elements are affected
  1447. same choices as in png_free_data()
  1448. freer - one of
  1449. PNG_DESTROY_WILL_FREE_DATA
  1450. PNG_SET_WILL_FREE_DATA
  1451. PNG_USER_WILL_FREE_DATA
  1452. This function only affects data that has already been allocated.
  1453. You can call this function after reading the PNG data but before calling
  1454. any png_set_*() functions, to control whether the user or the png_set_*()
  1455. function is responsible for freeing any existing data that might be present,
  1456. and again after the png_set_*() functions to control whether the user
  1457. or png_destroy_*() is supposed to free the data. When the user assumes
  1458. responsibility for libpng-allocated data, the application must use
  1459. png_free() to free it, and when the user transfers responsibility to libpng
  1460. for data that the user has allocated, the user must have used png_malloc()
  1461. or png_zalloc() to allocate it.
  1462. If you allocated your row_pointers in a single block, as suggested above in
  1463. the description of the high level read interface, you must not transfer
  1464. responsibility for freeing it to the png_set_rows or png_read_destroy function,
  1465. because they would also try to free the individual row_pointers[i].
  1466. If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword
  1467. separately, do not transfer responsibility for freeing text_ptr to libpng,
  1468. because when libpng fills a png_text structure it combines these members with
  1469. the key member, and png_free_data() will free only text_ptr.key. Similarly,
  1470. if you transfer responsibility for free'ing text_ptr from libpng to your
  1471. application, your application must not separately free those members.
  1472. The png_free_data() function will turn off the "valid" flag for anything
  1473. it frees. If you need to turn the flag off for a chunk that was freed by your
  1474. application instead of by libpng, you can use
  1475. png_set_invalid(png_ptr, info_ptr, mask);
  1476. mask - identifies the chunks to be made invalid,
  1477. containing the logical OR of one or
  1478. more of
  1479. PNG_INFO_gAMA, PNG_INFO_sBIT,
  1480. PNG_INFO_cHRM, PNG_INFO_PLTE,
  1481. PNG_INFO_tRNS, PNG_INFO_bKGD,
  1482. PNG_INFO_hIST, PNG_INFO_pHYs,
  1483. PNG_INFO_oFFs, PNG_INFO_tIME,
  1484. PNG_INFO_pCAL, PNG_INFO_sRGB,
  1485. PNG_INFO_iCCP, PNG_INFO_sPLT,
  1486. PNG_INFO_sCAL, PNG_INFO_IDAT
  1487. For a more compact example of reading a PNG image, see the file example.c.
  1488. .SS Reading PNG files progressively
  1489. The progressive reader is slightly different then the non-progressive
  1490. reader. Instead of calling png_read_info(), png_read_rows(), and
  1491. png_read_end(), you make one call to png_process_data(), which calls
  1492. callbacks when it has the info, a row, or the end of the image. You
  1493. set up these callbacks with png_set_progressive_read_fn(). You don't
  1494. have to worry about the input/output functions of libpng, as you are
  1495. giving the library the data directly in png_process_data(). I will
  1496. assume that you have read the section on reading PNG files above,
  1497. so I will only highlight the differences (although I will show
  1498. all of the code).
  1499. png_structp png_ptr;
  1500. png_infop info_ptr;
  1501. /* An example code fragment of how you would
  1502. initialize the progressive reader in your
  1503. application. */
  1504. int
  1505. initialize_png_reader()
  1506. {
  1507. png_ptr = png_create_read_struct
  1508. (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
  1509. user_error_fn, user_warning_fn);
  1510. if (!png_ptr)
  1511. return (ERROR);
  1512. info_ptr = png_create_info_struct(png_ptr);
  1513. if (!info_ptr)
  1514. {
  1515. png_destroy_read_struct(&png_ptr, (png_infopp)NULL,
  1516. (png_infopp)NULL);
  1517. return (ERROR);
  1518. }
  1519. if (setjmp(png_jmpbuf(png_ptr)))
  1520. {
  1521. png_destroy_read_struct(&png_ptr, &info_ptr,
  1522. (png_infopp)NULL);
  1523. return (ERROR);
  1524. }
  1525. /* This one's new. You can provide functions
  1526. to be called when the header info is valid,
  1527. when each row is completed, and when the image
  1528. is finished. If you aren't using all functions,
  1529. you can specify NULL parameters. Even when all
  1530. three functions are NULL, you need to call
  1531. png_set_progressive_read_fn(). You can use
  1532. any struct as the user_ptr (cast to a void pointer
  1533. for the function call), and retrieve the pointer
  1534. from inside the callbacks using the function
  1535. png_get_progressive_ptr(png_ptr);
  1536. which will return a void pointer, which you have
  1537. to cast appropriately.
  1538. */
  1539. png_set_progressive_read_fn(png_ptr, (void *)user_ptr,
  1540. info_callback, row_callback, end_callback);
  1541. return 0;
  1542. }
  1543. /* A code fragment that you call as you receive blocks
  1544. of data */
  1545. int
  1546. process_data(png_bytep buffer, png_uint_32 length)
  1547. {
  1548. if (setjmp(png_jmpbuf(png_ptr)))
  1549. {
  1550. png_destroy_read_struct(&png_ptr, &info_ptr,
  1551. (png_infopp)NULL);
  1552. return (ERROR);
  1553. }
  1554. /* This one's new also. Simply give it a chunk
  1555. of data from the file stream (in order, of
  1556. course). On machines with segmented memory
  1557. models machines, don't give it any more than
  1558. 64K. The library seems to run fine with sizes
  1559. of 4K. Although you can give it much less if
  1560. necessary (I assume you can give it chunks of
  1561. 1 byte, I haven't tried less then 256 bytes
  1562. yet). When this function returns, you may
  1563. want to display any rows that were generated
  1564. in the row callback if you don't already do
  1565. so there.
  1566. */
  1567. png_process_data(png_ptr, info_ptr, buffer, length);
  1568. return 0;
  1569. }
  1570. /* This function is called (as set by
  1571. png_set_progressive_read_fn() above) when enough data
  1572. has been supplied so all of the header has been
  1573. read.
  1574. */
  1575. void
  1576. info_callback(png_structp png_ptr, png_infop info)
  1577. {
  1578. /* Do any setup here, including setting any of
  1579. the transformations mentioned in the Reading
  1580. PNG files section. For now, you _must_ call
  1581. either png_start_read_image() or
  1582. png_read_update_info() after all the
  1583. transformations are set (even if you don't set
  1584. any). You may start getting rows before
  1585. png_process_data() returns, so this is your
  1586. last chance to prepare for that.
  1587. */
  1588. }
  1589. /* This function is called when each row of image
  1590. data is complete */
  1591. void
  1592. row_callback(png_structp png_ptr, png_bytep new_row,
  1593. png_uint_32 row_num, int pass)
  1594. {
  1595. /* If the image is interlaced, and you turned
  1596. on the interlace handler, this function will
  1597. be called for every row in every pass. Some
  1598. of these rows will not be changed from the
  1599. previous pass. When the row is not changed,
  1600. the new_row variable will be NULL. The rows
  1601. and passes are called in order, so you don't
  1602. really need the row_num and pass, but I'm
  1603. supplying them because it may make your life
  1604. easier.
  1605. For the non-NULL rows of interlaced images,
  1606. you must call png_progressive_combine_row()
  1607. passing in the row and the old row. You can
  1608. call this function for NULL rows (it will just
  1609. return) and for non-interlaced images (it just
  1610. does the memcpy for you) if it will make the
  1611. code easier. Thus, you can just do this for
  1612. all cases:
  1613. */
  1614. png_progressive_combine_row(png_ptr, old_row,
  1615. new_row);
  1616. /* where old_row is what was displayed for
  1617. previously for the row. Note that the first
  1618. pass (pass == 0, really) will completely cover
  1619. the old row, so the rows do not have to be
  1620. initialized. After the first pass (and only
  1621. for interlaced images), you will have to pass
  1622. the current row, and the function will combine
  1623. the old row and the new row.
  1624. */
  1625. }
  1626. void
  1627. end_callback(png_structp png_ptr, png_infop info)
  1628. {
  1629. /* This function is called after the whole image
  1630. has been read, including any chunks after the
  1631. image (up to and including the IEND). You
  1632. will usually have the same info chunk as you
  1633. had in the header, although some data may have
  1634. been added to the comments and time fields.
  1635. Most people won't do much here, perhaps setting
  1636. a flag that marks the image as finished.
  1637. */
  1638. }
  1639. .SH IV. Writing
  1640. Much of this is very similar to reading. However, everything of
  1641. importance is repeated here, so you won't have to constantly look
  1642. back up in the reading section to understand writing.
  1643. .SS Setup
  1644. You will want to do the I/O initialization before you get into libpng,
  1645. so if it doesn't work, you don't have anything to undo. If you are not
  1646. using the standard I/O functions, you will need to replace them with
  1647. custom writing functions. See the discussion under Customizing libpng.
  1648. FILE *fp = fopen(file_name, "wb");
  1649. if (!fp)
  1650. {
  1651. return (ERROR);
  1652. }
  1653. Next, png_struct and png_info need to be allocated and initialized.
  1654. As these can be both relatively large, you may not want to store these
  1655. on the stack, unless you have stack space to spare. Of course, you
  1656. will want to check if they return NULL. If you are also reading,
  1657. you won't want to name your read structure and your write structure
  1658. both "png_ptr"; you can call them anything you like, such as
  1659. "read_ptr" and "write_ptr". Look at pngtest.c, for example.
  1660. png_structp png_ptr = png_create_write_struct
  1661. (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
  1662. user_error_fn, user_warning_fn);
  1663. if (!png_ptr)
  1664. return (ERROR);
  1665. png_infop info_ptr = png_create_info_struct(png_ptr);
  1666. if (!info_ptr)
  1667. {
  1668. png_destroy_write_struct(&png_ptr,
  1669. (png_infopp)NULL);
  1670. return (ERROR);
  1671. }
  1672. If you want to use your own memory allocation routines,
  1673. define PNG_USER_MEM_SUPPORTED and use
  1674. png_create_write_struct_2() instead of png_create_write_struct():
  1675. png_structp png_ptr = png_create_write_struct_2
  1676. (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
  1677. user_error_fn, user_warning_fn, (png_voidp)
  1678. user_mem_ptr, user_malloc_fn, user_free_fn);
  1679. After you have these structures, you will need to set up the
  1680. error handling. When libpng encounters an error, it expects to
  1681. longjmp() back to your routine. Therefore, you will need to call
  1682. setjmp() and pass the png_jmpbuf(png_ptr). If you
  1683. write the file from different routines, you will need to update
  1684. the png_jmpbuf(png_ptr) every time you enter a new routine that will
  1685. call a png_*() function. See your documentation of setjmp/longjmp
  1686. for your compiler for more information on setjmp/longjmp. See
  1687. the discussion on libpng error handling in the Customizing Libpng
  1688. section below for more information on the libpng error handling.
  1689. if (setjmp(png_jmpbuf(png_ptr)))
  1690. {
  1691. png_destroy_write_struct(&png_ptr, &info_ptr);
  1692. fclose(fp);
  1693. return (ERROR);
  1694. }
  1695. ...
  1696. return;
  1697. If you would rather avoid the complexity of setjmp/longjmp issues,
  1698. you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case
  1699. errors will result in a call to PNG_ABORT() which defaults to abort().
  1700. Now you need to set up the output code. The default for libpng is to
  1701. use the C function fwrite(). If you use this, you will need to pass a
  1702. valid FILE * in the function png_init_io(). Be sure that the file is
  1703. opened in binary mode. Again, if you wish to handle writing data in
  1704. another way, see the discussion on libpng I/O handling in the Customizing
  1705. Libpng section below.
  1706. png_init_io(png_ptr, fp);
  1707. .SS Write callbacks
  1708. At this point, you can set up a callback function that will be
  1709. called after each row has been written, which you can use to control
  1710. a progress meter or the like. It's demonstrated in pngtest.c.
  1711. You must supply a function
  1712. void write_row_callback(png_ptr, png_uint_32 row,
  1713. int pass);
  1714. {
  1715. /* put your code here */
  1716. }
  1717. (You can give it another name that you like instead of "write_row_callback")
  1718. To inform libpng about your function, use
  1719. png_set_write_status_fn(png_ptr, write_row_callback);
  1720. You now have the option of modifying how the compression library will
  1721. run. The following functions are mainly for testing, but may be useful
  1722. in some cases, like if you need to write PNG files extremely fast and
  1723. are willing to give up some compression, or if you want to get the
  1724. maximum possible compression at the expense of slower writing. If you
  1725. have no special needs in this area, let the library do what it wants by
  1726. not calling this function at all, as it has been tuned to deliver a good
  1727. speed/compression ratio. The second parameter to png_set_filter() is
  1728. the filter method, for which the only valid values are 0 (as of the
  1729. July 1999 PNG specification, version 1.2) or 64 (if you are writing
  1730. a PNG datastream that is to be embedded in a MNG datastream). The third
  1731. parameter is a flag that indicates which filter type(s) are to be tested
  1732. for each scanline. See the PNG specification for details on the specific filter
  1733. types.
  1734. /* turn on or off filtering, and/or choose
  1735. specific filters. You can use either a single
  1736. PNG_FILTER_VALUE_NAME or the logical OR of one
  1737. or more PNG_FILTER_NAME masks. */
  1738. png_set_filter(png_ptr, 0,
  1739. PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE |
  1740. PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB |
  1741. PNG_FILTER_UP | PNG_FILTER_VALUE_UP |
  1742. PNG_FILTER_AVE | PNG_FILTER_VALUE_AVE |
  1743. PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH|
  1744. PNG_ALL_FILTERS);
  1745. If an application
  1746. wants to start and stop using particular filters during compression,
  1747. it should start out with all of the filters (to ensure that the previous
  1748. row of pixels will be stored in case it's needed later), and then add
  1749. and remove them after the start of compression.
  1750. If you are writing a PNG datastream that is to be embedded in a MNG
  1751. datastream, the second parameter can be either 0 or 64.
  1752. The png_set_compression_*() functions interface to the zlib compression
  1753. library, and should mostly be ignored unless you really know what you are
  1754. doing. The only generally useful call is png_set_compression_level()
  1755. which changes how much time zlib spends on trying to compress the image
  1756. data. See the Compression Library (zlib.h and algorithm.txt, distributed
  1757. with zlib) for details on the compression levels.
  1758. /* set the zlib compression level */
  1759. png_set_compression_level(png_ptr,
  1760. Z_BEST_COMPRESSION);
  1761. /* set other zlib parameters */
  1762. png_set_compression_mem_level(png_ptr, 8);
  1763. png_set_compression_strategy(png_ptr,
  1764. Z_DEFAULT_STRATEGY);
  1765. png_set_compression_window_bits(png_ptr, 15);
  1766. png_set_compression_method(png_ptr, 8);
  1767. png_set_compression_buffer_size(png_ptr, 8192)
  1768. extern PNG_EXPORT(void,png_set_zbuf_size)
  1769. .SS Setting the contents of info for output
  1770. You now need to fill in the png_info structure with all the data you
  1771. wish to write before the actual image. Note that the only thing you
  1772. are allowed to write after the image is the text chunks and the time
  1773. chunk (as of PNG Specification 1.2, anyway). See png_write_end() and
  1774. the latest PNG specification for more information on that. If you
  1775. wish to write them before the image, fill them in now, and flag that
  1776. data as being valid. If you want to wait until after the data, don't
  1777. fill them until png_write_end(). For all the fields in png_info and
  1778. their data types, see png.h. For explanations of what the fields
  1779. contain, see the PNG specification.
  1780. Some of the more important parts of the png_info are:
  1781. png_set_IHDR(png_ptr, info_ptr, width, height,
  1782. bit_depth, color_type, interlace_type,
  1783. compression_type, filter_method)
  1784. width - holds the width of the image
  1785. in pixels (up to 2^31).
  1786. height - holds the height of the image
  1787. in pixels (up to 2^31).
  1788. bit_depth - holds the bit depth of one of the
  1789. image channels.
  1790. (valid values are 1, 2, 4, 8, 16
  1791. and depend also on the
  1792. color_type. See also significant
  1793. bits (sBIT) below).
  1794. color_type - describes which color/alpha
  1795. channels are present.
  1796. PNG_COLOR_TYPE_GRAY
  1797. (bit depths 1, 2, 4, 8, 16)
  1798. PNG_COLOR_TYPE_GRAY_ALPHA
  1799. (bit depths 8, 16)
  1800. PNG_COLOR_TYPE_PALETTE
  1801. (bit depths 1, 2, 4, 8)
  1802. PNG_COLOR_TYPE_RGB
  1803. (bit_depths 8, 16)
  1804. PNG_COLOR_TYPE_RGB_ALPHA
  1805. (bit_depths 8, 16)
  1806. PNG_COLOR_MASK_PALETTE
  1807. PNG_COLOR_MASK_COLOR
  1808. PNG_COLOR_MASK_ALPHA
  1809. interlace_type - PNG_INTERLACE_NONE or
  1810. PNG_INTERLACE_ADAM7
  1811. compression_type - (must be
  1812. PNG_COMPRESSION_TYPE_DEFAULT)
  1813. filter_method - (must be PNG_FILTER_TYPE_DEFAULT
  1814. or, if you are writing a PNG to
  1815. be embedded in a MNG datastream,
  1816. can also be
  1817. PNG_INTRAPIXEL_DIFFERENCING)
  1818. png_set_PLTE(png_ptr, info_ptr, palette,
  1819. num_palette);
  1820. palette - the palette for the file
  1821. (array of png_color)
  1822. num_palette - number of entries in the palette
  1823. png_set_gAMA(png_ptr, info_ptr, gamma);
  1824. gamma - the gamma the image was created
  1825. at (PNG_INFO_gAMA)
  1826. png_set_sRGB(png_ptr, info_ptr, srgb_intent);
  1827. srgb_intent - the rendering intent
  1828. (PNG_INFO_sRGB) The presence of
  1829. the sRGB chunk means that the pixel
  1830. data is in the sRGB color space.
  1831. This chunk also implies specific
  1832. values of gAMA and cHRM. Rendering
  1833. intent is the CSS-1 property that
  1834. has been defined by the International
  1835. Color Consortium
  1836. (http://www.color.org).
  1837. It can be one of
  1838. PNG_sRGB_INTENT_SATURATION,
  1839. PNG_sRGB_INTENT_PERCEPTUAL,
  1840. PNG_sRGB_INTENT_ABSOLUTE, or
  1841. PNG_sRGB_INTENT_RELATIVE.
  1842. png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr,
  1843. srgb_intent);
  1844. srgb_intent - the rendering intent
  1845. (PNG_INFO_sRGB) The presence of the
  1846. sRGB chunk means that the pixel
  1847. data is in the sRGB color space.
  1848. This function also causes gAMA and
  1849. cHRM chunks with the specific values
  1850. that are consistent with sRGB to be
  1851. written.
  1852. png_set_iCCP(png_ptr, info_ptr, name, compression_type,
  1853. profile, proflen);
  1854. name - The profile name.
  1855. compression - The compression type; always
  1856. PNG_COMPRESSION_TYPE_BASE for PNG 1.0.
  1857. You may give NULL to this argument to
  1858. ignore it.
  1859. profile - International Color Consortium color
  1860. profile data. May contain NULs.
  1861. proflen - length of profile data in bytes.
  1862. png_set_sBIT(png_ptr, info_ptr, sig_bit);
  1863. sig_bit - the number of significant bits for
  1864. (PNG_INFO_sBIT) each of the gray, red,
  1865. green, and blue channels, whichever are
  1866. appropriate for the given color type
  1867. (png_color_16)
  1868. png_set_tRNS(png_ptr, info_ptr, trans, num_trans,
  1869. trans_values);
  1870. trans - array of transparent entries for
  1871. palette (PNG_INFO_tRNS)
  1872. trans_values - graylevel or color sample values of
  1873. the single transparent color for
  1874. non-paletted images (PNG_INFO_tRNS)
  1875. num_trans - number of transparent entries
  1876. (PNG_INFO_tRNS)
  1877. png_set_hIST(png_ptr, info_ptr, hist);
  1878. (PNG_INFO_hIST)
  1879. hist - histogram of palette (array of
  1880. png_uint_16)
  1881. png_set_tIME(png_ptr, info_ptr, mod_time);
  1882. mod_time - time image was last modified
  1883. (PNG_VALID_tIME)
  1884. png_set_bKGD(png_ptr, info_ptr, background);
  1885. background - background color (PNG_VALID_bKGD)
  1886. png_set_text(png_ptr, info_ptr, text_ptr, num_text);
  1887. text_ptr - array of png_text holding image
  1888. comments
  1889. text_ptr[i].compression - type of compression used
  1890. on "text" PNG_TEXT_COMPRESSION_NONE
  1891. PNG_TEXT_COMPRESSION_zTXt
  1892. PNG_ITXT_COMPRESSION_NONE
  1893. PNG_ITXT_COMPRESSION_zTXt
  1894. text_ptr[i].key - keyword for comment. Must contain
  1895. 1-79 characters.
  1896. text_ptr[i].text - text comments for current
  1897. keyword. Can be NULL or empty.
  1898. text_ptr[i].text_length - length of text string,
  1899. after decompression, 0 for iTXt
  1900. text_ptr[i].itxt_length - length of itxt string,
  1901. after decompression, 0 for tEXt/zTXt
  1902. text_ptr[i].lang - language of comment (NULL or
  1903. empty for unknown).
  1904. text_ptr[i].translated_keyword - keyword in UTF-8 (NULL
  1905. or empty for unknown).
  1906. num_text - number of comments
  1907. png_set_sPLT(png_ptr, info_ptr, &palette_ptr,
  1908. num_spalettes);
  1909. palette_ptr - array of png_sPLT_struct structures
  1910. to be added to the list of palettes
  1911. in the info structure.
  1912. num_spalettes - number of palette structures to be
  1913. added.
  1914. png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y,
  1915. unit_type);
  1916. offset_x - positive offset from the left
  1917. edge of the screen
  1918. offset_y - positive offset from the top
  1919. edge of the screen
  1920. unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
  1921. png_set_pHYs(png_ptr, info_ptr, res_x, res_y,
  1922. unit_type);
  1923. res_x - pixels/unit physical resolution
  1924. in x direction
  1925. res_y - pixels/unit physical resolution
  1926. in y direction
  1927. unit_type - PNG_RESOLUTION_UNKNOWN,
  1928. PNG_RESOLUTION_METER
  1929. png_set_sCAL(png_ptr, info_ptr, unit, width, height)
  1930. unit - physical scale units (an integer)
  1931. width - width of a pixel in physical scale units
  1932. height - height of a pixel in physical scale units
  1933. (width and height are doubles)
  1934. png_set_sCAL_s(png_ptr, info_ptr, unit, width, height)
  1935. unit - physical scale units (an integer)
  1936. width - width of a pixel in physical scale units
  1937. height - height of a pixel in physical scale units
  1938. (width and height are strings like "2.54")
  1939. png_set_unknown_chunks(png_ptr, info_ptr, &unknowns,
  1940. num_unknowns)
  1941. unknowns - array of png_unknown_chunk
  1942. structures holding unknown chunks
  1943. unknowns[i].name - name of unknown chunk
  1944. unknowns[i].data - data of unknown chunk
  1945. unknowns[i].size - size of unknown chunk's data
  1946. unknowns[i].location - position to write chunk in file
  1947. 0: do not write chunk
  1948. PNG_HAVE_IHDR: before PLTE
  1949. PNG_HAVE_PLTE: before IDAT
  1950. PNG_AFTER_IDAT: after IDAT
  1951. The "location" member is set automatically according to
  1952. what part of the output file has already been written.
  1953. You can change its value after calling png_set_unknown_chunks()
  1954. as demonstrated in pngtest.c. Within each of the "locations",
  1955. the chunks are sequenced according to their position in the
  1956. structure (that is, the value of "i", which is the order in which
  1957. the chunk was either read from the input file or defined with
  1958. png_set_unknown_chunks).
  1959. A quick word about text and num_text. text is an array of png_text
  1960. structures. num_text is the number of valid structures in the array.
  1961. Each png_text structure holds a language code, a keyword, a text value,
  1962. and a compression type.
  1963. The compression types have the same valid numbers as the compression
  1964. types of the image data. Currently, the only valid number is zero.
  1965. However, you can store text either compressed or uncompressed, unlike
  1966. images, which always have to be compressed. So if you don't want the
  1967. text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE.
  1968. Because tEXt and zTXt chunks don't have a language field, if you
  1969. specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt
  1970. any language code or translated keyword will not be written out.
  1971. Until text gets around 1000 bytes, it is not worth compressing it.
  1972. After the text has been written out to the file, the compression type
  1973. is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR,
  1974. so that it isn't written out again at the end (in case you are calling
  1975. png_write_end() with the same struct.
  1976. The keywords that are given in the PNG Specification are:
  1977. Title Short (one line) title or
  1978. caption for image
  1979. Author Name of image's creator
  1980. Description Description of image (possibly long)
  1981. Copyright Copyright notice
  1982. Creation Time Time of original image creation
  1983. (usually RFC 1123 format, see below)
  1984. Software Software used to create the image
  1985. Disclaimer Legal disclaimer
  1986. Warning Warning of nature of content
  1987. Source Device used to create the image
  1988. Comment Miscellaneous comment; conversion
  1989. from other image format
  1990. The keyword-text pairs work like this. Keywords should be short
  1991. simple descriptions of what the comment is about. Some typical
  1992. keywords are found in the PNG specification, as is some recommendations
  1993. on keywords. You can repeat keywords in a file. You can even write
  1994. some text before the image and some after. For example, you may want
  1995. to put a description of the image before the image, but leave the
  1996. disclaimer until after, so viewers working over modem connections
  1997. don't have to wait for the disclaimer to go over the modem before
  1998. they start seeing the image. Finally, keywords should be full
  1999. words, not abbreviations. Keywords and text are in the ISO 8859-1
  2000. (Latin-1) character set (a superset of regular ASCII) and can not
  2001. contain NUL characters, and should not contain control or other
  2002. unprintable characters. To make the comments widely readable, stick
  2003. with basic ASCII, and avoid machine specific character set extensions
  2004. like the IBM-PC character set. The keyword must be present, but
  2005. you can leave off the text string on non-compressed pairs.
  2006. Compressed pairs must have a text string, as only the text string
  2007. is compressed anyway, so the compression would be meaningless.
  2008. PNG supports modification time via the png_time structure. Two
  2009. conversion routines are provided, png_convert_from_time_t() for
  2010. time_t and png_convert_from_struct_tm() for struct tm. The
  2011. time_t routine uses gmtime(). You don't have to use either of
  2012. these, but if you wish to fill in the png_time structure directly,
  2013. you should provide the time in universal time (GMT) if possible
  2014. instead of your local time. Note that the year number is the full
  2015. year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and
  2016. that months start with 1.
  2017. If you want to store the time of the original image creation, you should
  2018. use a plain tEXt chunk with the "Creation Time" keyword. This is
  2019. necessary because the "creation time" of a PNG image is somewhat vague,
  2020. depending on whether you mean the PNG file, the time the image was
  2021. created in a non-PNG format, a still photo from which the image was
  2022. scanned, or possibly the subject matter itself. In order to facilitate
  2023. machine-readable dates, it is recommended that the "Creation Time"
  2024. tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"),
  2025. although this isn't a requirement. Unlike the tIME chunk, the
  2026. "Creation Time" tEXt chunk is not expected to be automatically changed
  2027. by the software. To facilitate the use of RFC 1123 dates, a function
  2028. png_convert_to_rfc1123(png_timep) is provided to convert from PNG
  2029. time to an RFC 1123 format string.
  2030. .SS Writing unknown chunks
  2031. You can use the png_set_unknown_chunks function to queue up chunks
  2032. for writing. You give it a chunk name, raw data, and a size; that's
  2033. all there is to it. The chunks will be written by the next following
  2034. png_write_info_before_PLTE, png_write_info, or png_write_end function.
  2035. Any chunks previously read into the info structure's unknown-chunk
  2036. list will also be written out in a sequence that satisfies the PNG
  2037. specification's ordering rules.
  2038. .SS The high-level write interface
  2039. At this point there are two ways to proceed; through the high-level
  2040. write interface, or through a sequence of low-level write operations.
  2041. You can use the high-level interface if your image data is present
  2042. in the info structure. All defined output
  2043. transformations are permitted, enabled by the following masks.
  2044. PNG_TRANSFORM_IDENTITY No transformation
  2045. PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples
  2046. PNG_TRANSFORM_PACKSWAP Change order of packed
  2047. pixels to LSB first
  2048. PNG_TRANSFORM_INVERT_MONO Invert monochrome images
  2049. PNG_TRANSFORM_SHIFT Normalize pixels to the
  2050. sBIT depth
  2051. PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA
  2052. to BGRA
  2053. PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA
  2054. to AG
  2055. PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity
  2056. to transparency
  2057. PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples
  2058. PNG_TRANSFORM_STRIP_FILLER Strip out filler bytes.
  2059. If you have valid image data in the info structure (you can use
  2060. png_set_rows() to put image data in the info structure), simply do this:
  2061. png_write_png(png_ptr, info_ptr, png_transforms, NULL)
  2062. where png_transforms is an integer containing the logical OR of some set of
  2063. transformation flags. This call is equivalent to png_write_info(),
  2064. followed the set of transformations indicated by the transform mask,
  2065. then png_write_image(), and finally png_write_end().
  2066. (The final parameter of this call is not yet used. Someday it might point
  2067. to transformation parameters required by some future output transform.)
  2068. You must use png_transforms and not call any png_set_transform() functions
  2069. when you use png_write_png().
  2070. .SS The low-level write interface
  2071. If you are going the low-level route instead, you are now ready to
  2072. write all the file information up to the actual image data. You do
  2073. this with a call to png_write_info().
  2074. png_write_info(png_ptr, info_ptr);
  2075. Note that there is one transformation you may need to do before
  2076. png_write_info(). In PNG files, the alpha channel in an image is the
  2077. level of opacity. If your data is supplied as a level of
  2078. transparency, you can invert the alpha channel before you write it, so
  2079. that 0 is fully transparent and 255 (in 8-bit or paletted images) or
  2080. 65535 (in 16-bit images) is fully opaque, with
  2081. png_set_invert_alpha(png_ptr);
  2082. This must appear before png_write_info() instead of later with the
  2083. other transformations because in the case of paletted images the tRNS
  2084. chunk data has to be inverted before the tRNS chunk is written. If
  2085. your image is not a paletted image, the tRNS data (which in such cases
  2086. represents a single color to be rendered as transparent) won't need to
  2087. be changed, and you can safely do this transformation after your
  2088. png_write_info() call.
  2089. If you need to write a private chunk that you want to appear before
  2090. the PLTE chunk when PLTE is present, you can write the PNG info in
  2091. two steps, and insert code to write your own chunk between them:
  2092. png_write_info_before_PLTE(png_ptr, info_ptr);
  2093. png_set_unknown_chunks(png_ptr, info_ptr, ...);
  2094. png_write_info(png_ptr, info_ptr);
  2095. After you've written the file information, you can set up the library
  2096. to handle any special transformations of the image data. The various
  2097. ways to transform the data will be described in the order that they
  2098. should occur. This is important, as some of these change the color
  2099. type and/or bit depth of the data, and some others only work on
  2100. certain color types and bit depths. Even though each transformation
  2101. checks to see if it has data that it can do something with, you should
  2102. make sure to only enable a transformation if it will be valid for the
  2103. data. For example, don't swap red and blue on grayscale data.
  2104. PNG files store RGB pixels packed into 3 or 6 bytes. This code tells
  2105. the library to strip input data that has 4 or 8 bytes per pixel down
  2106. to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2
  2107. bytes per pixel).
  2108. png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
  2109. where the 0 is unused, and the location is either PNG_FILLER_BEFORE or
  2110. PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel
  2111. is stored XRGB or RGBX.
  2112. PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
  2113. they can, resulting in, for example, 8 pixels per byte for 1 bit files.
  2114. If the data is supplied at 1 pixel per byte, use this code, which will
  2115. correctly pack the pixels into a single byte:
  2116. png_set_packing(png_ptr);
  2117. PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your
  2118. data is of another bit depth, you can write an sBIT chunk into the
  2119. file so that decoders can recover the original data if desired.
  2120. /* Set the true bit depth of the image data */
  2121. if (color_type & PNG_COLOR_MASK_COLOR)
  2122. {
  2123. sig_bit.red = true_bit_depth;
  2124. sig_bit.green = true_bit_depth;
  2125. sig_bit.blue = true_bit_depth;
  2126. }
  2127. else
  2128. {
  2129. sig_bit.gray = true_bit_depth;
  2130. }
  2131. if (color_type & PNG_COLOR_MASK_ALPHA)
  2132. {
  2133. sig_bit.alpha = true_bit_depth;
  2134. }
  2135. png_set_sBIT(png_ptr, info_ptr, &sig_bit);
  2136. If the data is stored in the row buffer in a bit depth other than
  2137. one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG),
  2138. this will scale the values to appear to be the correct bit depth as
  2139. is required by PNG.
  2140. png_set_shift(png_ptr, &sig_bit);
  2141. PNG files store 16 bit pixels in network byte order (big-endian,
  2142. ie. most significant bits first). This code would be used if they are
  2143. supplied the other way (little-endian, i.e. least significant bits
  2144. first, the way PCs store them):
  2145. if (bit_depth > 8)
  2146. png_set_swap(png_ptr);
  2147. If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you
  2148. need to change the order the pixels are packed into bytes, you can use:
  2149. if (bit_depth < 8)
  2150. png_set_packswap(png_ptr);
  2151. PNG files store 3 color pixels in red, green, blue order. This code
  2152. would be used if they are supplied as blue, green, red:
  2153. png_set_bgr(png_ptr);
  2154. PNG files describe monochrome as black being zero and white being
  2155. one. This code would be used if the pixels are supplied with this reversed
  2156. (black being one and white being zero):
  2157. png_set_invert_mono(png_ptr);
  2158. Finally, you can write your own transformation function if none of
  2159. the existing ones meets your needs. This is done by setting a callback
  2160. with
  2161. png_set_write_user_transform_fn(png_ptr,
  2162. write_transform_fn);
  2163. You must supply the function
  2164. void write_transform_fn(png_ptr ptr, row_info_ptr
  2165. row_info, png_bytep data)
  2166. See pngtest.c for a working example. Your function will be called
  2167. before any of the other transformations are processed.
  2168. You can also set up a pointer to a user structure for use by your
  2169. callback function.
  2170. png_set_user_transform_info(png_ptr, user_ptr, 0, 0);
  2171. The user_channels and user_depth parameters of this function are ignored
  2172. when writing; you can set them to zero as shown.
  2173. You can retrieve the pointer via the function png_get_user_transform_ptr().
  2174. For example:
  2175. voidp write_user_transform_ptr =
  2176. png_get_user_transform_ptr(png_ptr);
  2177. It is possible to have libpng flush any pending output, either manually,
  2178. or automatically after a certain number of lines have been written. To
  2179. flush the output stream a single time call:
  2180. png_write_flush(png_ptr);
  2181. and to have libpng flush the output stream periodically after a certain
  2182. number of scanlines have been written, call:
  2183. png_set_flush(png_ptr, nrows);
  2184. Note that the distance between rows is from the last time png_write_flush()
  2185. was called, or the first row of the image if it has never been called.
  2186. So if you write 50 lines, and then png_set_flush 25, it will flush the
  2187. output on the next scanline, and every 25 lines thereafter, unless
  2188. png_write_flush() is called before 25 more lines have been written.
  2189. If nrows is too small (less than about 10 lines for a 640 pixel wide
  2190. RGB image) the image compression may decrease noticeably (although this
  2191. may be acceptable for real-time applications). Infrequent flushing will
  2192. only degrade the compression performance by a few percent over images
  2193. that do not use flushing.
  2194. .SS Writing the image data
  2195. That's it for the transformations. Now you can write the image data.
  2196. The simplest way to do this is in one function call. If you have the
  2197. whole image in memory, you can just call png_write_image() and libpng
  2198. will write the image. You will need to pass in an array of pointers to
  2199. each row. This function automatically handles interlacing, so you don't
  2200. need to call png_set_interlace_handling() or call this function multiple
  2201. times, or any of that other stuff necessary with png_write_rows().
  2202. png_write_image(png_ptr, row_pointers);
  2203. where row_pointers is:
  2204. png_byte *row_pointers[height];
  2205. You can point to void or char or whatever you use for pixels.
  2206. If you don't want to write the whole image at once, you can
  2207. use png_write_rows() instead. If the file is not interlaced,
  2208. this is simple:
  2209. png_write_rows(png_ptr, row_pointers,
  2210. number_of_rows);
  2211. row_pointers is the same as in the png_write_image() call.
  2212. If you are just writing one row at a time, you can do this with
  2213. a single row_pointer instead of an array of row_pointers:
  2214. png_bytep row_pointer = row;
  2215. png_write_row(png_ptr, row_pointer);
  2216. When the file is interlaced, things can get a good deal more
  2217. complicated. The only currently (as of the PNG Specification
  2218. version 1.2, dated July 1999) defined interlacing scheme for PNG files
  2219. is the "Adam7" interlace scheme, that breaks down an
  2220. image into seven smaller images of varying size. libpng will build
  2221. these images for you, or you can do them yourself. If you want to
  2222. build them yourself, see the PNG specification for details of which
  2223. pixels to write when.
  2224. If you don't want libpng to handle the interlacing details, just
  2225. use png_set_interlace_handling() and call png_write_rows() the
  2226. correct number of times to write all seven sub-images.
  2227. If you want libpng to build the sub-images, call this before you start
  2228. writing any rows:
  2229. number_of_passes =
  2230. png_set_interlace_handling(png_ptr);
  2231. This will return the number of passes needed. Currently, this
  2232. is seven, but may change if another interlace type is added.
  2233. Then write the complete image number_of_passes times.
  2234. png_write_rows(png_ptr, row_pointers,
  2235. number_of_rows);
  2236. As some of these rows are not used, and thus return immediately,
  2237. you may want to read about interlacing in the PNG specification,
  2238. and only update the rows that are actually used.
  2239. .SS Finishing a sequential write
  2240. After you are finished writing the image, you should finish writing
  2241. the file. If you are interested in writing comments or time, you should
  2242. pass an appropriately filled png_info pointer. If you are not interested,
  2243. you can pass NULL.
  2244. png_write_end(png_ptr, info_ptr);
  2245. When you are done, you can free all memory used by libpng like this:
  2246. png_destroy_write_struct(&png_ptr, &info_ptr);
  2247. It is also possible to individually free the info_ptr members that
  2248. point to libpng-allocated storage with the following function:
  2249. png_free_data(png_ptr, info_ptr, mask, seq)
  2250. mask - identifies data to be freed, a mask
  2251. containing the logical OR of one or
  2252. more of
  2253. PNG_FREE_PLTE, PNG_FREE_TRNS,
  2254. PNG_FREE_HIST, PNG_FREE_ICCP,
  2255. PNG_FREE_PCAL, PNG_FREE_ROWS,
  2256. PNG_FREE_SCAL, PNG_FREE_SPLT,
  2257. PNG_FREE_TEXT, PNG_FREE_UNKN,
  2258. or simply PNG_FREE_ALL
  2259. seq - sequence number of item to be freed
  2260. (-1 for all items)
  2261. This function may be safely called when the relevant storage has
  2262. already been freed, or has not yet been allocated, or was allocated
  2263. by the user and not by libpng, and will in those
  2264. cases do nothing. The "seq" parameter is ignored if only one item
  2265. of the selected data type, such as PLTE, is allowed. If "seq" is not
  2266. -1, and multiple items are allowed for the data type identified in
  2267. the mask, such as text or sPLT, only the n'th item in the structure
  2268. is freed, where n is "seq".
  2269. If you allocated data such as a palette that you passed
  2270. in to libpng with png_set_*, you must not free it until just before the call to
  2271. png_destroy_write_struct().
  2272. The default behavior is only to free data that was allocated internally
  2273. by libpng. This can be changed, so that libpng will not free the data,
  2274. or so that it will free data that was allocated by the user with png_malloc()
  2275. or png_zalloc() and passed in via a png_set_*() function, with
  2276. png_data_freer(png_ptr, info_ptr, freer, mask)
  2277. mask - which data elements are affected
  2278. same choices as in png_free_data()
  2279. freer - one of
  2280. PNG_DESTROY_WILL_FREE_DATA
  2281. PNG_SET_WILL_FREE_DATA
  2282. PNG_USER_WILL_FREE_DATA
  2283. For example, to transfer responsibility for some data from a read structure
  2284. to a write structure, you could use
  2285. png_data_freer(read_ptr, read_info_ptr,
  2286. PNG_USER_WILL_FREE_DATA,
  2287. PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST)
  2288. png_data_freer(write_ptr, write_info_ptr,
  2289. PNG_DESTROY_WILL_FREE_DATA,
  2290. PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST)
  2291. thereby briefly reassigning responsibility for freeing to the user but
  2292. immediately afterwards reassigning it once more to the write_destroy
  2293. function. Having done this, it would then be safe to destroy the read
  2294. structure and continue to use the PLTE, tRNS, and hIST data in the write
  2295. structure.
  2296. This function only affects data that has already been allocated.
  2297. You can call this function before calling after the png_set_*() functions
  2298. to control whether the user or png_destroy_*() is supposed to free the data.
  2299. When the user assumes responsibility for libpng-allocated data, the
  2300. application must use
  2301. png_free() to free it, and when the user transfers responsibility to libpng
  2302. for data that the user has allocated, the user must have used png_malloc()
  2303. or png_zalloc() to allocate it.
  2304. If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword
  2305. separately, do not transfer responsibility for freeing text_ptr to libpng,
  2306. because when libpng fills a png_text structure it combines these members with
  2307. the key member, and png_free_data() will free only text_ptr.key. Similarly,
  2308. if you transfer responsibility for free'ing text_ptr from libpng to your
  2309. application, your application must not separately free those members.
  2310. For a more compact example of writing a PNG image, see the file example.c.
  2311. .SH V. Modifying/Customizing libpng:
  2312. There are three issues here. The first is changing how libpng does
  2313. standard things like memory allocation, input/output, and error handling.
  2314. The second deals with more complicated things like adding new chunks,
  2315. adding new transformations, and generally changing how libpng works.
  2316. Both of those are compile-time issues; that is, they are generally
  2317. determined at the time the code is written, and there is rarely a need
  2318. to provide the user with a means of changing them. The third is a
  2319. run-time issue: choosing between and/or tuning one or more alternate
  2320. versions of computationally intensive routines; specifically, optimized
  2321. assembly-language (and therefore compiler- and platform-dependent)
  2322. versions.
  2323. Memory allocation, input/output, and error handling
  2324. All of the memory allocation, input/output, and error handling in libpng
  2325. goes through callbacks that are user-settable. The default routines are
  2326. in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change
  2327. these functions, call the appropriate png_set_*_fn() function.
  2328. Memory allocation is done through the functions png_malloc()
  2329. and png_free(). These currently just call the standard C functions. If
  2330. your pointers can't access more then 64K at a time, you will want to set
  2331. MAXSEG_64K in zlib.h. Since it is unlikely that the method of handling
  2332. memory allocation on a platform will change between applications, these
  2333. functions must be modified in the library at compile time. If you prefer
  2334. to use a different method of allocating and freeing data, you can use
  2335. png_create_read_struct_2() or png_create_write_struct_2() to register
  2336. your own functions as described above.
  2337. These functions also provide a void pointer that can be retrieved via
  2338. mem_ptr=png_get_mem_ptr(png_ptr);
  2339. Your replacement memory functions must have prototypes as follows:
  2340. png_voidp malloc_fn(png_structp png_ptr,
  2341. png_size_t size);
  2342. void free_fn(png_structp png_ptr, png_voidp ptr);
  2343. Your malloc_fn() must return NULL in case of failure. The png_malloc()
  2344. function will normally call png_error() if it receives a NULL from the
  2345. system memory allocator or from your replacement malloc_fn().
  2346. Input/Output in libpng is done through png_read() and png_write(),
  2347. which currently just call fread() and fwrite(). The FILE * is stored in
  2348. png_struct and is initialized via png_init_io(). If you wish to change
  2349. the method of I/O, the library supplies callbacks that you can set
  2350. through the function png_set_read_fn() and png_set_write_fn() at run
  2351. time, instead of calling the png_init_io() function. These functions
  2352. also provide a void pointer that can be retrieved via the function
  2353. png_get_io_ptr(). For example:
  2354. png_set_read_fn(png_structp read_ptr,
  2355. voidp read_io_ptr, png_rw_ptr read_data_fn)
  2356. png_set_write_fn(png_structp write_ptr,
  2357. voidp write_io_ptr, png_rw_ptr write_data_fn,
  2358. png_flush_ptr output_flush_fn);
  2359. voidp read_io_ptr = png_get_io_ptr(read_ptr);
  2360. voidp write_io_ptr = png_get_io_ptr(write_ptr);
  2361. The replacement I/O functions must have prototypes as follows:
  2362. void user_read_data(png_structp png_ptr,
  2363. png_bytep data, png_size_t length);
  2364. void user_write_data(png_structp png_ptr,
  2365. png_bytep data, png_size_t length);
  2366. void user_flush_data(png_structp png_ptr);
  2367. Supplying NULL for the read, write, or flush functions sets them back
  2368. to using the default C stream functions. It is an error to read from
  2369. a write stream, and vice versa.
  2370. Error handling in libpng is done through png_error() and png_warning().
  2371. Errors handled through png_error() are fatal, meaning that png_error()
  2372. should never return to its caller. Currently, this is handled via
  2373. setjmp() and longjmp() (unless you have compiled libpng with
  2374. PNG_SETJMP_NOT_SUPPORTED, in which case it is handled via PNG_ABORT()),
  2375. but you could change this to do things like exit() if you should wish.
  2376. On non-fatal errors, png_warning() is called
  2377. to print a warning message, and then control returns to the calling code.
  2378. By default png_error() and png_warning() print a message on stderr via
  2379. fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined
  2380. (because you don't want the messages) or PNG_NO_STDIO defined (because
  2381. fprintf() isn't available). If you wish to change the behavior of the error
  2382. functions, you will need to set up your own message callbacks. These
  2383. functions are normally supplied at the time that the png_struct is created.
  2384. It is also possible to redirect errors and warnings to your own replacement
  2385. functions after png_create_*_struct() has been called by calling:
  2386. png_set_error_fn(png_structp png_ptr,
  2387. png_voidp error_ptr, png_error_ptr error_fn,
  2388. png_error_ptr warning_fn);
  2389. png_voidp error_ptr = png_get_error_ptr(png_ptr);
  2390. If NULL is supplied for either error_fn or warning_fn, then the libpng
  2391. default function will be used, calling fprintf() and/or longjmp() if a
  2392. problem is encountered. The replacement error functions should have
  2393. parameters as follows:
  2394. void user_error_fn(png_structp png_ptr,
  2395. png_const_charp error_msg);
  2396. void user_warning_fn(png_structp png_ptr,
  2397. png_const_charp warning_msg);
  2398. The motivation behind using setjmp() and longjmp() is the C++ throw and
  2399. catch exception handling methods. This makes the code much easier to write,
  2400. as there is no need to check every return code of every function call.
  2401. However, there are some uncertainties about the status of local variables
  2402. after a longjmp, so the user may want to be careful about doing anything after
  2403. setjmp returns non-zero besides returning itself. Consult your compiler
  2404. documentation for more details. For an alternative approach, you may wish
  2405. to use the "cexcept" facility (see http://cexcept.sourceforge.net).
  2406. .SS Custom chunks
  2407. If you need to read or write custom chunks, you may need to get deeper
  2408. into the libpng code. The library now has mechanisms for storing
  2409. and writing chunks of unknown type; you can even declare callbacks
  2410. for custom chunks. Hoewver, this may not be good enough if the
  2411. library code itself needs to know about interactions between your
  2412. chunk and existing `intrinsic' chunks.
  2413. If you need to write a new intrinsic chunk, first read the PNG
  2414. specification. Acquire a first level of
  2415. understanding of how it works. Pay particular attention to the
  2416. sections that describe chunk names, and look at how other chunks were
  2417. designed, so you can do things similarly. Second, check out the
  2418. sections of libpng that read and write chunks. Try to find a chunk
  2419. that is similar to yours and use it as a template. More details can
  2420. be found in the comments inside the code. It is best to handle unknown
  2421. chunks in a generic method, via callback functions, instead of by
  2422. modifying libpng functions.
  2423. If you wish to write your own transformation for the data, look through
  2424. the part of the code that does the transformations, and check out some of
  2425. the simpler ones to get an idea of how they work. Try to find a similar
  2426. transformation to the one you want to add and copy off of it. More details
  2427. can be found in the comments inside the code itself.
  2428. .SS Configuring for 16 bit platforms
  2429. You will want to look into zconf.h to tell zlib (and thus libpng) that
  2430. it cannot allocate more then 64K at a time. Even if you can, the memory
  2431. won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
  2432. .SS Configuring for DOS
  2433. For DOS users who only have access to the lower 640K, you will
  2434. have to limit zlib's memory usage via a png_set_compression_mem_level()
  2435. call. See zlib.h or zconf.h in the zlib library for more information.
  2436. .SS Configuring for Medium Model
  2437. Libpng's support for medium model has been tested on most of the popular
  2438. compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
  2439. defined, and FAR gets defined to far in pngconf.h, and you should be
  2440. all set. Everything in the library (except for zlib's structure) is
  2441. expecting far data. You must use the typedefs with the p or pp on
  2442. the end for pointers (or at least look at them and be careful). Make
  2443. note that the rows of data are defined as png_bytepp, which is an
  2444. unsigned char far * far *.
  2445. .SS Configuring for gui/windowing platforms:
  2446. You will need to write new error and warning functions that use the GUI
  2447. interface, as described previously, and set them to be the error and
  2448. warning functions at the time that png_create_*_struct() is called,
  2449. in order to have them available during the structure initialization.
  2450. They can be changed later via png_set_error_fn(). On some compilers,
  2451. you may also have to change the memory allocators (png_malloc, etc.).
  2452. .SS Configuring for compiler xxx:
  2453. All includes for libpng are in pngconf.h. If you need to add/change/delete
  2454. an include, this is the place to do it. The includes that are not
  2455. needed outside libpng are protected by the PNG_INTERNAL definition,
  2456. which is only defined for those routines inside libpng itself. The
  2457. files in libpng proper only include png.h, which includes pngconf.h.
  2458. .SS Configuring zlib:
  2459. There are special functions to configure the compression. Perhaps the
  2460. most useful one changes the compression level, which currently uses
  2461. input compression values in the range 0 - 9. The library normally
  2462. uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests
  2463. have shown that for a large majority of images, compression values in
  2464. the range 3-6 compress nearly as well as higher levels, and do so much
  2465. faster. For online applications it may be desirable to have maximum speed
  2466. (Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also
  2467. specify no compression (Z_NO_COMPRESSION = 0), but this would create
  2468. files larger than just storing the raw bitmap. You can specify the
  2469. compression level by calling:
  2470. png_set_compression_level(png_ptr, level);
  2471. Another useful one is to reduce the memory level used by the library.
  2472. The memory level defaults to 8, but it can be lowered if you are
  2473. short on memory (running DOS, for example, where you only have 640K).
  2474. Note that the memory level does have an effect on compression; among
  2475. other things, lower levels will result in sections of incompressible
  2476. data being emitted in smaller stored blocks, with a correspondingly
  2477. larger relative overhead of up to 15% in the worst case.
  2478. png_set_compression_mem_level(png_ptr, level);
  2479. The other functions are for configuring zlib. They are not recommended
  2480. for normal use and may result in writing an invalid PNG file. See
  2481. zlib.h for more information on what these mean.
  2482. png_set_compression_strategy(png_ptr,
  2483. strategy);
  2484. png_set_compression_window_bits(png_ptr,
  2485. window_bits);
  2486. png_set_compression_method(png_ptr, method);
  2487. png_set_compression_buffer_size(png_ptr, size);
  2488. .SS Controlling row filtering
  2489. If you want to control whether libpng uses filtering or not, which
  2490. filters are used, and how it goes about picking row filters, you
  2491. can call one of these functions. The selection and configuration
  2492. of row filters can have a significant impact on the size and
  2493. encoding speed and a somewhat lesser impact on the decoding speed
  2494. of an image. Filtering is enabled by default for RGB and grayscale
  2495. images (with and without alpha), but not for paletted images nor
  2496. for any images with bit depths less than 8 bits/pixel.
  2497. The 'method' parameter sets the main filtering method, which is
  2498. currently only '0' in the PNG 1.2 specification. The 'filters'
  2499. parameter sets which filter(s), if any, should be used for each
  2500. scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS
  2501. to turn filtering on and off, respectively.
  2502. Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB,
  2503. PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise
  2504. ORed together with '|' to specify one or more filters to use.
  2505. These filters are described in more detail in the PNG specification.
  2506. If you intend to change the filter type during the course of writing
  2507. the image, you should start with flags set for all of the filters
  2508. you intend to use so that libpng can initialize its internal
  2509. structures appropriately for all of the filter types. (Note that this
  2510. means the first row must always be adaptively filtered, because libpng
  2511. currently does not allocate the filter buffers until png_write_row()
  2512. is called for the first time.)
  2513. filters = PNG_FILTER_NONE | PNG_FILTER_SUB
  2514. PNG_FILTER_UP | PNG_FILTER_AVE |
  2515. PNG_FILTER_PAETH | PNG_ALL_FILTERS;
  2516. png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE,
  2517. filters);
  2518. The second parameter can also be
  2519. PNG_INTRAPIXEL_DIFFERENCING if you are
  2520. writing a PNG to be embedded in a MNG
  2521. datastream. This parameter must be the
  2522. same as the value of filter_method used
  2523. in png_set_IHDR().
  2524. It is also possible to influence how libpng chooses from among the
  2525. available filters. This is done in one or both of two ways - by
  2526. telling it how important it is to keep the same filter for successive
  2527. rows, and by telling it the relative computational costs of the filters.
  2528. double weights[3] = {1.5, 1.3, 1.1},
  2529. costs[PNG_FILTER_VALUE_LAST] =
  2530. {1.0, 1.3, 1.3, 1.5, 1.7};
  2531. png_set_filter_heuristics(png_ptr,
  2532. PNG_FILTER_HEURISTIC_WEIGHTED, 3,
  2533. weights, costs);
  2534. The weights are multiplying factors that indicate to libpng that the
  2535. row filter should be the same for successive rows unless another row filter
  2536. is that many times better than the previous filter. In the above example,
  2537. if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a
  2538. "sum of absolute differences" 1.5 x 1.3 times higher than other filters
  2539. and still be chosen, while the NONE filter could have a sum 1.1 times
  2540. higher than other filters and still be chosen. Unspecified weights are
  2541. taken to be 1.0, and the specified weights should probably be declining
  2542. like those above in order to emphasize recent filters over older filters.
  2543. The filter costs specify for each filter type a relative decoding cost
  2544. to be considered when selecting row filters. This means that filters
  2545. with higher costs are less likely to be chosen over filters with lower
  2546. costs, unless their "sum of absolute differences" is that much smaller.
  2547. The costs do not necessarily reflect the exact computational speeds of
  2548. the various filters, since this would unduly influence the final image
  2549. size.
  2550. Note that the numbers above were invented purely for this example and
  2551. are given only to help explain the function usage. Little testing has
  2552. been done to find optimum values for either the costs or the weights.
  2553. .SS Removing unwanted object code
  2554. There are a bunch of #define's in pngconf.h that control what parts of
  2555. libpng are compiled. All the defines end in _SUPPORTED. If you are
  2556. never going to use a capability, you can change the #define to #undef
  2557. before recompiling libpng and save yourself code and data space, or
  2558. you can turn off individual capabilities with defines that begin with
  2559. PNG_NO_.
  2560. You can also turn all of the transforms and ancillary chunk capabilities
  2561. off en masse with compiler directives that define
  2562. PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
  2563. or all four,
  2564. along with directives to turn on any of the capabilities that you do
  2565. want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable
  2566. the extra transformations but still leave the library fully capable of reading
  2567. and writing PNG files with all known public chunks
  2568. Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive
  2569. produces a library that is incapable of reading or writing ancillary chunks.
  2570. If you are not using the progressive reading capability, you can
  2571. turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse
  2572. this with the INTERLACING capability, which you'll still have).
  2573. All the reading and writing specific code are in separate files, so the
  2574. linker should only grab the files it needs. However, if you want to
  2575. make sure, or if you are building a stand alone library, all the
  2576. reading files start with pngr and all the writing files start with
  2577. pngw. The files that don't match either (like png.c, pngtrans.c, etc.)
  2578. are used for both reading and writing, and always need to be included.
  2579. The progressive reader is in pngpread.c
  2580. If you are creating or distributing a dynamically linked library (a .so
  2581. or DLL file), you should not remove or disable any parts of the library,
  2582. as this will cause applications linked with different versions of the
  2583. library to fail if they call functions not available in your library.
  2584. The size of the library itself should not be an issue, because only
  2585. those sections that are actually used will be loaded into memory.
  2586. .SS Requesting debug printout
  2587. The macro definition PNG_DEBUG can be used to request debugging
  2588. printout. Set it to an integer value in the range 0 to 3. Higher
  2589. numbers result in increasing amounts of debugging information. The
  2590. information is printed to the "stderr" file, unless another file
  2591. name is specified in the PNG_DEBUG_FILE macro definition.
  2592. When PNG_DEBUG > 0, the following functions (macros) become available:
  2593. png_debug(level, message)
  2594. png_debug1(level, message, p1)
  2595. png_debug2(level, message, p1, p2)
  2596. in which "level" is compared to PNG_DEBUG to decide whether to print
  2597. the message, "message" is the formatted string to be printed,
  2598. and p1 and p2 are parameters that are to be embedded in the string
  2599. according to printf-style formatting directives. For example,
  2600. png_debug1(2, "foo=%d\n", foo);
  2601. is expanded to
  2602. if(PNG_DEBUG > 2)
  2603. fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo);
  2604. When PNG_DEBUG is defined but is zero, the macros aren't defined, but you
  2605. can still use PNG_DEBUG to control your own debugging:
  2606. #ifdef PNG_DEBUG
  2607. fprintf(stderr, ...
  2608. #endif
  2609. When PNG_DEBUG = 1, the macros are defined, but only png_debug statements
  2610. having level = 0 will be printed. There aren't any such statements in
  2611. this version of libpng, but if you insert some they will be printed.
  2612. .SH VI. Runtime optimization
  2613. A new feature in libpng 1.2.0 is the ability to dynamically switch between
  2614. standard and optimized versions of some routines. Currently these are
  2615. limited to three computationally intensive tasks when reading PNG files:
  2616. decoding row filters, expanding interlacing, and combining interlaced or
  2617. transparent row data with previous row data. Currently the optimized
  2618. versions are available only for x86 (Intel, AMD, etc.) platforms with
  2619. MMX support, though this may change in future versions. (For example,
  2620. the non-MMX assembler optimizations for zlib might become similarly
  2621. runtime-selectable in future releases, in which case libpng could be
  2622. extended to support them. Alternatively, the compile-time choice of
  2623. floating-point versus integer routines for gamma correction might become
  2624. runtime-selectable.)
  2625. Because such optimizations tend to be very platform- and compiler-dependent,
  2626. both in how they are written and in how they perform, the new runtime code
  2627. in libpng has been written to allow programs to query, enable, and disable
  2628. either specific optimizations or all such optimizations. For example, to
  2629. enable all possible optimizations (bearing in mind that some "optimizations"
  2630. may actually run more slowly in rare cases):
  2631. #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
  2632. png_uint_32 mask, flags;
  2633. flags = png_get_asm_flags(png_ptr);
  2634. mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE);
  2635. png_set_asm_flags(png_ptr, flags | mask);
  2636. #endif
  2637. To enable only optimizations relevant to reading PNGs, use PNG_SELECT_READ
  2638. by itself when calling png_get_asm_flagmask(); similarly for optimizing
  2639. only writing. To disable all optimizations:
  2640. #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
  2641. flags = png_get_asm_flags(png_ptr);
  2642. mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE);
  2643. png_set_asm_flags(png_ptr, flags & ~mask);
  2644. #endif
  2645. To enable or disable only MMX-related features, use png_get_mmx_flagmask()
  2646. in place of png_get_asm_flagmask(). The mmx version takes one additional
  2647. parameter:
  2648. #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
  2649. int selection = PNG_SELECT_READ | PNG_SELECT_WRITE;
  2650. int compilerID;
  2651. mask = png_get_mmx_flagmask(selection, &compilerID);
  2652. #endif
  2653. On return, compilerID will indicate which version of the MMX assembler
  2654. optimizations was compiled. Currently two flavors exist: Microsoft
  2655. Visual C++ (compilerID == 1) and GNU C (a.k.a. gcc/gas, compilerID == 2).
  2656. On non-x86 platforms or on systems compiled without MMX optimizations, a
  2657. value of -1 is used.
  2658. Note that both png_get_asm_flagmask() and png_get_mmx_flagmask() return
  2659. all valid, settable optimization bits for the version of the library that's
  2660. currently in use. In the case of shared (dynamically linked) libraries,
  2661. this may include optimizations that did not exist at the time the code was
  2662. written and compiled. It is also possible, of course, to enable only known,
  2663. specific optimizations; for example:
  2664. #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
  2665. flags = PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \
  2666. | PNG_ASM_FLAG_MMX_READ_INTERLACE \
  2667. | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \
  2668. | PNG_ASM_FLAG_MMX_READ_FILTER_UP \
  2669. | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \
  2670. | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
  2671. png_set_asm_flags(png_ptr, flags);
  2672. #endif
  2673. This method would enable only the MMX read-optimizations available at the
  2674. time of libpng 1.2.0's release, regardless of whether a later version of
  2675. the DLL were actually being used. (Also note that these functions did not
  2676. exist in versions older than 1.2.0, so any attempt to run a dynamically
  2677. linked app on such an older version would fail.)
  2678. To determine whether the processor supports MMX instructions at all, use
  2679. the png_mmx_support() function:
  2680. #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
  2681. mmxsupport = png_mmx_support();
  2682. #endif
  2683. It returns -1 if MMX support is not compiled into libpng, 0 if MMX code
  2684. is compiled but MMX is not supported by the processor, or 1 if MMX support
  2685. is fully available. Note that png_mmx_support(), png_get_mmx_flagmask(),
  2686. and png_get_asm_flagmask() all may be called without allocating and ini-
  2687. tializing any PNG structures (for example, as part of a usage screen or
  2688. "about" box).
  2689. The following code can be used to prevent an application from using the
  2690. thread_unsafe features, even if libpng was built with PNG_THREAD_UNSAFE_OK
  2691. defined:
  2692. #if defined(PNG_USE_PNGGCCRD) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) \
  2693. && defined(PNG_THREAD_UNSAFE_OK)
  2694. /* Disable thread-unsafe features of pnggccrd */
  2695. if (png_access_version() >= 10200)
  2696. {
  2697. png_uint_32 mmx_disable_mask = 0;
  2698. png_uint_32 asm_flags;
  2699. mmx_disable_mask |= ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \
  2700. | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \
  2701. | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \
  2702. | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH );
  2703. asm_flags = png_get_asm_flags(png_ptr);
  2704. png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask);
  2705. }
  2706. #endif
  2707. For more extensive examples of runtime querying, enabling and disabling
  2708. of optimized features, see contrib/gregbook/readpng2.c in the libpng
  2709. source-code distribution.
  2710. .SH VII. MNG support
  2711. The MNG specification (available at http://www.libpng.org/pub/mng) allows
  2712. certain extensions to PNG for PNG images that are embedded in MNG datastreams.
  2713. Libpng can support some of these extensions. To enable them, use the
  2714. png_permit_mng_features() function:
  2715. feature_set = png_permit_mng_features(png_ptr, mask)
  2716. mask is a png_uint_32 containing the logical OR of the
  2717. features you want to enable. These include
  2718. PNG_FLAG_MNG_EMPTY_PLTE
  2719. PNG_FLAG_MNG_FILTER_64
  2720. PNG_ALL_MNG_FEATURES
  2721. feature_set is a png_uint_32 that is the logical AND of
  2722. your mask with the set of MNG features that is
  2723. supported by the version of libpng that you are using.
  2724. It is an error to use this function when reading or writing a standalone
  2725. PNG file with the PNG 8-byte signature. The PNG datastream must be wrapped
  2726. in a MNG datastream. As a minimum, it must have the MNG 8-byte signature
  2727. and the MHDR and MEND chunks. Libpng does not provide support for these
  2728. or any other MNG chunks; your application must provide its own support for
  2729. them. You may wish to consider using libmng (available at
  2730. http://www.libmng.com) instead.
  2731. .SH VIII. Changes to Libpng from version 0.88
  2732. It should be noted that versions of libpng later than 0.96 are not
  2733. distributed by the original libpng author, Guy Schalnat, nor by
  2734. Andreas Dilger, who had taken over from Guy during 1996 and 1997, and
  2735. distributed versions 0.89 through 0.96, but rather by another member
  2736. of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are
  2737. still alive and well, but they have moved on to other things.
  2738. The old libpng functions png_read_init(), png_write_init(),
  2739. png_info_init(), png_read_destroy(), and png_write_destroy() have been
  2740. moved to PNG_INTERNAL in version 0.95 to discourage their use. These
  2741. functions will be removed from libpng version 2.0.0.
  2742. The preferred method of creating and initializing the libpng structures is
  2743. via the png_create_read_struct(), png_create_write_struct(), and
  2744. png_create_info_struct() because they isolate the size of the structures
  2745. from the application, allow version error checking, and also allow the
  2746. use of custom error handling routines during the initialization, which
  2747. the old functions do not. The functions png_read_destroy() and
  2748. png_write_destroy() do not actually free the memory that libpng
  2749. allocated for these structs, but just reset the data structures, so they
  2750. can be used instead of png_destroy_read_struct() and
  2751. png_destroy_write_struct() if you feel there is too much system overhead
  2752. allocating and freeing the png_struct for each image read.
  2753. Setting the error callbacks via png_set_message_fn() before
  2754. png_read_init() as was suggested in libpng-0.88 is no longer supported
  2755. because this caused applications that do not use custom error functions
  2756. to fail if the png_ptr was not initialized to zero. It is still possible
  2757. to set the error callbacks AFTER png_read_init(), or to change them with
  2758. png_set_error_fn(), which is essentially the same function, but with a new
  2759. name to force compilation errors with applications that try to use the old
  2760. method.
  2761. Starting with version 1.0.7, you can find out which version of the library
  2762. you are using at run-time:
  2763. png_uint_32 libpng_vn = png_access_version_number();
  2764. The number libpng_vn is constructed from the major version, minor
  2765. version with leading zero, and release number with leading zero,
  2766. (e.g., libpng_vn for version 1.0.7 is 10007).
  2767. You can also check which version of png.h you used when compiling your
  2768. application:
  2769. png_uint_32 application_vn = PNG_LIBPNG_VER;
  2770. .SH IX. Y2K Compliance in libpng
  2771. December 3, 2004
  2772. Since the PNG Development group is an ad-hoc body, we can't make
  2773. an official declaration.
  2774. This is your unofficial assurance that libpng from version 0.71 and
  2775. upward through 1.2.8 are Y2K compliant. It is my belief that earlier
  2776. versions were also Y2K compliant.
  2777. Libpng only has three year fields. One is a 2-byte unsigned integer that
  2778. will hold years up to 65535. The other two hold the date in text
  2779. format, and will hold years up to 9999.
  2780. The integer is
  2781. "png_uint_16 year" in png_time_struct.
  2782. The strings are
  2783. "png_charp time_buffer" in png_struct and
  2784. "near_time_buffer", which is a local character string in png.c.
  2785. There are seven time-related functions:
  2786. png_convert_to_rfc_1123() in png.c
  2787. (formerly png_convert_to_rfc_1152() in error)
  2788. png_convert_from_struct_tm() in pngwrite.c, called
  2789. in pngwrite.c
  2790. png_convert_from_time_t() in pngwrite.c
  2791. png_get_tIME() in pngget.c
  2792. png_handle_tIME() in pngrutil.c, called in pngread.c
  2793. png_set_tIME() in pngset.c
  2794. png_write_tIME() in pngwutil.c, called in pngwrite.c
  2795. All appear to handle dates properly in a Y2K environment. The
  2796. png_convert_from_time_t() function calls gmtime() to convert from system
  2797. clock time, which returns (year - 1900), which we properly convert to
  2798. the full 4-digit year. There is a possibility that applications using
  2799. libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
  2800. function, or that they are incorrectly passing only a 2-digit year
  2801. instead of "year - 1900" into the png_convert_from_struct_tm() function,
  2802. but this is not under our control. The libpng documentation has always
  2803. stated that it works with 4-digit years, and the APIs have been
  2804. documented as such.
  2805. The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
  2806. integer to hold the year, and can hold years as large as 65535.
  2807. zlib, upon which libpng depends, is also Y2K compliant. It contains
  2808. no date-related code.
  2809. Glenn Randers-Pehrson
  2810. libpng maintainer
  2811. PNG Development Group
  2812. .SH NOTE
  2813. Note about libpng version numbers:
  2814. Due to various miscommunications, unforeseen code incompatibilities
  2815. and occasional factors outside the authors' control, version numbering
  2816. on the library has not always been consistent and straightforward.
  2817. The following table summarizes matters since version 0.89c, which was
  2818. the first widely used release:
  2819. source png.h png.h shared-lib
  2820. version string int version
  2821. ------- ------ ----- ----------
  2822. 0.89c ("beta 3") 0.89 89 1.0.89
  2823. 0.90 ("beta 4") 0.90 90 0.90
  2824. 0.95 ("beta 5") 0.95 95 0.95
  2825. 0.96 ("beta 6") 0.96 96 0.96
  2826. 0.97b ("beta 7") 1.00.97 97 1.0.1
  2827. 0.97c 0.97 97 2.0.97
  2828. 0.98 0.98 98 2.0.98
  2829. 0.99 0.99 98 2.0.99
  2830. 0.99a-m 0.99 99 2.0.99
  2831. 1.00 1.00 100 2.1.0
  2832. 1.0.0 1.0.0 100 2.1.0
  2833. 1.0.0 (from here on, the 100 2.1.0
  2834. 1.0.1 png.h string is 10001 2.1.0
  2835. 1.0.1a-e identical to the 10002 from here on, the
  2836. 1.0.2 source version) 10002 shared library is 2.V
  2837. 1.0.2a-b 10003 where V is the source
  2838. 1.0.1 10001 code version except as
  2839. 1.0.1a-e 10002 2.1.0.1a-e noted.
  2840. 1.0.2 10002 2.1.0.2
  2841. 1.0.2a-b 10003 2.1.0.2a-b
  2842. 1.0.3 10003 2.1.0.3
  2843. 1.0.3a-d 10004 2.1.0.3a-d
  2844. 1.0.4 10004 2.1.0.4
  2845. 1.0.4a-f 10005 2.1.0.4a-f
  2846. 1.0.5 (+ 2 patches) 10005 2.1.0.5
  2847. 1.0.5a-d 10006 2.1.0.5a-d
  2848. 1.0.5e-r 10100 2.1.0.5e-r
  2849. 1.0.5s-v 10006 2.1.0.5s-v
  2850. 1.0.6 (+ 3 patches) 10006 2.1.0.6
  2851. 1.0.6d-g 10007 2.1.0.6d-g
  2852. 1.0.6h 10007 10.6h
  2853. 1.0.6i 10007 10.6i
  2854. 1.0.6j 10007 2.1.0.6j
  2855. 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14
  2856. 1.0.7beta15-18 1 10007 2.1.0.7beta15-18
  2857. 1.0.7rc1-2 1 10007 2.1.0.7rc1-2
  2858. 1.0.7 1 10007 2.1.0.7
  2859. 1.0.8beta1-4 1 10008 2.1.0.8beta1-4
  2860. 1.0.8rc1 1 10008 2.1.0.8rc1
  2861. 1.0.8 1 10008 2.1.0.8
  2862. 1.0.9beta1-6 1 10009 2.1.0.9beta1-6
  2863. 1.0.9rc1 1 10009 2.1.0.9rc1
  2864. 1.0.9beta7-10 1 10009 2.1.0.9beta7-10
  2865. 1.0.9rc2 1 10009 2.1.0.9rc2
  2866. 1.0.9 1 10009 2.1.0.9
  2867. 1.0.10beta1 1 10010 2.1.0.10beta1
  2868. 1.0.10rc1 1 10010 2.1.0.10rc1
  2869. 1.0.10 1 10010 2.1.0.10
  2870. 1.0.11beta1-3 1 10011 2.1.0.11beta1-3
  2871. 1.0.11rc1 1 10011 2.1.0.11rc1
  2872. 1.0.11 1 10011 2.1.0.11
  2873. 1.0.12beta1-2 2 10012 2.1.0.12beta1-2
  2874. 1.0.12rc1 2 10012 2.1.0.12rc1
  2875. 1.0.12 2 10012 2.1.0.12
  2876. 1.1.0a-f - 10100 2.1.1.0a-f abandoned
  2877. 1.2.0beta1-2 2 10200 2.1.2.0beta1-2
  2878. 1.2.0beta3-5 3 10200 3.1.2.0beta3-5
  2879. 1.2.0rc1 3 10200 3.1.2.0rc1
  2880. 1.2.0 3 10200 3.1.2.0
  2881. 1.2.1beta-4 3 10201 3.1.2.1beta1-4
  2882. 1.2.1rc1-2 3 10201 3.1.2.1rc1-2
  2883. 1.2.1 3 10201 3.1.2.1
  2884. 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6
  2885. 1.0.13beta1 10 10013 10.so.0.1.0.13beta1
  2886. 1.0.13rc1 10 10013 10.so.0.1.0.13rc1
  2887. 1.2.2rc1 12 10202 12.so.0.1.2.2rc1
  2888. 1.0.13 10 10013 10.so.0.1.0.13
  2889. 1.2.2 12 10202 12.so.0.1.2.2
  2890. 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6
  2891. 1.2.3 12 10203 12.so.0.1.2.3
  2892. 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3
  2893. 1.2.4rc1 13 10204 12.so.0.1.2.4rc1
  2894. 1.0.14 10 10014 10.so.0.1.0.14
  2895. 1.2.4 13 10204 12.so.0.1.2.4
  2896. 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2
  2897. 1.0.15rc1 10 10015 10.so.0.1.0.15rc1
  2898. 1.0.15 10 10015 10.so.0.1.0.15
  2899. 1.2.5 13 10205 12.so.0.1.2.5
  2900. 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4
  2901. 1.2.6rc1-5 13 10206 12.so.0.1.2.6rc1-5
  2902. 1.0.16 10 10016 10.so.0.1.0.16
  2903. 1.2.6 13 10206 12.so.0.1.2.6
  2904. 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2
  2905. 1.0.17rc1 10 10017 12.so.0.1.0.17rc1
  2906. 1.2.7rc1 13 10207 12.so.0.1.2.7rc1
  2907. 1.0.17 10 10017 12.so.0.1.0.17
  2908. 1.2.7 13 10207 12.so.0.1.2.7
  2909. 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5
  2910. 1.0.18rc1-5 10 10018 12.so.0.1.0.18rc1-5
  2911. 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5
  2912. 1.0.18 10 10018 12.so.0.1.0.18
  2913. 1.2.8 13 10208 12.so.0.1.2.8
  2914. Henceforth the source version will match the shared-library minor
  2915. and patch numbers; the shared-library major version number will be
  2916. used for changes in backward compatibility, as it is intended. The
  2917. PNG_PNGLIB_VER macro, which is not used within libpng but is available
  2918. for applications, is an unsigned integer of the form xyyzz corresponding
  2919. to the source version x.y.z (leading zeros in y and z). Beta versions
  2920. were given the previous public release number plus a letter, until
  2921. version 1.0.6j; from then on they were given the upcoming public
  2922. release number plus "betaNN" or "rcN".
  2923. .SH "SEE ALSO"
  2924. libpngpf(3), png(5)
  2925. .LP
  2926. .IR libpng :
  2927. .IP
  2928. http://libpng.sourceforge.net (follow the [DOWNLOAD] link)
  2929. http://www.libpng.org/pub/png
  2930. .LP
  2931. .IR zlib :
  2932. .IP
  2933. (generally) at the same location as
  2934. .I libpng
  2935. or at
  2936. .br
  2937. ftp://ftp.info-zip.org/pub/infozip/zlib
  2938. .LP
  2939. .IR PNG specification: RFC 2083
  2940. .IP
  2941. (generally) at the same location as
  2942. .I libpng
  2943. or at
  2944. .br
  2945. ftp://ds.internic.net/rfc/rfc2083.txt
  2946. .br
  2947. or (as a W3C Recommendation) at
  2948. .br
  2949. http://www.w3.org/TR/REC-png.html
  2950. .LP
  2951. In the case of any inconsistency between the PNG specification
  2952. and this library, the specification takes precedence.
  2953. .SH AUTHORS
  2954. This man page: Glenn Randers-Pehrson
  2955. <glennrp at users.sourceforge.net>
  2956. The contributing authors would like to thank all those who helped
  2957. with testing, bug fixes, and patience. This wouldn't have been
  2958. possible without all of you.
  2959. Thanks to Frank J. T. Wojcik for helping with the documentation.
  2960. Libpng version 1.2.8 - December 3, 2004:
  2961. Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
  2962. Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
  2963. Supported by the PNG development group
  2964. .br
  2965. png-implement at ccrc.wustl.edu (subscription required; write to
  2966. majordomo at ccrc.wustl.edu with "subscribe png-implement" in the message).
  2967. .SH COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
  2968. (This copy of the libpng notices is provided for your convenience. In case of
  2969. any discrepancy between this copy and the notices in the file png.h that is
  2970. included in the libpng distribution, the latter shall prevail.)
  2971. If you modify libpng you may insert additional notices immediately following
  2972. this sentence.
  2973. libpng version 1.2.6, December 3, 2004, is
  2974. Copyright (c) 2004 Glenn Randers-Pehrson, and is
  2975. distributed according to the same disclaimer and license as libpng-1.2.5
  2976. with the following individual added to the list of Contributing Authors
  2977. Cosmin Truta
  2978. libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
  2979. Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
  2980. distributed according to the same disclaimer and license as libpng-1.0.6
  2981. with the following individuals added to the list of Contributing Authors
  2982. Simon-Pierre Cadieux
  2983. Eric S. Raymond
  2984. Gilles Vollant
  2985. and with the following additions to the disclaimer:
  2986. There is no warranty against interference with your
  2987. enjoyment of the library or against infringement.
  2988. There is no warranty that our efforts or the library
  2989. will fulfill any of your particular purposes or needs.
  2990. This library is provided with all faults, and the entire
  2991. risk of satisfactory quality, performance, accuracy, and
  2992. effort is with the user.
  2993. libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
  2994. Copyright (c) 1998, 1999 Glenn Randers-Pehrson
  2995. Distributed according to the same disclaimer and license as libpng-0.96,
  2996. with the following individuals added to the list of Contributing Authors:
  2997. Tom Lane
  2998. Glenn Randers-Pehrson
  2999. Willem van Schaik
  3000. libpng versions 0.89, June 1996, through 0.96, May 1997, are
  3001. Copyright (c) 1996, 1997 Andreas Dilger
  3002. Distributed according to the same disclaimer and license as libpng-0.88,
  3003. with the following individuals added to the list of Contributing Authors:
  3004. John Bowler
  3005. Kevin Bracey
  3006. Sam Bushell
  3007. Magnus Holmgren
  3008. Greg Roelofs
  3009. Tom Tanner
  3010. libpng versions 0.5, May 1995, through 0.88, January 1996, are
  3011. Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  3012. For the purposes of this copyright and license, "Contributing Authors"
  3013. is defined as the following set of individuals:
  3014. Andreas Dilger
  3015. Dave Martindale
  3016. Guy Eric Schalnat
  3017. Paul Schmidt
  3018. Tim Wegner
  3019. The PNG Reference Library is supplied "AS IS". The Contributing Authors
  3020. and Group 42, Inc. disclaim all warranties, expressed or implied,
  3021. including, without limitation, the warranties of merchantability and of
  3022. fitness for any purpose. The Contributing Authors and Group 42, Inc.
  3023. assume no liability for direct, indirect, incidental, special, exemplary,
  3024. or consequential damages, which may result from the use of the PNG
  3025. Reference Library, even if advised of the possibility of such damage.
  3026. Permission is hereby granted to use, copy, modify, and distribute this
  3027. source code, or portions hereof, for any purpose, without fee, subject
  3028. to the following restrictions:
  3029. 1. The origin of this source code must not be misrepresented.
  3030. 2. Altered versions must be plainly marked as such and
  3031. must not be misrepresented as being the original source.
  3032. 3. This Copyright notice may not be removed or altered from
  3033. any source or altered source distribution.
  3034. The Contributing Authors and Group 42, Inc. specifically permit, without
  3035. fee, and encourage the use of this source code as a component to
  3036. supporting the PNG file format in commercial products. If you use this
  3037. source code in a product, acknowledgment is not required but would be
  3038. appreciated.
  3039. A "png_get_copyright" function is available, for convenient use in "about"
  3040. boxes and the like:
  3041. printf("%s",png_get_copyright(NULL));
  3042. Also, the PNG logo (in PNG format, of course) is supplied in the
  3043. files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
  3044. Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
  3045. certification mark of the Open Source Initiative.
  3046. Glenn Randers-Pehrson
  3047. glennrp at users.sourceforge.net
  3048. December 3, 2004
  3049. .\" end of man page