libmng_chunk_xs.c 252 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016
  1. /* ************************************************************************** */
  2. /* * For conditions of distribution and use, * */
  3. /* * see copyright notice in libmng.h * */
  4. /* ************************************************************************** */
  5. /* * * */
  6. /* * project : libmng * */
  7. /* * file : libmng_chunk_xs.c copyright (c) 2000-2007 G.Juyn * */
  8. /* * version : 1.0.10 * */
  9. /* * * */
  10. /* * purpose : chunk access functions (implementation) * */
  11. /* * * */
  12. /* * author : G.Juyn * */
  13. /* * * */
  14. /* * comment : implementation of the chunk access functions * */
  15. /* * * */
  16. /* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */
  17. /* * - changed and filled iterate-chunk function * */
  18. /* * 0.5.1 - 05/08/2000 - G.Juyn * */
  19. /* * - fixed calling convention * */
  20. /* * - added getchunk functions * */
  21. /* * - added putchunk functions * */
  22. /* * - changed strict-ANSI stuff * */
  23. /* * 0.5.1 - 05/11/2000 - G.Juyn * */
  24. /* * - added empty-chunk put-routines * */
  25. /* * 0.5.1 - 05/12/2000 - G.Juyn * */
  26. /* * - changed trace to macro for callback error-reporting * */
  27. /* * 0.5.1 - 05/15/2000 - G.Juyn * */
  28. /* * - added getimgdata & putimgdata functions * */
  29. /* * * */
  30. /* * 0.5.2 - 05/19/2000 - G.Juyn * */
  31. /* * - B004 - fixed problem with MNG_SUPPORT_WRITE not defined * */
  32. /* * also for MNG_SUPPORT_WRITE without MNG_INCLUDE_JNG * */
  33. /* * - Cleaned up some code regarding mixed support * */
  34. /* * * */
  35. /* * 0.9.1 - 07/19/2000 - G.Juyn * */
  36. /* * - fixed creation-code * */
  37. /* * * */
  38. /* * 0.9.2 - 08/05/2000 - G.Juyn * */
  39. /* * - changed file-prefixes * */
  40. /* * - added function to set simplicity field * */
  41. /* * - fixed putchunk_unknown() function * */
  42. /* * * */
  43. /* * 0.9.3 - 08/07/2000 - G.Juyn * */
  44. /* * - B111300 - fixup for improved portability * */
  45. /* * 0.9.3 - 08/26/2000 - G.Juyn * */
  46. /* * - added MAGN chunk * */
  47. /* * 0.9.3 - 10/20/2000 - G.Juyn * */
  48. /* * - fixed putchunk_plte() to set bEmpty parameter * */
  49. /* * * */
  50. /* * 0.9.5 - 01/25/2001 - G.Juyn * */
  51. /* * - fixed some small compiler warnings (thanks Nikki) * */
  52. /* * * */
  53. /* * 1.0.5 - 09/07/2002 - G.Juyn * */
  54. /* * - B578940 - unimplemented functions return errorcode * */
  55. /* * 1.0.5 - 08/19/2002 - G.Juyn * */
  56. /* * - B597134 - libmng pollutes the linker namespace * */
  57. /* * - added HLAPI function to copy chunks * */
  58. /* * 1.0.5 - 09/14/2002 - G.Juyn * */
  59. /* * - added event handling for dynamic MNG * */
  60. /* * 1.0.5 - 10/07/2002 - G.Juyn * */
  61. /* * - added check for TERM placement during create/write * */
  62. /* * 1.0.5 - 11/28/2002 - G.Juyn * */
  63. /* * - fixed definition of iMethodX/Y for MAGN chunk * */
  64. /* * * */
  65. /* * 1.0.6 - 05/25/2003 - G.R-P * */
  66. /* * - added MNG_SKIPCHUNK_cHNK footprint optimizations * */
  67. /* * 1.0.6 - 07/07/2003 - G.R-P * */
  68. /* * - added MNG_NO_DELTA_PNG reduction and more SKIPCHUNK * */
  69. /* * optimizations * */
  70. /* * 1.0.6 - 07/29/2003 - G.R-P * */
  71. /* * - added conditionals around PAST chunk support * */
  72. /* * 1.0.6 - 08/17/2003 - G.R-P * */
  73. /* * - added conditionals around non-VLC chunk support * */
  74. /* * * */
  75. /* * 1.0.8 - 04/01/2004 - G.Juyn * */
  76. /* * - added missing get-/put-chunk-jdaa * */
  77. /* * 1.0.8 - 08/02/2004 - G.Juyn * */
  78. /* * - added conditional to allow easier writing of large MNG's * */
  79. /* * * */
  80. /* * 1.0.9 - 09/17/2004 - G.R-P * */
  81. /* * - added two more conditionals * */
  82. /* * 1.0.9 - 09/25/2004 - G.Juyn * */
  83. /* * - replaced MNG_TWEAK_LARGE_FILES with permanent solution * */
  84. /* * 1.0.9 - 17/14/2004 - G.Juyn * */
  85. /* * - fixed PPLT getchunk/putchunk routines * */
  86. /* * 1.0.9 - 12/05/2004 - G.Juyn * */
  87. /* * - added conditional MNG_OPTIMIZE_CHUNKINITFREE * */
  88. /* * 1.0.9 - 12/20/2004 - G.Juyn * */
  89. /* * - cleaned up macro-invocations (thanks to D. Airlie) * */
  90. /* * * */
  91. /* * 1.0.10 - 04/08/2007 - G.Juyn * */
  92. /* * - added support for mPNG proposal * */
  93. /* * * */
  94. /* ************************************************************************** */
  95. #include "libmng.h"
  96. #include "libmng_data.h"
  97. #include "libmng_error.h"
  98. #include "libmng_trace.h"
  99. #ifdef __BORLANDC__
  100. #pragma hdrstop
  101. #endif
  102. #include "libmng_memory.h"
  103. #include "libmng_chunks.h"
  104. #ifdef MNG_OPTIMIZE_CHUNKREADER
  105. #include "libmng_chunk_descr.h"
  106. #endif
  107. #include "libmng_chunk_prc.h"
  108. #include "libmng_chunk_io.h"
  109. #if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
  110. #pragma option -A /* force ANSI-C */
  111. #endif
  112. /* ************************************************************************** */
  113. #ifdef MNG_ACCESS_CHUNKS
  114. /* ************************************************************************** */
  115. mng_retcode MNG_DECL mng_iterate_chunks (mng_handle hHandle,
  116. mng_uint32 iChunkseq,
  117. mng_iteratechunk fProc)
  118. {
  119. mng_uint32 iSeq;
  120. mng_chunkid iChunkname;
  121. mng_datap pData;
  122. mng_chunkp pChunk;
  123. mng_bool bCont;
  124. #ifdef MNG_SUPPORT_TRACE
  125. MNG_TRACE (((mng_datap)hHandle), MNG_FN_ITERATE_CHUNKS, MNG_LC_START);
  126. #endif
  127. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  128. pData = ((mng_datap)hHandle); /* and make it addressable */
  129. iSeq = 0;
  130. bCont = MNG_TRUE;
  131. pChunk = pData->pFirstchunk; /* get the first chunk */
  132. /* as long as there are some more */
  133. while ((pChunk) && (bCont)) /* and the app didn't signal a stop */
  134. {
  135. if (iSeq >= iChunkseq) /* reached the first target ? */
  136. { /* then call this and next ones back in... */
  137. iChunkname = ((mng_chunk_headerp)pChunk)->iChunkname;
  138. bCont = fProc (hHandle, (mng_handle)pChunk, iChunkname, iSeq);
  139. }
  140. iSeq++; /* next one */
  141. pChunk = ((mng_chunk_headerp)pChunk)->pNext;
  142. }
  143. #ifdef MNG_SUPPORT_TRACE
  144. MNG_TRACE (((mng_datap)hHandle), MNG_FN_ITERATE_CHUNKS, MNG_LC_END);
  145. #endif
  146. return MNG_NOERROR;
  147. }
  148. /* ************************************************************************** */
  149. #ifdef MNG_SUPPORT_WRITE
  150. mng_retcode MNG_DECL mng_copy_chunk (mng_handle hHandle,
  151. mng_handle hChunk,
  152. mng_handle hHandleOut)
  153. {
  154. mng_datap pDataOut;
  155. mng_chunkp pChunk;
  156. mng_chunkp pChunkOut;
  157. mng_retcode iRetcode;
  158. #ifdef MNG_SUPPORT_TRACE
  159. MNG_TRACE (((mng_datap)hHandle), MNG_FN_COPY_CHUNK, MNG_LC_START);
  160. #endif
  161. MNG_VALIDHANDLE (hHandle) /* check validity handles */
  162. MNG_VALIDHANDLE (hHandleOut)
  163. pDataOut = (mng_datap)hHandleOut; /* make outhandle addressable */
  164. pChunk = (mng_chunkp)hChunk; /* address the chunk */
  165. if (!pDataOut->bCreating) /* aren't we creating a new file ? */
  166. MNG_ERROR (pDataOut, MNG_FUNCTIONINVALID)
  167. /* create a new chunk */
  168. iRetcode = ((mng_createchunk)((mng_chunk_headerp)pChunk)->fCreate)
  169. (pDataOut, ((mng_chunk_headerp)pChunk), &pChunkOut);
  170. if (!iRetcode) /* assign the chunk-specific data */
  171. iRetcode = ((mng_assignchunk)((mng_chunk_headerp)pChunk)->fAssign)
  172. (pDataOut, pChunkOut, pChunk);
  173. if (iRetcode) /* on error bail out */
  174. return iRetcode;
  175. mng_add_chunk (pDataOut, pChunkOut); /* and put it in the output-stream */
  176. /* could it be the end of the chain ? */
  177. if (((mng_chunk_headerp)pChunkOut)->iChunkname == MNG_UINT_IEND)
  178. {
  179. #ifdef MNG_INCLUDE_JNG
  180. if ((pDataOut->iFirstchunkadded == MNG_UINT_IHDR) ||
  181. (pDataOut->iFirstchunkadded == MNG_UINT_JHDR) )
  182. #else
  183. if (pDataOut->iFirstchunkadded == MNG_UINT_IHDR)
  184. #endif
  185. pDataOut->bCreating = MNG_FALSE; /* right; this should be the last chunk !!! */
  186. }
  187. if (((mng_chunk_headerp)pChunkOut)->iChunkname == MNG_UINT_MEND)
  188. pDataOut->bCreating = MNG_FALSE; /* definitely this should be the last !!! */
  189. #ifdef MNG_SUPPORT_TRACE
  190. MNG_TRACE (((mng_datap)hHandle), MNG_FN_COPY_CHUNK, MNG_LC_END);
  191. #endif
  192. return MNG_NOERROR;
  193. }
  194. #endif /* MNG_SUPPORT_WRITE */
  195. /* ************************************************************************** */
  196. mng_retcode MNG_DECL mng_getchunk_ihdr (mng_handle hHandle,
  197. mng_handle hChunk,
  198. mng_uint32 *iWidth,
  199. mng_uint32 *iHeight,
  200. mng_uint8 *iBitdepth,
  201. mng_uint8 *iColortype,
  202. mng_uint8 *iCompression,
  203. mng_uint8 *iFilter,
  204. mng_uint8 *iInterlace)
  205. {
  206. mng_datap pData;
  207. mng_ihdrp pChunk;
  208. #ifdef MNG_SUPPORT_TRACE
  209. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IHDR, MNG_LC_START);
  210. #endif
  211. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  212. pData = (mng_datap)hHandle; /* and make it addressable */
  213. pChunk = (mng_ihdrp)hChunk; /* address the chunk */
  214. if (pChunk->sHeader.iChunkname != MNG_UINT_IHDR)
  215. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  216. *iWidth = pChunk->iWidth; /* fill the fields */
  217. *iHeight = pChunk->iHeight;
  218. *iBitdepth = pChunk->iBitdepth;
  219. *iColortype = pChunk->iColortype;
  220. *iCompression = pChunk->iCompression;
  221. *iFilter = pChunk->iFilter;
  222. *iInterlace = pChunk->iInterlace;
  223. /* fill the chunk */
  224. #ifdef MNG_SUPPORT_TRACE
  225. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IHDR, MNG_LC_END);
  226. #endif
  227. return MNG_NOERROR;
  228. }
  229. /* ************************************************************************** */
  230. mng_retcode MNG_DECL mng_getchunk_plte (mng_handle hHandle,
  231. mng_handle hChunk,
  232. mng_uint32 *iCount,
  233. mng_palette8 *aPalette)
  234. {
  235. mng_datap pData;
  236. mng_pltep pChunk;
  237. #ifdef MNG_SUPPORT_TRACE
  238. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PLTE, MNG_LC_START);
  239. #endif
  240. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  241. pData = (mng_datap)hHandle; /* and make it addressable */
  242. pChunk = (mng_pltep)hChunk; /* address the chunk */
  243. if (pChunk->sHeader.iChunkname != MNG_UINT_PLTE)
  244. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  245. *iCount = pChunk->iEntrycount; /* fill the fields */
  246. MNG_COPY (*aPalette, pChunk->aEntries, sizeof (mng_palette8));
  247. #ifdef MNG_SUPPORT_TRACE
  248. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PLTE, MNG_LC_END);
  249. #endif
  250. return MNG_NOERROR;
  251. }
  252. /* ************************************************************************** */
  253. mng_retcode MNG_DECL mng_getchunk_idat (mng_handle hHandle,
  254. mng_handle hChunk,
  255. mng_uint32 *iRawlen,
  256. mng_ptr *pRawdata)
  257. {
  258. mng_datap pData;
  259. mng_idatp pChunk;
  260. #ifdef MNG_SUPPORT_TRACE
  261. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IDAT, MNG_LC_START);
  262. #endif
  263. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  264. pData = (mng_datap)hHandle; /* and make it addressable */
  265. pChunk = (mng_idatp)hChunk; /* address the chunk */
  266. if (pChunk->sHeader.iChunkname != MNG_UINT_IDAT)
  267. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  268. *iRawlen = pChunk->iDatasize; /* fill the fields */
  269. *pRawdata = pChunk->pData;
  270. #ifdef MNG_SUPPORT_TRACE
  271. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IDAT, MNG_LC_END);
  272. #endif
  273. return MNG_NOERROR;
  274. }
  275. /* ************************************************************************** */
  276. mng_retcode MNG_DECL mng_getchunk_trns (mng_handle hHandle,
  277. mng_handle hChunk,
  278. mng_bool *bEmpty,
  279. mng_bool *bGlobal,
  280. mng_uint8 *iType,
  281. mng_uint32 *iCount,
  282. mng_uint8arr *aAlphas,
  283. mng_uint16 *iGray,
  284. mng_uint16 *iRed,
  285. mng_uint16 *iGreen,
  286. mng_uint16 *iBlue,
  287. mng_uint32 *iRawlen,
  288. mng_uint8arr *aRawdata)
  289. {
  290. mng_datap pData;
  291. mng_trnsp pChunk;
  292. #ifdef MNG_SUPPORT_TRACE
  293. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TRNS, MNG_LC_START);
  294. #endif
  295. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  296. pData = (mng_datap)hHandle; /* and make it addressable */
  297. pChunk = (mng_trnsp)hChunk; /* address the chunk */
  298. if (pChunk->sHeader.iChunkname != MNG_UINT_tRNS)
  299. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  300. *bEmpty = pChunk->bEmpty; /* fill the fields */
  301. *bGlobal = pChunk->bGlobal;
  302. *iType = pChunk->iType;
  303. *iCount = pChunk->iCount;
  304. *iGray = pChunk->iGray;
  305. *iRed = pChunk->iRed;
  306. *iGreen = pChunk->iGreen;
  307. *iBlue = pChunk->iBlue;
  308. *iRawlen = pChunk->iRawlen;
  309. MNG_COPY (*aAlphas, pChunk->aEntries, sizeof (mng_uint8arr));
  310. MNG_COPY (*aRawdata, pChunk->aRawdata, sizeof (mng_uint8arr));
  311. #ifdef MNG_SUPPORT_TRACE
  312. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TRNS, MNG_LC_END);
  313. #endif
  314. return MNG_NOERROR;
  315. }
  316. /* ************************************************************************** */
  317. #ifndef MNG_SKIPCHUNK_gAMA
  318. mng_retcode MNG_DECL mng_getchunk_gama (mng_handle hHandle,
  319. mng_handle hChunk,
  320. mng_bool *bEmpty,
  321. mng_uint32 *iGamma)
  322. {
  323. mng_datap pData;
  324. mng_gamap pChunk;
  325. #ifdef MNG_SUPPORT_TRACE
  326. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_GAMA, MNG_LC_START);
  327. #endif
  328. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  329. pData = (mng_datap)hHandle; /* and make it addressable */
  330. pChunk = (mng_gamap)hChunk; /* address the chunk */
  331. if (pChunk->sHeader.iChunkname != MNG_UINT_gAMA)
  332. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  333. *bEmpty = pChunk->bEmpty; /* fill the fields */
  334. *iGamma = pChunk->iGamma;
  335. #ifdef MNG_SUPPORT_TRACE
  336. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_GAMA, MNG_LC_END);
  337. #endif
  338. return MNG_NOERROR;
  339. }
  340. #endif
  341. /* ************************************************************************** */
  342. #ifndef MNG_SKIPCHUNK_cHRM
  343. mng_retcode MNG_DECL mng_getchunk_chrm (mng_handle hHandle,
  344. mng_handle hChunk,
  345. mng_bool *bEmpty,
  346. mng_uint32 *iWhitepointx,
  347. mng_uint32 *iWhitepointy,
  348. mng_uint32 *iRedx,
  349. mng_uint32 *iRedy,
  350. mng_uint32 *iGreenx,
  351. mng_uint32 *iGreeny,
  352. mng_uint32 *iBluex,
  353. mng_uint32 *iBluey)
  354. {
  355. mng_datap pData;
  356. mng_chrmp pChunk;
  357. #ifdef MNG_SUPPORT_TRACE
  358. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CHRM, MNG_LC_START);
  359. #endif
  360. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  361. pData = (mng_datap)hHandle; /* and make it addressable */
  362. pChunk = (mng_chrmp)hChunk; /* address the chunk */
  363. if (pChunk->sHeader.iChunkname != MNG_UINT_cHRM)
  364. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  365. *bEmpty = pChunk->bEmpty; /* fill the fields */
  366. *iWhitepointx = pChunk->iWhitepointx;
  367. *iWhitepointy = pChunk->iWhitepointy;
  368. *iRedx = pChunk->iRedx;
  369. *iRedy = pChunk->iRedy;
  370. *iGreenx = pChunk->iGreenx;
  371. *iGreeny = pChunk->iGreeny;
  372. *iBluex = pChunk->iBluex;
  373. *iBluey = pChunk->iBluey;
  374. #ifdef MNG_SUPPORT_TRACE
  375. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CHRM, MNG_LC_END);
  376. #endif
  377. return MNG_NOERROR;
  378. }
  379. #endif
  380. /* ************************************************************************** */
  381. #ifndef MNG_SKIPCHUNK_sRGB
  382. mng_retcode MNG_DECL mng_getchunk_srgb (mng_handle hHandle,
  383. mng_handle hChunk,
  384. mng_bool *bEmpty,
  385. mng_uint8 *iRenderingintent)
  386. {
  387. mng_datap pData;
  388. mng_srgbp pChunk;
  389. #ifdef MNG_SUPPORT_TRACE
  390. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SRGB, MNG_LC_START);
  391. #endif
  392. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  393. pData = (mng_datap)hHandle; /* and make it addressable */
  394. pChunk = (mng_srgbp)hChunk; /* address the chunk */
  395. if (pChunk->sHeader.iChunkname != MNG_UINT_sRGB)
  396. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  397. *bEmpty = pChunk->bEmpty; /* fill the fields */
  398. *iRenderingintent = pChunk->iRenderingintent;
  399. #ifdef MNG_SUPPORT_TRACE
  400. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SRGB, MNG_LC_END);
  401. #endif
  402. return MNG_NOERROR;
  403. }
  404. #endif
  405. /* ************************************************************************** */
  406. #ifndef MNG_SKIPCHUNK_iCCP
  407. mng_retcode MNG_DECL mng_getchunk_iccp (mng_handle hHandle,
  408. mng_handle hChunk,
  409. mng_bool *bEmpty,
  410. mng_uint32 *iNamesize,
  411. mng_pchar *zName,
  412. mng_uint8 *iCompression,
  413. mng_uint32 *iProfilesize,
  414. mng_ptr *pProfile)
  415. {
  416. mng_datap pData;
  417. mng_iccpp pChunk;
  418. #ifdef MNG_SUPPORT_TRACE
  419. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ICCP, MNG_LC_START);
  420. #endif
  421. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  422. pData = (mng_datap)hHandle; /* and make it addressable */
  423. pChunk = (mng_iccpp)hChunk; /* address the chunk */
  424. if (pChunk->sHeader.iChunkname != MNG_UINT_iCCP)
  425. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  426. *bEmpty = pChunk->bEmpty; /* fill the fields */
  427. *iNamesize = pChunk->iNamesize;
  428. *zName = pChunk->zName;
  429. *iCompression = pChunk->iCompression;
  430. *iProfilesize = pChunk->iProfilesize;
  431. *pProfile = pChunk->pProfile;
  432. #ifdef MNG_SUPPORT_TRACE
  433. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ICCP, MNG_LC_END);
  434. #endif
  435. return MNG_NOERROR;
  436. }
  437. #endif
  438. /* ************************************************************************** */
  439. #ifndef MNG_SKIPCHUNK_tEXt
  440. mng_retcode MNG_DECL mng_getchunk_text (mng_handle hHandle,
  441. mng_handle hChunk,
  442. mng_uint32 *iKeywordsize,
  443. mng_pchar *zKeyword,
  444. mng_uint32 *iTextsize,
  445. mng_pchar *zText)
  446. {
  447. mng_datap pData;
  448. mng_textp pChunk;
  449. #ifdef MNG_SUPPORT_TRACE
  450. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TEXT, MNG_LC_START);
  451. #endif
  452. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  453. pData = (mng_datap)hHandle; /* and make it addressable */
  454. pChunk = (mng_textp)hChunk; /* address the chunk */
  455. if (pChunk->sHeader.iChunkname != MNG_UINT_tEXt)
  456. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  457. /* fill the fields */
  458. *iKeywordsize = pChunk->iKeywordsize;
  459. *zKeyword = pChunk->zKeyword;
  460. *iTextsize = pChunk->iTextsize;
  461. *zText = pChunk->zText;
  462. #ifdef MNG_SUPPORT_TRACE
  463. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TEXT, MNG_LC_END);
  464. #endif
  465. return MNG_NOERROR;
  466. }
  467. #endif
  468. /* ************************************************************************** */
  469. #ifndef MNG_SKIPCHUNK_zTXt
  470. mng_retcode MNG_DECL mng_getchunk_ztxt (mng_handle hHandle,
  471. mng_handle hChunk,
  472. mng_uint32 *iKeywordsize,
  473. mng_pchar *zKeyword,
  474. mng_uint8 *iCompression,
  475. mng_uint32 *iTextsize,
  476. mng_pchar *zText)
  477. {
  478. mng_datap pData;
  479. mng_ztxtp pChunk;
  480. #ifdef MNG_SUPPORT_TRACE
  481. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ZTXT, MNG_LC_START);
  482. #endif
  483. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  484. pData = (mng_datap)hHandle; /* and make it addressable */
  485. pChunk = (mng_ztxtp)hChunk; /* address the chunk */
  486. if (pChunk->sHeader.iChunkname != MNG_UINT_zTXt)
  487. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  488. /* fill the fields */
  489. *iKeywordsize = pChunk->iKeywordsize;
  490. *zKeyword = pChunk->zKeyword;
  491. *iCompression = pChunk->iCompression;
  492. *iTextsize = pChunk->iTextsize;
  493. *zText = pChunk->zText;
  494. #ifdef MNG_SUPPORT_TRACE
  495. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ZTXT, MNG_LC_END);
  496. #endif
  497. return MNG_NOERROR;
  498. }
  499. #endif
  500. /* ************************************************************************** */
  501. #ifndef MNG_SKIPCHUNK_iTXt
  502. mng_retcode MNG_DECL mng_getchunk_itxt (mng_handle hHandle,
  503. mng_handle hChunk,
  504. mng_uint32 *iKeywordsize,
  505. mng_pchar *zKeyword,
  506. mng_uint8 *iCompressionflag,
  507. mng_uint8 *iCompressionmethod,
  508. mng_uint32 *iLanguagesize,
  509. mng_pchar *zLanguage,
  510. mng_uint32 *iTranslationsize,
  511. mng_pchar *zTranslation,
  512. mng_uint32 *iTextsize,
  513. mng_pchar *zText)
  514. {
  515. mng_datap pData;
  516. mng_itxtp pChunk;
  517. #ifdef MNG_SUPPORT_TRACE
  518. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ITXT, MNG_LC_START);
  519. #endif
  520. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  521. pData = (mng_datap)hHandle; /* and make it addressable */
  522. pChunk = (mng_itxtp)hChunk; /* address the chunk */
  523. if (pChunk->sHeader.iChunkname != MNG_UINT_iTXt)
  524. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  525. /* fill the fields */
  526. *iKeywordsize = pChunk->iKeywordsize;
  527. *zKeyword = pChunk->zKeyword;
  528. *iCompressionflag = pChunk->iCompressionflag;
  529. *iCompressionmethod = pChunk->iCompressionmethod;
  530. *iLanguagesize = pChunk->iLanguagesize;
  531. *zLanguage = pChunk->zLanguage;
  532. *iTranslationsize = pChunk->iTranslationsize;
  533. *zTranslation = pChunk->zTranslation;
  534. *iTextsize = pChunk->iTextsize;
  535. *zText = pChunk->zText;
  536. #ifdef MNG_SUPPORT_TRACE
  537. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ITXT, MNG_LC_END);
  538. #endif
  539. return MNG_NOERROR;
  540. }
  541. #endif
  542. /* ************************************************************************** */
  543. #ifndef MNG_SKIPCHUNK_bKGD
  544. mng_retcode MNG_DECL mng_getchunk_bkgd (mng_handle hHandle,
  545. mng_handle hChunk,
  546. mng_bool *bEmpty,
  547. mng_uint8 *iType,
  548. mng_uint8 *iIndex,
  549. mng_uint16 *iGray,
  550. mng_uint16 *iRed,
  551. mng_uint16 *iGreen,
  552. mng_uint16 *iBlue)
  553. {
  554. mng_datap pData;
  555. mng_bkgdp pChunk;
  556. #ifdef MNG_SUPPORT_TRACE
  557. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BKGD, MNG_LC_START);
  558. #endif
  559. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  560. pData = (mng_datap)hHandle; /* and make it addressable */
  561. pChunk = (mng_bkgdp)hChunk; /* address the chunk */
  562. if (pChunk->sHeader.iChunkname != MNG_UINT_bKGD)
  563. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  564. *bEmpty = pChunk->bEmpty; /* fill the fields */
  565. *iType = pChunk->iType;
  566. *iIndex = pChunk->iIndex;
  567. *iGray = pChunk->iGray;
  568. *iRed = pChunk->iRed;
  569. *iGreen = pChunk->iGreen;
  570. *iBlue = pChunk->iBlue;
  571. #ifdef MNG_SUPPORT_TRACE
  572. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BKGD, MNG_LC_END);
  573. #endif
  574. return MNG_NOERROR;
  575. }
  576. #endif
  577. /* ************************************************************************** */
  578. #ifndef MNG_SKIPCHUNK_pHYs
  579. mng_retcode MNG_DECL mng_getchunk_phys (mng_handle hHandle,
  580. mng_handle hChunk,
  581. mng_bool *bEmpty,
  582. mng_uint32 *iSizex,
  583. mng_uint32 *iSizey,
  584. mng_uint8 *iUnit)
  585. {
  586. mng_datap pData;
  587. mng_physp pChunk;
  588. #ifdef MNG_SUPPORT_TRACE
  589. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PHYS, MNG_LC_START);
  590. #endif
  591. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  592. pData = (mng_datap)hHandle; /* and make it addressable */
  593. pChunk = (mng_physp)hChunk; /* address the chunk */
  594. if (pChunk->sHeader.iChunkname != MNG_UINT_pHYs)
  595. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  596. *bEmpty = pChunk->bEmpty; /* fill the fields */
  597. *iSizex = pChunk->iSizex;
  598. *iSizey = pChunk->iSizey;
  599. *iUnit = pChunk->iUnit;
  600. #ifdef MNG_SUPPORT_TRACE
  601. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PHYS, MNG_LC_END);
  602. #endif
  603. return MNG_NOERROR;
  604. }
  605. #endif
  606. /* ************************************************************************** */
  607. #ifndef MNG_SKIPCHUNK_sBIT
  608. mng_retcode MNG_DECL mng_getchunk_sbit (mng_handle hHandle,
  609. mng_handle hChunk,
  610. mng_bool *bEmpty,
  611. mng_uint8 *iType,
  612. mng_uint8arr4 *aBits)
  613. {
  614. mng_datap pData;
  615. mng_sbitp pChunk;
  616. #ifdef MNG_SUPPORT_TRACE
  617. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SBIT, MNG_LC_START);
  618. #endif
  619. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  620. pData = (mng_datap)hHandle; /* and make it addressable */
  621. pChunk = (mng_sbitp)hChunk; /* address the chunk */
  622. if (pChunk->sHeader.iChunkname != MNG_UINT_sBIT)
  623. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  624. *bEmpty = pChunk->bEmpty;
  625. *iType = pChunk->iType;
  626. (*aBits)[0] = pChunk->aBits[0];
  627. (*aBits)[1] = pChunk->aBits[1];
  628. (*aBits)[2] = pChunk->aBits[2];
  629. (*aBits)[3] = pChunk->aBits[3];
  630. #ifdef MNG_SUPPORT_TRACE
  631. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SBIT, MNG_LC_END);
  632. #endif
  633. return MNG_NOERROR;
  634. }
  635. #endif
  636. /* ************************************************************************** */
  637. #ifndef MNG_SKIPCHUNK_sPLT
  638. mng_retcode MNG_DECL mng_getchunk_splt (mng_handle hHandle,
  639. mng_handle hChunk,
  640. mng_bool *bEmpty,
  641. mng_uint32 *iNamesize,
  642. mng_pchar *zName,
  643. mng_uint8 *iSampledepth,
  644. mng_uint32 *iEntrycount,
  645. mng_ptr *pEntries)
  646. {
  647. mng_datap pData;
  648. mng_spltp pChunk;
  649. #ifdef MNG_SUPPORT_TRACE
  650. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SPLT, MNG_LC_START);
  651. #endif
  652. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  653. pData = (mng_datap)hHandle; /* and make it addressable */
  654. pChunk = (mng_spltp)hChunk; /* address the chunk */
  655. if (pChunk->sHeader.iChunkname != MNG_UINT_sPLT)
  656. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  657. *bEmpty = pChunk->bEmpty; /* fill the fields */
  658. *iNamesize = pChunk->iNamesize;
  659. *zName = pChunk->zName;
  660. *iSampledepth = pChunk->iSampledepth;
  661. *iEntrycount = pChunk->iEntrycount;
  662. *pEntries = pChunk->pEntries;
  663. #ifdef MNG_SUPPORT_TRACE
  664. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SPLT, MNG_LC_END);
  665. #endif
  666. return MNG_NOERROR;
  667. }
  668. #endif
  669. /* ************************************************************************** */
  670. #ifndef MNG_SKIPCHUNK_hIST
  671. mng_retcode MNG_DECL mng_getchunk_hist (mng_handle hHandle,
  672. mng_handle hChunk,
  673. mng_uint32 *iEntrycount,
  674. mng_uint16arr *aEntries)
  675. {
  676. mng_datap pData;
  677. mng_histp pChunk;
  678. #ifdef MNG_SUPPORT_TRACE
  679. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_HIST, MNG_LC_START);
  680. #endif
  681. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  682. pData = (mng_datap)hHandle; /* and make it addressable */
  683. pChunk = (mng_histp)hChunk; /* address the chunk */
  684. if (pChunk->sHeader.iChunkname != MNG_UINT_hIST)
  685. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  686. *iEntrycount = pChunk->iEntrycount; /* fill the fields */
  687. MNG_COPY (*aEntries, pChunk->aEntries, sizeof (mng_uint16arr));
  688. #ifdef MNG_SUPPORT_TRACE
  689. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_HIST, MNG_LC_END);
  690. #endif
  691. return MNG_NOERROR;
  692. }
  693. #endif
  694. /* ************************************************************************** */
  695. #ifndef MNG_SKIPCHUNK_tIME
  696. mng_retcode MNG_DECL mng_getchunk_time (mng_handle hHandle,
  697. mng_handle hChunk,
  698. mng_uint16 *iYear,
  699. mng_uint8 *iMonth,
  700. mng_uint8 *iDay,
  701. mng_uint8 *iHour,
  702. mng_uint8 *iMinute,
  703. mng_uint8 *iSecond)
  704. {
  705. mng_datap pData;
  706. mng_timep pChunk;
  707. #ifdef MNG_SUPPORT_TRACE
  708. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TIME, MNG_LC_START);
  709. #endif
  710. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  711. pData = (mng_datap)hHandle; /* and make it addressable */
  712. pChunk = (mng_timep)hChunk; /* address the chunk */
  713. if (pChunk->sHeader.iChunkname != MNG_UINT_tIME)
  714. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  715. *iYear = pChunk->iYear; /* fill the fields */
  716. *iMonth = pChunk->iMonth;
  717. *iDay = pChunk->iDay;
  718. *iHour = pChunk->iHour;
  719. *iMinute = pChunk->iMinute;
  720. *iSecond = pChunk->iSecond;
  721. #ifdef MNG_SUPPORT_TRACE
  722. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TIME, MNG_LC_END);
  723. #endif
  724. return MNG_NOERROR;
  725. }
  726. #endif
  727. /* ************************************************************************** */
  728. mng_retcode MNG_DECL mng_getchunk_mhdr (mng_handle hHandle,
  729. mng_handle hChunk,
  730. mng_uint32 *iWidth,
  731. mng_uint32 *iHeight,
  732. mng_uint32 *iTicks,
  733. mng_uint32 *iLayercount,
  734. mng_uint32 *iFramecount,
  735. mng_uint32 *iPlaytime,
  736. mng_uint32 *iSimplicity)
  737. {
  738. mng_datap pData;
  739. mng_mhdrp pChunk;
  740. #ifdef MNG_SUPPORT_TRACE
  741. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MHDR, MNG_LC_START);
  742. #endif
  743. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  744. pData = (mng_datap)hHandle; /* and make it addressable */
  745. pChunk = (mng_mhdrp)hChunk; /* address the chunk */
  746. if (pChunk->sHeader.iChunkname != MNG_UINT_MHDR)
  747. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  748. *iWidth = pChunk->iWidth; /* fill the fields */
  749. *iHeight = pChunk->iHeight;
  750. *iTicks = pChunk->iTicks;
  751. *iLayercount = pChunk->iLayercount;
  752. *iFramecount = pChunk->iFramecount;
  753. *iPlaytime = pChunk->iPlaytime;
  754. *iSimplicity = pChunk->iSimplicity;
  755. #ifdef MNG_SUPPORT_TRACE
  756. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MHDR, MNG_LC_END);
  757. #endif
  758. return MNG_NOERROR;
  759. }
  760. /* ************************************************************************** */
  761. #ifndef MNG_SKIPCHUNK_LOOP
  762. mng_retcode MNG_DECL mng_getchunk_loop (mng_handle hHandle,
  763. mng_handle hChunk,
  764. mng_uint8 *iLevel,
  765. mng_uint32 *iRepeat,
  766. mng_uint8 *iTermination,
  767. mng_uint32 *iItermin,
  768. mng_uint32 *iItermax,
  769. mng_uint32 *iCount,
  770. mng_uint32p *pSignals)
  771. {
  772. mng_datap pData;
  773. mng_loopp pChunk;
  774. #ifdef MNG_SUPPORT_TRACE
  775. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_LOOP, MNG_LC_START);
  776. #endif
  777. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  778. pData = (mng_datap)hHandle; /* and make it addressable */
  779. pChunk = (mng_loopp)hChunk; /* address the chunk */
  780. if (pChunk->sHeader.iChunkname != MNG_UINT_LOOP)
  781. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  782. *iLevel = pChunk->iLevel; /* fill teh fields */
  783. *iRepeat = pChunk->iRepeat;
  784. *iTermination = pChunk->iTermination;
  785. *iItermin = pChunk->iItermin;
  786. *iItermax = pChunk->iItermax;
  787. *iCount = pChunk->iCount;
  788. *pSignals = pChunk->pSignals;
  789. #ifdef MNG_SUPPORT_TRACE
  790. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_LOOP, MNG_LC_END);
  791. #endif
  792. return MNG_NOERROR;
  793. }
  794. /* ************************************************************************** */
  795. mng_retcode MNG_DECL mng_getchunk_endl (mng_handle hHandle,
  796. mng_handle hChunk,
  797. mng_uint8 *iLevel)
  798. {
  799. mng_datap pData;
  800. mng_endlp pChunk;
  801. #ifdef MNG_SUPPORT_TRACE
  802. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ENDL, MNG_LC_START);
  803. #endif
  804. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  805. pData = (mng_datap)hHandle; /* and make it addressable */
  806. pChunk = (mng_endlp)hChunk; /* address the chunk */
  807. if (pChunk->sHeader.iChunkname != MNG_UINT_ENDL)
  808. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  809. *iLevel = pChunk->iLevel; /* fill the field */
  810. #ifdef MNG_SUPPORT_TRACE
  811. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ENDL, MNG_LC_END);
  812. #endif
  813. return MNG_NOERROR;
  814. }
  815. #endif
  816. /* ************************************************************************** */
  817. #ifndef MNG_SKIPCHUNK_DEFI
  818. mng_retcode MNG_DECL mng_getchunk_defi (mng_handle hHandle,
  819. mng_handle hChunk,
  820. mng_uint16 *iObjectid,
  821. mng_uint8 *iDonotshow,
  822. mng_uint8 *iConcrete,
  823. mng_bool *bHasloca,
  824. mng_int32 *iXlocation,
  825. mng_int32 *iYlocation,
  826. mng_bool *bHasclip,
  827. mng_int32 *iLeftcb,
  828. mng_int32 *iRightcb,
  829. mng_int32 *iTopcb,
  830. mng_int32 *iBottomcb)
  831. {
  832. mng_datap pData;
  833. mng_defip pChunk;
  834. #ifdef MNG_SUPPORT_TRACE
  835. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DEFI, MNG_LC_START);
  836. #endif
  837. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  838. pData = (mng_datap)hHandle; /* and make it addressable */
  839. pChunk = (mng_defip)hChunk; /* address the chunk */
  840. if (pChunk->sHeader.iChunkname != MNG_UINT_DEFI)
  841. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  842. *iObjectid = pChunk->iObjectid; /* fill the fields */
  843. *iDonotshow = pChunk->iDonotshow;
  844. *iConcrete = pChunk->iConcrete;
  845. *bHasloca = pChunk->bHasloca;
  846. *iXlocation = pChunk->iXlocation;
  847. *iYlocation = pChunk->iYlocation;
  848. *bHasclip = pChunk->bHasclip;
  849. *iLeftcb = pChunk->iLeftcb;
  850. *iRightcb = pChunk->iRightcb;
  851. *iTopcb = pChunk->iTopcb;
  852. *iBottomcb = pChunk->iBottomcb;
  853. #ifdef MNG_SUPPORT_TRACE
  854. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DEFI, MNG_LC_END);
  855. #endif
  856. return MNG_NOERROR;
  857. }
  858. #endif
  859. /* ************************************************************************** */
  860. #ifndef MNG_SKIPCHUNK_BASI
  861. mng_retcode MNG_DECL mng_getchunk_basi (mng_handle hHandle,
  862. mng_handle hChunk,
  863. mng_uint32 *iWidth,
  864. mng_uint32 *iHeight,
  865. mng_uint8 *iBitdepth,
  866. mng_uint8 *iColortype,
  867. mng_uint8 *iCompression,
  868. mng_uint8 *iFilter,
  869. mng_uint8 *iInterlace,
  870. mng_uint16 *iRed,
  871. mng_uint16 *iGreen,
  872. mng_uint16 *iBlue,
  873. mng_uint16 *iAlpha,
  874. mng_uint8 *iViewable)
  875. {
  876. mng_datap pData;
  877. mng_basip pChunk;
  878. #ifdef MNG_SUPPORT_TRACE
  879. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BASI, MNG_LC_START);
  880. #endif
  881. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  882. pData = (mng_datap)hHandle; /* and make it addressable */
  883. pChunk = (mng_basip)hChunk; /* address the chunk */
  884. if (pChunk->sHeader.iChunkname != MNG_UINT_BASI)
  885. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  886. *iWidth = pChunk->iWidth; /* fill the fields */
  887. *iHeight = pChunk->iHeight;
  888. *iBitdepth = pChunk->iBitdepth;
  889. *iColortype = pChunk->iColortype;
  890. *iCompression = pChunk->iCompression;
  891. *iFilter = pChunk->iFilter;
  892. *iInterlace = pChunk->iInterlace;
  893. *iRed = pChunk->iRed;
  894. *iGreen = pChunk->iGreen;
  895. *iBlue = pChunk->iBlue;
  896. *iAlpha = pChunk->iAlpha;
  897. *iViewable = pChunk->iViewable;
  898. #ifdef MNG_SUPPORT_TRACE
  899. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BASI, MNG_LC_END);
  900. #endif
  901. return MNG_NOERROR;
  902. }
  903. #endif
  904. /* ************************************************************************** */
  905. #ifndef MNG_SKIPCHUNK_CLON
  906. mng_retcode MNG_DECL mng_getchunk_clon (mng_handle hHandle,
  907. mng_handle hChunk,
  908. mng_uint16 *iSourceid,
  909. mng_uint16 *iCloneid,
  910. mng_uint8 *iClonetype,
  911. mng_uint8 *iDonotshow,
  912. mng_uint8 *iConcrete,
  913. mng_bool *bHasloca,
  914. mng_uint8 *iLocationtype,
  915. mng_int32 *iLocationx,
  916. mng_int32 *iLocationy)
  917. {
  918. mng_datap pData;
  919. mng_clonp pChunk;
  920. #ifdef MNG_SUPPORT_TRACE
  921. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CLON, MNG_LC_START);
  922. #endif
  923. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  924. pData = (mng_datap)hHandle; /* and make it addressable */
  925. pChunk = (mng_clonp)hChunk; /* address the chunk */
  926. if (pChunk->sHeader.iChunkname != MNG_UINT_CLON)
  927. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  928. *iSourceid = pChunk->iSourceid; /* fill the fields */
  929. *iCloneid = pChunk->iCloneid;
  930. *iClonetype = pChunk->iClonetype;
  931. *iDonotshow = pChunk->iDonotshow;
  932. *iConcrete = pChunk->iConcrete;
  933. *bHasloca = pChunk->bHasloca;
  934. *iLocationtype = pChunk->iLocationtype;
  935. *iLocationx = pChunk->iLocationx;
  936. *iLocationy = pChunk->iLocationy;
  937. #ifdef MNG_SUPPORT_TRACE
  938. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CLON, MNG_LC_END);
  939. #endif
  940. return MNG_NOERROR;
  941. }
  942. #endif
  943. /* ************************************************************************** */
  944. #ifndef MNG_SKIPCHUNK_PAST
  945. mng_retcode MNG_DECL mng_getchunk_past (mng_handle hHandle,
  946. mng_handle hChunk,
  947. mng_uint16 *iDestid,
  948. mng_uint8 *iTargettype,
  949. mng_int32 *iTargetx,
  950. mng_int32 *iTargety,
  951. mng_uint32 *iCount)
  952. {
  953. mng_datap pData;
  954. mng_pastp pChunk;
  955. #ifdef MNG_SUPPORT_TRACE
  956. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PAST, MNG_LC_START);
  957. #endif
  958. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  959. pData = (mng_datap)hHandle; /* and make it addressable */
  960. pChunk = (mng_pastp)hChunk; /* address the chunk */
  961. if (pChunk->sHeader.iChunkname != MNG_UINT_PAST)
  962. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  963. *iDestid = pChunk->iDestid; /* fill the fields */
  964. *iTargettype = pChunk->iTargettype;
  965. *iTargetx = pChunk->iTargetx;
  966. *iTargety = pChunk->iTargety;
  967. *iCount = pChunk->iCount;
  968. #ifdef MNG_SUPPORT_TRACE
  969. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PAST, MNG_LC_END);
  970. #endif
  971. return MNG_NOERROR;
  972. }
  973. #endif
  974. /* ************************************************************************** */
  975. #ifndef MNG_SKIPCHUNK_PAST
  976. mng_retcode MNG_DECL mng_getchunk_past_src (mng_handle hHandle,
  977. mng_handle hChunk,
  978. mng_uint32 iEntry,
  979. mng_uint16 *iSourceid,
  980. mng_uint8 *iComposition,
  981. mng_uint8 *iOrientation,
  982. mng_uint8 *iOffsettype,
  983. mng_int32 *iOffsetx,
  984. mng_int32 *iOffsety,
  985. mng_uint8 *iBoundarytype,
  986. mng_int32 *iBoundaryl,
  987. mng_int32 *iBoundaryr,
  988. mng_int32 *iBoundaryt,
  989. mng_int32 *iBoundaryb)
  990. {
  991. mng_datap pData;
  992. mng_pastp pChunk;
  993. mng_past_sourcep pEntry;
  994. #ifdef MNG_SUPPORT_TRACE
  995. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PAST_SRC, MNG_LC_START);
  996. #endif
  997. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  998. pData = (mng_datap)hHandle; /* and make it addressable */
  999. pChunk = (mng_pastp)hChunk; /* address the chunk */
  1000. if (pChunk->sHeader.iChunkname != MNG_UINT_PAST)
  1001. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1002. if (iEntry >= pChunk->iCount) /* valid index ? */
  1003. MNG_ERROR (pData, MNG_INVALIDENTRYIX)
  1004. /* address the entry */
  1005. pEntry = pChunk->pSources + iEntry;
  1006. *iSourceid = pEntry->iSourceid; /* fill the fields */
  1007. *iComposition = pEntry->iComposition;
  1008. *iOrientation = pEntry->iOrientation;
  1009. *iOffsettype = pEntry->iOffsettype;
  1010. *iOffsetx = pEntry->iOffsetx;
  1011. *iOffsety = pEntry->iOffsety;
  1012. *iBoundarytype = pEntry->iBoundarytype;
  1013. *iBoundaryl = pEntry->iBoundaryl;
  1014. *iBoundaryr = pEntry->iBoundaryr;
  1015. *iBoundaryt = pEntry->iBoundaryt;
  1016. *iBoundaryb = pEntry->iBoundaryb;
  1017. #ifdef MNG_SUPPORT_TRACE
  1018. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PAST_SRC, MNG_LC_END);
  1019. #endif
  1020. return MNG_NOERROR;
  1021. }
  1022. #endif
  1023. /* ************************************************************************** */
  1024. #ifndef MNG_SKIPCHUNK_DISC
  1025. mng_retcode MNG_DECL mng_getchunk_disc (mng_handle hHandle,
  1026. mng_handle hChunk,
  1027. mng_uint32 *iCount,
  1028. mng_uint16p *pObjectids)
  1029. {
  1030. mng_datap pData;
  1031. mng_discp pChunk;
  1032. #ifdef MNG_SUPPORT_TRACE
  1033. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DISC, MNG_LC_START);
  1034. #endif
  1035. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1036. pData = (mng_datap)hHandle; /* and make it addressable */
  1037. pChunk = (mng_discp)hChunk; /* address the chunk */
  1038. if (pChunk->sHeader.iChunkname != MNG_UINT_DISC)
  1039. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1040. *iCount = pChunk->iCount; /* fill the fields */
  1041. *pObjectids = pChunk->pObjectids;
  1042. #ifdef MNG_SUPPORT_TRACE
  1043. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DISC, MNG_LC_END);
  1044. #endif
  1045. return MNG_NOERROR;
  1046. }
  1047. #endif
  1048. /* ************************************************************************** */
  1049. #ifndef MNG_SKIPCHUNK_BACK
  1050. mng_retcode MNG_DECL mng_getchunk_back (mng_handle hHandle,
  1051. mng_handle hChunk,
  1052. mng_uint16 *iRed,
  1053. mng_uint16 *iGreen,
  1054. mng_uint16 *iBlue,
  1055. mng_uint8 *iMandatory,
  1056. mng_uint16 *iImageid,
  1057. mng_uint8 *iTile)
  1058. {
  1059. mng_datap pData;
  1060. mng_backp pChunk;
  1061. #ifdef MNG_SUPPORT_TRACE
  1062. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BACK, MNG_LC_START);
  1063. #endif
  1064. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1065. pData = (mng_datap)hHandle; /* and make it addressable */
  1066. pChunk = (mng_backp)hChunk; /* address the chunk */
  1067. if (pChunk->sHeader.iChunkname != MNG_UINT_BACK)
  1068. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1069. *iRed = pChunk->iRed; /* fill the fields */
  1070. *iGreen = pChunk->iGreen;
  1071. *iBlue = pChunk->iBlue;
  1072. *iMandatory = pChunk->iMandatory;
  1073. *iImageid = pChunk->iImageid;
  1074. *iTile = pChunk->iTile;
  1075. #ifdef MNG_SUPPORT_TRACE
  1076. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BACK, MNG_LC_END);
  1077. #endif
  1078. return MNG_NOERROR;
  1079. }
  1080. #endif
  1081. /* ************************************************************************** */
  1082. #ifndef MNG_SKIPCHUNK_FRAM
  1083. mng_retcode MNG_DECL mng_getchunk_fram (mng_handle hHandle,
  1084. mng_handle hChunk,
  1085. mng_bool *bEmpty,
  1086. mng_uint8 *iMode,
  1087. mng_uint32 *iNamesize,
  1088. mng_pchar *zName,
  1089. mng_uint8 *iChangedelay,
  1090. mng_uint8 *iChangetimeout,
  1091. mng_uint8 *iChangeclipping,
  1092. mng_uint8 *iChangesyncid,
  1093. mng_uint32 *iDelay,
  1094. mng_uint32 *iTimeout,
  1095. mng_uint8 *iBoundarytype,
  1096. mng_int32 *iBoundaryl,
  1097. mng_int32 *iBoundaryr,
  1098. mng_int32 *iBoundaryt,
  1099. mng_int32 *iBoundaryb,
  1100. mng_uint32 *iCount,
  1101. mng_uint32p *pSyncids)
  1102. {
  1103. mng_datap pData;
  1104. mng_framp pChunk;
  1105. #ifdef MNG_SUPPORT_TRACE
  1106. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_FRAM, MNG_LC_START);
  1107. #endif
  1108. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1109. pData = (mng_datap)hHandle; /* and make it addressable */
  1110. pChunk = (mng_framp)hChunk; /* address the chunk */
  1111. if (pChunk->sHeader.iChunkname != MNG_UINT_FRAM)
  1112. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1113. *bEmpty = pChunk->bEmpty; /* fill the fields */
  1114. *iMode = pChunk->iMode;
  1115. *iNamesize = pChunk->iNamesize;
  1116. *zName = pChunk->zName;
  1117. *iChangedelay = pChunk->iChangedelay;
  1118. *iChangetimeout = pChunk->iChangetimeout;
  1119. *iChangeclipping = pChunk->iChangeclipping;
  1120. *iChangesyncid = pChunk->iChangesyncid;
  1121. *iDelay = pChunk->iDelay;
  1122. *iTimeout = pChunk->iTimeout;
  1123. *iBoundarytype = pChunk->iBoundarytype;
  1124. *iBoundaryl = pChunk->iBoundaryl;
  1125. *iBoundaryr = pChunk->iBoundaryr;
  1126. *iBoundaryt = pChunk->iBoundaryt;
  1127. *iBoundaryb = pChunk->iBoundaryb;
  1128. *iCount = pChunk->iCount;
  1129. *pSyncids = pChunk->pSyncids;
  1130. #ifdef MNG_SUPPORT_TRACE
  1131. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_FRAM, MNG_LC_END);
  1132. #endif
  1133. return MNG_NOERROR;
  1134. }
  1135. #endif
  1136. /* ************************************************************************** */
  1137. #ifndef MNG_SKIPCHUNK_MOVE
  1138. mng_retcode MNG_DECL mng_getchunk_move (mng_handle hHandle,
  1139. mng_handle hChunk,
  1140. mng_uint16 *iFirstid,
  1141. mng_uint16 *iLastid,
  1142. mng_uint8 *iMovetype,
  1143. mng_int32 *iMovex,
  1144. mng_int32 *iMovey)
  1145. {
  1146. mng_datap pData;
  1147. mng_movep pChunk;
  1148. #ifdef MNG_SUPPORT_TRACE
  1149. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MOVE, MNG_LC_START);
  1150. #endif
  1151. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1152. pData = (mng_datap)hHandle; /* and make it addressable */
  1153. pChunk = (mng_movep)hChunk; /* address the chunk */
  1154. if (pChunk->sHeader.iChunkname != MNG_UINT_MOVE)
  1155. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1156. *iFirstid = pChunk->iFirstid; /* fill the fields */
  1157. *iLastid = pChunk->iLastid;
  1158. *iMovetype = pChunk->iMovetype;
  1159. *iMovex = pChunk->iMovex;
  1160. *iMovey = pChunk->iMovey;
  1161. #ifdef MNG_SUPPORT_TRACE
  1162. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MOVE, MNG_LC_END);
  1163. #endif
  1164. return MNG_NOERROR;
  1165. }
  1166. #endif
  1167. /* ************************************************************************** */
  1168. #ifndef MNG_SKIPCHUNK_CLIP
  1169. mng_retcode MNG_DECL mng_getchunk_clip (mng_handle hHandle,
  1170. mng_handle hChunk,
  1171. mng_uint16 *iFirstid,
  1172. mng_uint16 *iLastid,
  1173. mng_uint8 *iCliptype,
  1174. mng_int32 *iClipl,
  1175. mng_int32 *iClipr,
  1176. mng_int32 *iClipt,
  1177. mng_int32 *iClipb)
  1178. {
  1179. mng_datap pData;
  1180. mng_clipp pChunk;
  1181. #ifdef MNG_SUPPORT_TRACE
  1182. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CLIP, MNG_LC_START);
  1183. #endif
  1184. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1185. pData = (mng_datap)hHandle; /* and make it addressable */
  1186. pChunk = (mng_clipp)hChunk; /* address the chunk */
  1187. if (pChunk->sHeader.iChunkname != MNG_UINT_CLIP)
  1188. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1189. *iFirstid = pChunk->iFirstid; /* fill the fields */
  1190. *iLastid = pChunk->iLastid;
  1191. *iCliptype = pChunk->iCliptype;
  1192. *iClipl = pChunk->iClipl;
  1193. *iClipr = pChunk->iClipr;
  1194. *iClipt = pChunk->iClipt;
  1195. *iClipb = pChunk->iClipb;
  1196. #ifdef MNG_SUPPORT_TRACE
  1197. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CLIP, MNG_LC_END);
  1198. #endif
  1199. return MNG_NOERROR;
  1200. }
  1201. #endif
  1202. /* ************************************************************************** */
  1203. #ifndef MNG_SKIPCHUNK_SHOW
  1204. mng_retcode MNG_DECL mng_getchunk_show (mng_handle hHandle,
  1205. mng_handle hChunk,
  1206. mng_bool *bEmpty,
  1207. mng_uint16 *iFirstid,
  1208. mng_uint16 *iLastid,
  1209. mng_uint8 *iMode)
  1210. {
  1211. mng_datap pData;
  1212. mng_showp pChunk;
  1213. #ifdef MNG_SUPPORT_TRACE
  1214. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SHOW, MNG_LC_START);
  1215. #endif
  1216. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1217. pData = (mng_datap)hHandle; /* and make it addressable */
  1218. pChunk = (mng_showp)hChunk; /* address the chunk */
  1219. if (pChunk->sHeader.iChunkname != MNG_UINT_SHOW)
  1220. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1221. *bEmpty = pChunk->bEmpty; /* fill the fields */
  1222. *iFirstid = pChunk->iFirstid;
  1223. *iLastid = pChunk->iLastid;
  1224. *iMode = pChunk->iMode;
  1225. #ifdef MNG_SUPPORT_TRACE
  1226. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SHOW, MNG_LC_END);
  1227. #endif
  1228. return MNG_NOERROR;
  1229. }
  1230. #endif
  1231. /* ************************************************************************** */
  1232. #ifndef MNG_SKIPCHUNK_TERM
  1233. mng_retcode MNG_DECL mng_getchunk_term (mng_handle hHandle,
  1234. mng_handle hChunk,
  1235. mng_uint8 *iTermaction,
  1236. mng_uint8 *iIteraction,
  1237. mng_uint32 *iDelay,
  1238. mng_uint32 *iItermax)
  1239. {
  1240. mng_datap pData;
  1241. mng_termp pChunk;
  1242. #ifdef MNG_SUPPORT_TRACE
  1243. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TERM, MNG_LC_START);
  1244. #endif
  1245. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1246. pData = (mng_datap)hHandle; /* and make it addressable */
  1247. pChunk = (mng_termp)hChunk; /* address the chunk */
  1248. if (pChunk->sHeader.iChunkname != MNG_UINT_TERM)
  1249. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1250. *iTermaction = pChunk->iTermaction; /* fill the fields */
  1251. *iIteraction = pChunk->iIteraction;
  1252. *iDelay = pChunk->iDelay;
  1253. *iItermax = pChunk->iItermax;
  1254. #ifdef MNG_SUPPORT_TRACE
  1255. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TERM, MNG_LC_END);
  1256. #endif
  1257. return MNG_NOERROR;
  1258. }
  1259. #endif
  1260. /* ************************************************************************** */
  1261. #ifndef MNG_SKIPCHUNK_SAVE
  1262. mng_retcode MNG_DECL mng_getchunk_save (mng_handle hHandle,
  1263. mng_handle hChunk,
  1264. mng_bool *bEmpty,
  1265. mng_uint8 *iOffsettype,
  1266. mng_uint32 *iCount)
  1267. {
  1268. mng_datap pData;
  1269. mng_savep pChunk;
  1270. #ifdef MNG_SUPPORT_TRACE
  1271. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SAVE, MNG_LC_START);
  1272. #endif
  1273. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1274. pData = (mng_datap)hHandle; /* and make it addressable */
  1275. pChunk = (mng_savep)hChunk; /* address the chunk */
  1276. if (pChunk->sHeader.iChunkname != MNG_UINT_SAVE)
  1277. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1278. *bEmpty = pChunk->bEmpty; /* fill the fields */
  1279. *iOffsettype = pChunk->iOffsettype;
  1280. *iCount = pChunk->iCount;
  1281. #ifdef MNG_SUPPORT_TRACE
  1282. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SAVE, MNG_LC_END);
  1283. #endif
  1284. return MNG_NOERROR;
  1285. }
  1286. /* ************************************************************************** */
  1287. mng_retcode MNG_DECL mng_getchunk_save_entry (mng_handle hHandle,
  1288. mng_handle hChunk,
  1289. mng_uint32 iEntry,
  1290. mng_uint8 *iEntrytype,
  1291. mng_uint32arr2 *iOffset,
  1292. mng_uint32arr2 *iStarttime,
  1293. mng_uint32 *iLayernr,
  1294. mng_uint32 *iFramenr,
  1295. mng_uint32 *iNamesize,
  1296. mng_pchar *zName)
  1297. {
  1298. mng_datap pData;
  1299. mng_savep pChunk;
  1300. mng_save_entryp pEntry;
  1301. #ifdef MNG_SUPPORT_TRACE
  1302. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SAVE_ENTRY, MNG_LC_START);
  1303. #endif
  1304. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1305. pData = (mng_datap)hHandle; /* and make it addressable */
  1306. pChunk = (mng_savep)hChunk; /* address the chunk */
  1307. if (pChunk->sHeader.iChunkname != MNG_UINT_SAVE)
  1308. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1309. if (iEntry >= pChunk->iCount) /* valid index ? */
  1310. MNG_ERROR (pData, MNG_INVALIDENTRYIX)
  1311. pEntry = pChunk->pEntries + iEntry; /* address the entry */
  1312. /* fill the fields */
  1313. *iEntrytype = pEntry->iEntrytype;
  1314. (*iOffset)[0] = pEntry->iOffset[0];
  1315. (*iOffset)[1] = pEntry->iOffset[1];
  1316. (*iStarttime)[0] = pEntry->iStarttime[0];
  1317. (*iStarttime)[1] = pEntry->iStarttime[1];
  1318. *iLayernr = pEntry->iLayernr;
  1319. *iFramenr = pEntry->iFramenr;
  1320. *iNamesize = pEntry->iNamesize;
  1321. *zName = pEntry->zName;
  1322. #ifdef MNG_SUPPORT_TRACE
  1323. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SAVE_ENTRY, MNG_LC_END);
  1324. #endif
  1325. return MNG_NOERROR;
  1326. }
  1327. #endif
  1328. /* ************************************************************************** */
  1329. #ifndef MNG_SKIPCHUNK_SEEK
  1330. mng_retcode MNG_DECL mng_getchunk_seek (mng_handle hHandle,
  1331. mng_handle hChunk,
  1332. mng_uint32 *iNamesize,
  1333. mng_pchar *zName)
  1334. {
  1335. mng_datap pData;
  1336. mng_seekp pChunk;
  1337. #ifdef MNG_SUPPORT_TRACE
  1338. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SEEK, MNG_LC_START);
  1339. #endif
  1340. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1341. pData = (mng_datap)hHandle; /* and make it addressable */
  1342. pChunk = (mng_seekp)hChunk; /* address the chunk */
  1343. if (pChunk->sHeader.iChunkname != MNG_UINT_SEEK)
  1344. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1345. *iNamesize = pChunk->iNamesize; /* fill the fields */
  1346. *zName = pChunk->zName;
  1347. #ifdef MNG_SUPPORT_TRACE
  1348. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SEEK, MNG_LC_END);
  1349. #endif
  1350. return MNG_NOERROR;
  1351. }
  1352. #endif
  1353. /* ************************************************************************** */
  1354. #ifndef MNG_SKIPCHUNK_eXPI
  1355. mng_retcode MNG_DECL mng_getchunk_expi (mng_handle hHandle,
  1356. mng_handle hChunk,
  1357. mng_uint16 *iSnapshotid,
  1358. mng_uint32 *iNamesize,
  1359. mng_pchar *zName)
  1360. {
  1361. mng_datap pData;
  1362. mng_expip pChunk;
  1363. #ifdef MNG_SUPPORT_TRACE
  1364. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_EXPI, MNG_LC_START);
  1365. #endif
  1366. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1367. pData = (mng_datap)hHandle; /* and make it addressable */
  1368. pChunk = (mng_expip)hChunk; /* address the chunk */
  1369. if (pChunk->sHeader.iChunkname != MNG_UINT_eXPI)
  1370. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1371. *iSnapshotid = pChunk->iSnapshotid; /* fill the fields */
  1372. *iNamesize = pChunk->iNamesize;
  1373. *zName = pChunk->zName;
  1374. #ifdef MNG_SUPPORT_TRACE
  1375. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_EXPI, MNG_LC_END);
  1376. #endif
  1377. return MNG_NOERROR;
  1378. }
  1379. #endif
  1380. /* ************************************************************************** */
  1381. #ifndef MNG_SKIPCHUNK_fPRI
  1382. mng_retcode MNG_DECL mng_getchunk_fpri (mng_handle hHandle,
  1383. mng_handle hChunk,
  1384. mng_uint8 *iDeltatype,
  1385. mng_uint8 *iPriority)
  1386. {
  1387. mng_datap pData;
  1388. mng_fprip pChunk;
  1389. #ifdef MNG_SUPPORT_TRACE
  1390. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_FPRI, MNG_LC_START);
  1391. #endif
  1392. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1393. pData = (mng_datap)hHandle; /* and make it addressable */
  1394. pChunk = (mng_fprip)hChunk; /* address the chunk */
  1395. if (pChunk->sHeader.iChunkname != MNG_UINT_fPRI)
  1396. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1397. *iDeltatype = pChunk->iDeltatype; /* fill the fields */
  1398. *iPriority = pChunk->iPriority;
  1399. #ifdef MNG_SUPPORT_TRACE
  1400. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_FPRI, MNG_LC_END);
  1401. #endif
  1402. return MNG_NOERROR;
  1403. }
  1404. #endif
  1405. /* ************************************************************************** */
  1406. #ifndef MNG_SKIPCHUNK_nEED
  1407. mng_retcode MNG_DECL mng_getchunk_need (mng_handle hHandle,
  1408. mng_handle hChunk,
  1409. mng_uint32 *iKeywordssize,
  1410. mng_pchar *zKeywords)
  1411. {
  1412. mng_datap pData;
  1413. mng_needp pChunk;
  1414. #ifdef MNG_SUPPORT_TRACE
  1415. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_NEED, MNG_LC_START);
  1416. #endif
  1417. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1418. pData = (mng_datap)hHandle; /* and make it addressable */
  1419. pChunk = (mng_needp)hChunk; /* address the chunk */
  1420. if (pChunk->sHeader.iChunkname != MNG_UINT_nEED)
  1421. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1422. /* fill the fields */
  1423. *iKeywordssize = pChunk->iKeywordssize;
  1424. *zKeywords = pChunk->zKeywords;
  1425. #ifdef MNG_SUPPORT_TRACE
  1426. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_NEED, MNG_LC_END);
  1427. #endif
  1428. return MNG_NOERROR;
  1429. }
  1430. #endif
  1431. /* ************************************************************************** */
  1432. #ifndef MNG_SKIPCHUNK_pHYg
  1433. mng_retcode MNG_DECL mng_getchunk_phyg (mng_handle hHandle,
  1434. mng_handle hChunk,
  1435. mng_bool *bEmpty,
  1436. mng_uint32 *iSizex,
  1437. mng_uint32 *iSizey,
  1438. mng_uint8 *iUnit)
  1439. {
  1440. mng_datap pData;
  1441. mng_phygp pChunk;
  1442. #ifdef MNG_SUPPORT_TRACE
  1443. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PHYG, MNG_LC_START);
  1444. #endif
  1445. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1446. pData = (mng_datap)hHandle; /* and make it addressable */
  1447. pChunk = (mng_phygp)hChunk; /* address the chunk */
  1448. if (pChunk->sHeader.iChunkname != MNG_UINT_pHYg)
  1449. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1450. *bEmpty = pChunk->bEmpty; /* fill the fields */
  1451. *iSizex = pChunk->iSizex;
  1452. *iSizey = pChunk->iSizey;
  1453. *iUnit = pChunk->iUnit;
  1454. #ifdef MNG_SUPPORT_TRACE
  1455. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PHYG, MNG_LC_END);
  1456. #endif
  1457. return MNG_NOERROR;
  1458. }
  1459. #endif
  1460. /* ************************************************************************** */
  1461. #ifdef MNG_INCLUDE_JNG
  1462. mng_retcode MNG_DECL mng_getchunk_jhdr (mng_handle hHandle,
  1463. mng_handle hChunk,
  1464. mng_uint32 *iWidth,
  1465. mng_uint32 *iHeight,
  1466. mng_uint8 *iColortype,
  1467. mng_uint8 *iImagesampledepth,
  1468. mng_uint8 *iImagecompression,
  1469. mng_uint8 *iImageinterlace,
  1470. mng_uint8 *iAlphasampledepth,
  1471. mng_uint8 *iAlphacompression,
  1472. mng_uint8 *iAlphafilter,
  1473. mng_uint8 *iAlphainterlace)
  1474. {
  1475. mng_datap pData;
  1476. mng_jhdrp pChunk;
  1477. #ifdef MNG_SUPPORT_TRACE
  1478. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JHDR, MNG_LC_START);
  1479. #endif
  1480. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1481. pData = (mng_datap)hHandle; /* and make it addressable */
  1482. pChunk = (mng_jhdrp)hChunk; /* address the chunk */
  1483. if (pChunk->sHeader.iChunkname != MNG_UINT_JHDR)
  1484. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1485. *iWidth = pChunk->iWidth; /* fill the fields */
  1486. *iHeight = pChunk->iHeight;
  1487. *iColortype = pChunk->iColortype;
  1488. *iImagesampledepth = pChunk->iImagesampledepth;
  1489. *iImagecompression = pChunk->iImagecompression;
  1490. *iImageinterlace = pChunk->iImageinterlace;
  1491. *iAlphasampledepth = pChunk->iAlphasampledepth;
  1492. *iAlphacompression = pChunk->iAlphacompression;
  1493. *iAlphafilter = pChunk->iAlphafilter;
  1494. *iAlphainterlace = pChunk->iAlphainterlace;
  1495. #ifdef MNG_SUPPORT_TRACE
  1496. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JHDR, MNG_LC_END);
  1497. #endif
  1498. return MNG_NOERROR;
  1499. }
  1500. #endif /* MNG_INCLUDE_JNG */
  1501. /* ************************************************************************** */
  1502. #ifdef MNG_INCLUDE_JNG
  1503. mng_retcode MNG_DECL mng_getchunk_jdat (mng_handle hHandle,
  1504. mng_handle hChunk,
  1505. mng_uint32 *iRawlen,
  1506. mng_ptr *pRawdata)
  1507. {
  1508. mng_datap pData;
  1509. mng_jdatp pChunk;
  1510. #ifdef MNG_SUPPORT_TRACE
  1511. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JDAT, MNG_LC_START);
  1512. #endif
  1513. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1514. pData = (mng_datap)hHandle; /* and make it addressable */
  1515. pChunk = (mng_jdatp)hChunk; /* address the chunk */
  1516. if (pChunk->sHeader.iChunkname != MNG_UINT_JDAT)
  1517. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1518. *iRawlen = pChunk->iDatasize; /* fill the fields */
  1519. *pRawdata = pChunk->pData;
  1520. #ifdef MNG_SUPPORT_TRACE
  1521. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JDAT, MNG_LC_END);
  1522. #endif
  1523. return MNG_NOERROR;
  1524. }
  1525. #endif /* MNG_INCLUDE_JNG */
  1526. /* ************************************************************************** */
  1527. #ifdef MNG_INCLUDE_JNG
  1528. mng_retcode MNG_DECL mng_getchunk_jdaa (mng_handle hHandle,
  1529. mng_handle hChunk,
  1530. mng_uint32 *iRawlen,
  1531. mng_ptr *pRawdata)
  1532. {
  1533. mng_datap pData;
  1534. mng_jdaap pChunk;
  1535. #ifdef MNG_SUPPORT_TRACE
  1536. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JDAA, MNG_LC_START);
  1537. #endif
  1538. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1539. pData = (mng_datap)hHandle; /* and make it addressable */
  1540. pChunk = (mng_jdaap)hChunk; /* address the chunk */
  1541. if (pChunk->sHeader.iChunkname != MNG_UINT_JDAA)
  1542. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1543. *iRawlen = pChunk->iDatasize; /* fill the fields */
  1544. *pRawdata = pChunk->pData;
  1545. #ifdef MNG_SUPPORT_TRACE
  1546. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JDAA, MNG_LC_END);
  1547. #endif
  1548. return MNG_NOERROR;
  1549. }
  1550. #endif /* MNG_INCLUDE_JNG */
  1551. /* ************************************************************************** */
  1552. #ifndef MNG_NO_DELTA_PNG
  1553. mng_retcode MNG_DECL mng_getchunk_dhdr (mng_handle hHandle,
  1554. mng_handle hChunk,
  1555. mng_uint16 *iObjectid,
  1556. mng_uint8 *iImagetype,
  1557. mng_uint8 *iDeltatype,
  1558. mng_uint32 *iBlockwidth,
  1559. mng_uint32 *iBlockheight,
  1560. mng_uint32 *iBlockx,
  1561. mng_uint32 *iBlocky)
  1562. {
  1563. mng_datap pData;
  1564. mng_dhdrp pChunk;
  1565. #ifdef MNG_SUPPORT_TRACE
  1566. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DHDR, MNG_LC_START);
  1567. #endif
  1568. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1569. pData = (mng_datap)hHandle; /* and make it addressable */
  1570. pChunk = (mng_dhdrp)hChunk; /* address the chunk */
  1571. if (pChunk->sHeader.iChunkname != MNG_UINT_DHDR)
  1572. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1573. *iObjectid = pChunk->iObjectid; /* fill the fields */
  1574. *iImagetype = pChunk->iImagetype;
  1575. *iDeltatype = pChunk->iDeltatype;
  1576. *iBlockwidth = pChunk->iBlockwidth;
  1577. *iBlockheight = pChunk->iBlockheight;
  1578. *iBlockx = pChunk->iBlockx;
  1579. *iBlocky = pChunk->iBlocky;
  1580. #ifdef MNG_SUPPORT_TRACE
  1581. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DHDR, MNG_LC_END);
  1582. #endif
  1583. return MNG_NOERROR;
  1584. }
  1585. #endif
  1586. /* ************************************************************************** */
  1587. #ifndef MNG_NO_DELTA_PNG
  1588. mng_retcode MNG_DECL mng_getchunk_prom (mng_handle hHandle,
  1589. mng_handle hChunk,
  1590. mng_uint8 *iColortype,
  1591. mng_uint8 *iSampledepth,
  1592. mng_uint8 *iFilltype)
  1593. {
  1594. mng_datap pData;
  1595. mng_promp pChunk;
  1596. #ifdef MNG_SUPPORT_TRACE
  1597. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PROM, MNG_LC_START);
  1598. #endif
  1599. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1600. pData = (mng_datap)hHandle; /* and make it addressable */
  1601. pChunk = (mng_promp)hChunk; /* address the chunk */
  1602. if (pChunk->sHeader.iChunkname != MNG_UINT_PROM)
  1603. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1604. *iColortype = pChunk->iColortype; /* fill the fields */
  1605. *iSampledepth = pChunk->iSampledepth;
  1606. *iFilltype = pChunk->iFilltype;
  1607. #ifdef MNG_SUPPORT_TRACE
  1608. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PROM, MNG_LC_END);
  1609. #endif
  1610. return MNG_NOERROR;
  1611. }
  1612. #endif
  1613. /* ************************************************************************** */
  1614. #ifndef MNG_NO_DELTA_PNG
  1615. mng_retcode MNG_DECL mng_getchunk_pplt (mng_handle hHandle,
  1616. mng_handle hChunk,
  1617. mng_uint8 *iDeltatype,
  1618. mng_uint32 *iCount)
  1619. {
  1620. mng_datap pData;
  1621. mng_ppltp pChunk;
  1622. #ifdef MNG_SUPPORT_TRACE
  1623. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PPLT, MNG_LC_START);
  1624. #endif
  1625. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1626. pData = (mng_datap)hHandle; /* and make it addressable */
  1627. pChunk = (mng_ppltp)hChunk; /* address the chunk */
  1628. if (pChunk->sHeader.iChunkname != MNG_UINT_PPLT)
  1629. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1630. *iDeltatype = pChunk->iDeltatype; /* fill the fields */
  1631. *iCount = pChunk->iCount;
  1632. #ifdef MNG_SUPPORT_TRACE
  1633. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PPLT, MNG_LC_END);
  1634. #endif
  1635. return MNG_NOERROR;
  1636. }
  1637. #endif
  1638. /* ************************************************************************** */
  1639. #ifndef MNG_NO_DELTA_PNG
  1640. mng_retcode MNG_DECL mng_getchunk_pplt_entry (mng_handle hHandle,
  1641. mng_handle hChunk,
  1642. mng_uint32 iEntry,
  1643. mng_uint16 *iRed,
  1644. mng_uint16 *iGreen,
  1645. mng_uint16 *iBlue,
  1646. mng_uint16 *iAlpha,
  1647. mng_bool *bUsed)
  1648. {
  1649. mng_datap pData;
  1650. mng_ppltp pChunk;
  1651. mng_pplt_entryp pEntry;
  1652. #ifdef MNG_SUPPORT_TRACE
  1653. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PPLT_ENTRY, MNG_LC_START);
  1654. #endif
  1655. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1656. pData = (mng_datap)hHandle; /* and make it addressable */
  1657. pChunk = (mng_ppltp)hChunk; /* address the chunk */
  1658. if (pChunk->sHeader.iChunkname != MNG_UINT_PPLT)
  1659. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1660. if (iEntry >= pChunk->iCount) /* valid index ? */
  1661. MNG_ERROR (pData, MNG_INVALIDENTRYIX)
  1662. pEntry = &pChunk->aEntries[iEntry]; /* address the entry */
  1663. *iRed = pEntry->iRed; /* fill the fields */
  1664. *iGreen = pEntry->iGreen;
  1665. *iBlue = pEntry->iBlue;
  1666. *iAlpha = pEntry->iAlpha;
  1667. *bUsed = pEntry->bUsed;
  1668. #ifdef MNG_SUPPORT_TRACE
  1669. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PPLT_ENTRY, MNG_LC_END);
  1670. #endif
  1671. return MNG_NOERROR;
  1672. }
  1673. #endif
  1674. /* ************************************************************************** */
  1675. #ifndef MNG_NO_DELTA_PNG
  1676. mng_retcode MNG_DECL mng_getchunk_drop (mng_handle hHandle,
  1677. mng_handle hChunk,
  1678. mng_uint32 *iCount,
  1679. mng_chunkidp *pChunknames)
  1680. {
  1681. mng_datap pData;
  1682. mng_dropp pChunk;
  1683. #ifdef MNG_SUPPORT_TRACE
  1684. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DROP, MNG_LC_START);
  1685. #endif
  1686. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1687. pData = (mng_datap)hHandle; /* and make it addressable */
  1688. pChunk = (mng_dropp)hChunk; /* address the chunk */
  1689. if (pChunk->sHeader.iChunkname != MNG_UINT_DROP)
  1690. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1691. *iCount = pChunk->iCount; /* fill the fields */
  1692. *pChunknames = pChunk->pChunknames;
  1693. #ifdef MNG_SUPPORT_TRACE
  1694. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DROP, MNG_LC_END);
  1695. #endif
  1696. return MNG_NOERROR;
  1697. }
  1698. #endif
  1699. /* ************************************************************************** */
  1700. #ifndef MNG_NO_DELTA_PNG
  1701. #ifndef MNG_SKIPCHUNK_DBYK
  1702. mng_retcode MNG_DECL mng_getchunk_dbyk (mng_handle hHandle,
  1703. mng_handle hChunk,
  1704. mng_chunkid *iChunkname,
  1705. mng_uint8 *iPolarity,
  1706. mng_uint32 *iKeywordssize,
  1707. mng_pchar *zKeywords)
  1708. {
  1709. mng_datap pData;
  1710. mng_dbykp pChunk;
  1711. #ifdef MNG_SUPPORT_TRACE
  1712. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DBYK, MNG_LC_START);
  1713. #endif
  1714. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1715. pData = (mng_datap)hHandle; /* and make it addressable */
  1716. pChunk = (mng_dbykp)hChunk; /* address the chunk */
  1717. if (pChunk->sHeader.iChunkname != MNG_UINT_DBYK)
  1718. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1719. *iChunkname = pChunk->iChunkname; /* fill the fields */
  1720. *iPolarity = pChunk->iPolarity;
  1721. *iKeywordssize = pChunk->iKeywordssize;
  1722. *zKeywords = pChunk->zKeywords;
  1723. #ifdef MNG_SUPPORT_TRACE
  1724. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DBYK, MNG_LC_END);
  1725. #endif
  1726. return MNG_NOERROR;
  1727. }
  1728. #endif
  1729. #endif
  1730. /* ************************************************************************** */
  1731. #ifndef MNG_NO_DELTA_PNG
  1732. #ifndef MNG_SKIPCHUNK_ORDR
  1733. mng_retcode MNG_DECL mng_getchunk_ordr (mng_handle hHandle,
  1734. mng_handle hChunk,
  1735. mng_uint32 *iCount)
  1736. {
  1737. mng_datap pData;
  1738. mng_ordrp pChunk;
  1739. #ifdef MNG_SUPPORT_TRACE
  1740. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ORDR, MNG_LC_START);
  1741. #endif
  1742. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1743. pData = (mng_datap)hHandle; /* and make it addressable */
  1744. pChunk = (mng_ordrp)hChunk; /* address the chunk */
  1745. if (pChunk->sHeader.iChunkname != MNG_UINT_ORDR)
  1746. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1747. *iCount = pChunk->iCount; /* fill the field */
  1748. #ifdef MNG_SUPPORT_TRACE
  1749. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ORDR, MNG_LC_END);
  1750. #endif
  1751. return MNG_NOERROR;
  1752. }
  1753. #endif
  1754. #endif
  1755. /* ************************************************************************** */
  1756. #ifndef MNG_NO_DELTA_PNG
  1757. #ifndef MNG_SKIPCHUNK_ORDR
  1758. mng_retcode MNG_DECL mng_getchunk_ordr_entry (mng_handle hHandle,
  1759. mng_handle hChunk,
  1760. mng_uint32 iEntry,
  1761. mng_chunkid *iChunkname,
  1762. mng_uint8 *iOrdertype)
  1763. {
  1764. mng_datap pData;
  1765. mng_ordrp pChunk;
  1766. mng_ordr_entryp pEntry;
  1767. #ifdef MNG_SUPPORT_TRACE
  1768. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ORDR_ENTRY, MNG_LC_START);
  1769. #endif
  1770. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1771. pData = (mng_datap)hHandle; /* and make it addressable */
  1772. pChunk = (mng_ordrp)hChunk; /* address the chunk */
  1773. if (pChunk->sHeader.iChunkname != MNG_UINT_ORDR)
  1774. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1775. if (iEntry >= pChunk->iCount) /* valid index ? */
  1776. MNG_ERROR (pData, MNG_INVALIDENTRYIX)
  1777. pEntry = pChunk->pEntries + iEntry; /* address the proper entry */
  1778. *iChunkname = pEntry->iChunkname; /* fill the fields */
  1779. *iOrdertype = pEntry->iOrdertype;
  1780. #ifdef MNG_SUPPORT_TRACE
  1781. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ORDR_ENTRY, MNG_LC_END);
  1782. #endif
  1783. return MNG_NOERROR;
  1784. }
  1785. #endif
  1786. #endif
  1787. /* ************************************************************************** */
  1788. #ifndef MNG_SKIPCHUNK_MAGN
  1789. mng_retcode MNG_DECL mng_getchunk_magn (mng_handle hHandle,
  1790. mng_handle hChunk,
  1791. mng_uint16 *iFirstid,
  1792. mng_uint16 *iLastid,
  1793. mng_uint16 *iMethodX,
  1794. mng_uint16 *iMX,
  1795. mng_uint16 *iMY,
  1796. mng_uint16 *iML,
  1797. mng_uint16 *iMR,
  1798. mng_uint16 *iMT,
  1799. mng_uint16 *iMB,
  1800. mng_uint16 *iMethodY)
  1801. {
  1802. mng_datap pData;
  1803. mng_magnp pChunk;
  1804. #ifdef MNG_SUPPORT_TRACE
  1805. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MAGN, MNG_LC_START);
  1806. #endif
  1807. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1808. pData = (mng_datap)hHandle; /* and make it addressable */
  1809. pChunk = (mng_magnp)hChunk; /* address the chunk */
  1810. if (pChunk->sHeader.iChunkname != MNG_UINT_MAGN)
  1811. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1812. *iFirstid = pChunk->iFirstid; /* fill the fields */
  1813. *iLastid = pChunk->iLastid;
  1814. *iMethodX = (mng_uint16)pChunk->iMethodX;
  1815. *iMX = pChunk->iMX;
  1816. *iMY = pChunk->iMY;
  1817. *iML = pChunk->iML;
  1818. *iMR = pChunk->iMR;
  1819. *iMT = pChunk->iMT;
  1820. *iMB = pChunk->iMB;
  1821. *iMethodY = (mng_uint16)pChunk->iMethodY;
  1822. #ifdef MNG_SUPPORT_TRACE
  1823. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MAGN, MNG_LC_END);
  1824. #endif
  1825. return MNG_NOERROR;
  1826. }
  1827. #endif
  1828. /* ************************************************************************** */
  1829. #ifdef MNG_INCLUDE_MPNG_PROPOSAL
  1830. MNG_EXT mng_retcode MNG_DECL mng_getchunk_mpng (mng_handle hHandle,
  1831. mng_handle hChunk,
  1832. mng_uint32 *iFramewidth,
  1833. mng_uint32 *iFrameheight,
  1834. mng_uint16 *iNumplays,
  1835. mng_uint16 *iTickspersec,
  1836. mng_uint8 *iCompressionmethod,
  1837. mng_uint32 *iCount)
  1838. {
  1839. mng_datap pData;
  1840. mng_mpngp pChunk;
  1841. #ifdef MNG_SUPPORT_TRACE
  1842. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MPNG, MNG_LC_START);
  1843. #endif
  1844. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1845. pData = (mng_datap)hHandle; /* and make it addressable */
  1846. pChunk = (mng_mpngp)hChunk; /* address the chunk */
  1847. if (pChunk->sHeader.iChunkname != MNG_UINT_mpNG)
  1848. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1849. /* fill the fields */
  1850. *iFramewidth = pChunk->iFramewidth;
  1851. *iFrameheight = pChunk->iFrameheight;
  1852. *iNumplays = pChunk->iNumplays;
  1853. *iTickspersec = pChunk->iTickspersec;
  1854. *iCompressionmethod = pChunk->iCompressionmethod;
  1855. *iCount = pChunk->iFramessize / sizeof (mng_mpng_frame);
  1856. #ifdef MNG_SUPPORT_TRACE
  1857. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MPNG, MNG_LC_END);
  1858. #endif
  1859. return MNG_NOERROR;
  1860. }
  1861. #endif
  1862. /* ************************************************************************** */
  1863. #ifdef MNG_INCLUDE_MPNG_PROPOSAL
  1864. MNG_EXT mng_retcode MNG_DECL mng_getchunk_mpng_frame (mng_handle hHandle,
  1865. mng_handle hChunk,
  1866. mng_uint32 iEntry,
  1867. mng_uint32 *iX,
  1868. mng_uint32 *iY,
  1869. mng_uint32 *iWidth,
  1870. mng_uint32 *iHeight,
  1871. mng_int32 *iXoffset,
  1872. mng_int32 *iYoffset,
  1873. mng_uint16 *iTicks)
  1874. {
  1875. mng_datap pData;
  1876. mng_mpngp pChunk;
  1877. mng_mpng_framep pFrame;
  1878. #ifdef MNG_SUPPORT_TRACE
  1879. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MPNG_FRAME, MNG_LC_START);
  1880. #endif
  1881. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1882. pData = (mng_datap)hHandle; /* and make it addressable */
  1883. pChunk = (mng_mpngp)hChunk; /* address the chunk */
  1884. if (pChunk->sHeader.iChunkname != MNG_UINT_mpNG)
  1885. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1886. /* valid index ? */
  1887. if (iEntry >= (pChunk->iFramessize / sizeof (mng_mpng_frame)))
  1888. MNG_ERROR (pData, MNG_INVALIDENTRYIX)
  1889. pFrame = pChunk->pFrames + iEntry; /* address the entry */
  1890. /* fill the fields */
  1891. *iX = pFrame->iX;
  1892. *iY = pFrame->iY;
  1893. *iWidth = pFrame->iWidth;
  1894. *iHeight = pFrame->iHeight;
  1895. *iXoffset = pFrame->iXoffset;
  1896. *iYoffset = pFrame->iYoffset;
  1897. *iTicks = pFrame->iTicks;
  1898. #ifdef MNG_SUPPORT_TRACE
  1899. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MPNG_FRAME, MNG_LC_END);
  1900. #endif
  1901. return MNG_NOERROR;
  1902. }
  1903. #endif
  1904. /* ************************************************************************** */
  1905. #ifndef MNG_SKIPCHUNK_evNT
  1906. mng_retcode MNG_DECL mng_getchunk_evnt (mng_handle hHandle,
  1907. mng_handle hChunk,
  1908. mng_uint32 *iCount)
  1909. {
  1910. mng_datap pData;
  1911. mng_evntp pChunk;
  1912. #ifdef MNG_SUPPORT_TRACE
  1913. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_EVNT, MNG_LC_START);
  1914. #endif
  1915. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1916. pData = (mng_datap)hHandle; /* and make it addressable */
  1917. pChunk = (mng_evntp)hChunk; /* address the chunk */
  1918. if (pChunk->sHeader.iChunkname != MNG_UINT_evNT)
  1919. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1920. *iCount = pChunk->iCount; /* fill the fields */
  1921. #ifdef MNG_SUPPORT_TRACE
  1922. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_EVNT, MNG_LC_END);
  1923. #endif
  1924. return MNG_NOERROR;
  1925. }
  1926. /* ************************************************************************** */
  1927. mng_retcode MNG_DECL mng_getchunk_evnt_entry (mng_handle hHandle,
  1928. mng_handle hChunk,
  1929. mng_uint32 iEntry,
  1930. mng_uint8 *iEventtype,
  1931. mng_uint8 *iMasktype,
  1932. mng_int32 *iLeft,
  1933. mng_int32 *iRight,
  1934. mng_int32 *iTop,
  1935. mng_int32 *iBottom,
  1936. mng_uint16 *iObjectid,
  1937. mng_uint8 *iIndex,
  1938. mng_uint32 *iSegmentnamesize,
  1939. mng_pchar *zSegmentname)
  1940. {
  1941. mng_datap pData;
  1942. mng_evntp pChunk;
  1943. mng_evnt_entryp pEntry;
  1944. #ifdef MNG_SUPPORT_TRACE
  1945. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_EVNT_ENTRY, MNG_LC_START);
  1946. #endif
  1947. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1948. pData = (mng_datap)hHandle; /* and make it addressable */
  1949. pChunk = (mng_evntp)hChunk; /* address the chunk */
  1950. if (pChunk->sHeader.iChunkname != MNG_UINT_evNT)
  1951. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1952. if (iEntry >= pChunk->iCount) /* valid index ? */
  1953. MNG_ERROR (pData, MNG_INVALIDENTRYIX)
  1954. pEntry = pChunk->pEntries + iEntry; /* address the entry */
  1955. /* fill the fields */
  1956. *iEventtype = pEntry->iEventtype;
  1957. *iMasktype = pEntry->iMasktype;
  1958. *iLeft = pEntry->iLeft;
  1959. *iRight = pEntry->iRight;
  1960. *iTop = pEntry->iTop;
  1961. *iBottom = pEntry->iBottom;
  1962. *iObjectid = pEntry->iObjectid;
  1963. *iIndex = pEntry->iIndex;
  1964. *iSegmentnamesize = pEntry->iSegmentnamesize;
  1965. *zSegmentname = pEntry->zSegmentname;
  1966. #ifdef MNG_SUPPORT_TRACE
  1967. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_EVNT_ENTRY, MNG_LC_END);
  1968. #endif
  1969. return MNG_NOERROR;
  1970. }
  1971. #endif
  1972. /* ************************************************************************** */
  1973. mng_retcode MNG_DECL mng_getchunk_unknown (mng_handle hHandle,
  1974. mng_handle hChunk,
  1975. mng_chunkid *iChunkname,
  1976. mng_uint32 *iRawlen,
  1977. mng_ptr *pRawdata)
  1978. {
  1979. mng_datap pData;
  1980. mng_unknown_chunkp pChunk;
  1981. #ifdef MNG_SUPPORT_TRACE
  1982. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_UNKNOWN, MNG_LC_START);
  1983. #endif
  1984. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1985. pData = (mng_datap)hHandle; /* and make it addressable */
  1986. pChunk = (mng_unknown_chunkp)hChunk; /* address the chunk */
  1987. if (pChunk->sHeader.fCleanup != mng_free_unknown)
  1988. MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */
  1989. /* fill the fields */
  1990. *iChunkname = pChunk->sHeader.iChunkname;
  1991. *iRawlen = pChunk->iDatasize;
  1992. *pRawdata = pChunk->pData;
  1993. #ifdef MNG_SUPPORT_TRACE
  1994. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_UNKNOWN, MNG_LC_END);
  1995. #endif
  1996. return MNG_NOERROR;
  1997. }
  1998. /* ************************************************************************** */
  1999. /* ************************************************************************** */
  2000. #ifdef MNG_INCLUDE_WRITE_PROCS
  2001. /* ************************************************************************** */
  2002. #ifndef MNG_SKIPCHUNK_TERM
  2003. MNG_LOCAL mng_bool check_term (mng_datap pData,
  2004. mng_chunkid iChunkname)
  2005. {
  2006. mng_chunk_headerp pChunk = (mng_chunk_headerp)pData->pLastchunk;
  2007. if (!pChunk) /* nothing added yet ? */
  2008. return MNG_TRUE;
  2009. /* last added chunk is TERM ? */
  2010. if (pChunk->iChunkname != MNG_UINT_TERM)
  2011. return MNG_TRUE;
  2012. /* previous to last is MHDR ? */
  2013. if ((pChunk->pPrev) && (((mng_chunk_headerp)pChunk->pPrev)->iChunkname == MNG_UINT_MHDR))
  2014. return MNG_TRUE;
  2015. if (iChunkname == MNG_UINT_SEEK) /* new chunk to be added is SEEK ? */
  2016. return MNG_TRUE;
  2017. return MNG_FALSE;
  2018. }
  2019. #endif
  2020. /* ************************************************************************** */
  2021. mng_retcode MNG_DECL mng_putchunk_ihdr (mng_handle hHandle,
  2022. mng_uint32 iWidth,
  2023. mng_uint32 iHeight,
  2024. mng_uint8 iBitdepth,
  2025. mng_uint8 iColortype,
  2026. mng_uint8 iCompression,
  2027. mng_uint8 iFilter,
  2028. mng_uint8 iInterlace)
  2029. {
  2030. mng_datap pData;
  2031. mng_chunkp pChunk;
  2032. mng_retcode iRetcode;
  2033. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2034. mng_chunk_header sChunkheader =
  2035. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2036. {MNG_UINT_IHDR, mng_init_general, mng_free_general, mng_read_ihdr, mng_write_ihdr, mng_assign_general, 0, 0, sizeof(mng_ihdr)};
  2037. #else
  2038. {MNG_UINT_IHDR, mng_init_ihdr, mng_free_ihdr, mng_read_ihdr, mng_write_ihdr, mng_assign_ihdr, 0, 0};
  2039. #endif
  2040. #else
  2041. mng_chunk_header sChunkheader;
  2042. #endif
  2043. #ifdef MNG_SUPPORT_TRACE
  2044. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IHDR, MNG_LC_START);
  2045. #endif
  2046. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  2047. pData = (mng_datap)hHandle; /* and make it addressable */
  2048. if (!pData->bCreating) /* aren't we creating a new file ? */
  2049. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  2050. /* prevent misplaced TERM ! */
  2051. if (!check_term (pData, MNG_UINT_IHDR))
  2052. MNG_ERROR (pData, MNG_TERMSEQERROR)
  2053. /* create the chunk */
  2054. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2055. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2056. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2057. #else
  2058. iRetcode = mng_init_ihdr (pData, &sChunkheader, &pChunk);
  2059. #endif
  2060. #else
  2061. mng_get_chunkheader(MNG_UINT_IHDR, &sChunkheader);
  2062. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2063. #endif
  2064. if (iRetcode) /* on error bail out */
  2065. return iRetcode;
  2066. ((mng_ihdrp)pChunk)->iWidth = iWidth;
  2067. ((mng_ihdrp)pChunk)->iHeight = iHeight;
  2068. ((mng_ihdrp)pChunk)->iBitdepth = iBitdepth;
  2069. ((mng_ihdrp)pChunk)->iColortype = iColortype;
  2070. ((mng_ihdrp)pChunk)->iCompression = iCompression;
  2071. ((mng_ihdrp)pChunk)->iFilter = iFilter;
  2072. ((mng_ihdrp)pChunk)->iInterlace = iInterlace;
  2073. mng_add_chunk (pData, pChunk); /* add it to the list */
  2074. #ifdef MNG_SUPPORT_TRACE
  2075. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IHDR, MNG_LC_END);
  2076. #endif
  2077. return MNG_NOERROR;
  2078. }
  2079. /* ************************************************************************** */
  2080. mng_retcode MNG_DECL mng_putchunk_plte (mng_handle hHandle,
  2081. mng_uint32 iCount,
  2082. mng_palette8 aPalette)
  2083. {
  2084. mng_datap pData;
  2085. mng_chunkp pChunk;
  2086. mng_retcode iRetcode;
  2087. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2088. mng_chunk_header sChunkheader =
  2089. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2090. {MNG_UINT_PLTE, mng_init_general, mng_free_general, mng_read_plte, mng_write_plte, mng_assign_general, 0, 0, sizeof(mng_plte)};
  2091. #else
  2092. {MNG_UINT_PLTE, mng_init_plte, mng_free_plte, mng_read_plte, mng_write_plte, mng_assign_plte, 0, 0};
  2093. #endif
  2094. #else
  2095. mng_chunk_header sChunkheader;
  2096. #endif
  2097. #ifdef MNG_SUPPORT_TRACE
  2098. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PLTE, MNG_LC_START);
  2099. #endif
  2100. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  2101. pData = (mng_datap)hHandle; /* and make it addressable */
  2102. if (!pData->bCreating) /* aren't we creating a new file ? */
  2103. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  2104. /* must have had a header first! */
  2105. if (pData->iFirstchunkadded == 0)
  2106. MNG_ERROR (pData, MNG_NOHEADER)
  2107. /* prevent misplaced TERM ! */
  2108. if (!check_term (pData, MNG_UINT_PLTE))
  2109. MNG_ERROR (pData, MNG_TERMSEQERROR)
  2110. /* create the chunk */
  2111. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2112. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2113. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2114. #else
  2115. iRetcode = mng_init_plte (pData, &sChunkheader, &pChunk);
  2116. #endif
  2117. #else
  2118. mng_get_chunkheader(MNG_UINT_PLTE, &sChunkheader);
  2119. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2120. #endif
  2121. if (iRetcode) /* on error bail out */
  2122. return iRetcode;
  2123. /* fill the chunk */
  2124. ((mng_pltep)pChunk)->iEntrycount = iCount;
  2125. ((mng_pltep)pChunk)->bEmpty = (mng_bool)(iCount == 0);
  2126. MNG_COPY (((mng_pltep)pChunk)->aEntries, aPalette, sizeof (mng_palette8));
  2127. mng_add_chunk (pData, pChunk); /* add it to the list */
  2128. #ifdef MNG_SUPPORT_TRACE
  2129. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PLTE, MNG_LC_END);
  2130. #endif
  2131. return MNG_NOERROR;
  2132. }
  2133. /* ************************************************************************** */
  2134. mng_retcode MNG_DECL mng_putchunk_idat (mng_handle hHandle,
  2135. mng_uint32 iRawlen,
  2136. mng_ptr pRawdata)
  2137. {
  2138. mng_datap pData;
  2139. mng_chunkp pChunk;
  2140. mng_retcode iRetcode;
  2141. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2142. mng_chunk_header sChunkheader =
  2143. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2144. {MNG_UINT_IDAT, mng_init_general, mng_free_idat, mng_read_idat, mng_write_idat, mng_assign_idat, 0, 0, sizeof(mng_idat)};
  2145. #else
  2146. {MNG_UINT_IDAT, mng_init_idat, mng_free_idat, mng_read_idat, mng_write_idat, mng_assign_idat, 0, 0};
  2147. #endif
  2148. #else
  2149. mng_chunk_header sChunkheader;
  2150. #endif
  2151. #ifdef MNG_SUPPORT_TRACE
  2152. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IDAT, MNG_LC_START);
  2153. #endif
  2154. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  2155. pData = (mng_datap)hHandle; /* and make it addressable */
  2156. if (!pData->bCreating) /* aren't we creating a new file ? */
  2157. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  2158. /* must have had a header first! */
  2159. if (pData->iFirstchunkadded == 0)
  2160. MNG_ERROR (pData, MNG_NOHEADER)
  2161. /* prevent misplaced TERM ! */
  2162. if (!check_term (pData, MNG_UINT_IDAT))
  2163. MNG_ERROR (pData, MNG_TERMSEQERROR)
  2164. /* create the chunk */
  2165. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2166. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2167. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2168. #else
  2169. iRetcode = mng_init_idat (pData, &sChunkheader, &pChunk);
  2170. #endif
  2171. #else
  2172. mng_get_chunkheader(MNG_UINT_IDAT, &sChunkheader);
  2173. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2174. #endif
  2175. if (iRetcode) /* on error bail out */
  2176. return iRetcode;
  2177. /* fill the chunk */
  2178. ((mng_idatp)pChunk)->bEmpty = (mng_bool)(iRawlen == 0);
  2179. ((mng_idatp)pChunk)->iDatasize = iRawlen;
  2180. if (iRawlen)
  2181. {
  2182. MNG_ALLOC (pData, ((mng_idatp)pChunk)->pData, iRawlen);
  2183. MNG_COPY (((mng_idatp)pChunk)->pData, pRawdata, iRawlen);
  2184. }
  2185. mng_add_chunk (pData, pChunk); /* add it to the list */
  2186. #ifdef MNG_SUPPORT_TRACE
  2187. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IDAT, MNG_LC_END);
  2188. #endif
  2189. return MNG_NOERROR;
  2190. }
  2191. /* ************************************************************************** */
  2192. mng_retcode MNG_DECL mng_putchunk_iend (mng_handle hHandle)
  2193. {
  2194. mng_datap pData;
  2195. mng_chunkp pChunk;
  2196. mng_retcode iRetcode;
  2197. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2198. mng_chunk_header sChunkheader =
  2199. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2200. {MNG_UINT_IEND, mng_init_general, mng_free_general, mng_read_iend, mng_write_iend, mng_assign_general, 0, 0, sizeof(mng_iend)};
  2201. #else
  2202. {MNG_UINT_IEND, mng_init_iend, mng_free_iend, mng_read_iend, mng_write_iend, mng_assign_iend, 0, 0};
  2203. #endif
  2204. #else
  2205. mng_chunk_header sChunkheader;
  2206. #endif
  2207. #ifdef MNG_SUPPORT_TRACE
  2208. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IEND, MNG_LC_START);
  2209. #endif
  2210. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  2211. pData = (mng_datap)hHandle; /* and make it addressable */
  2212. if (!pData->bCreating) /* aren't we creating a new file ? */
  2213. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  2214. /* must have had a header first! */
  2215. if (pData->iFirstchunkadded == 0)
  2216. MNG_ERROR (pData, MNG_NOHEADER)
  2217. /* prevent misplaced TERM ! */
  2218. if (!check_term (pData, MNG_UINT_IEND))
  2219. MNG_ERROR (pData, MNG_TERMSEQERROR)
  2220. /* create the chunk */
  2221. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2222. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2223. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2224. #else
  2225. iRetcode = mng_init_iend (pData, &sChunkheader, &pChunk);
  2226. #endif
  2227. #else
  2228. mng_get_chunkheader(MNG_UINT_IEND, &sChunkheader);
  2229. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2230. #endif
  2231. if (iRetcode) /* on error bail out */
  2232. return iRetcode;
  2233. mng_add_chunk (pData, pChunk); /* add it to the list */
  2234. #ifdef MNG_INCLUDE_JNG
  2235. if ((pData->iFirstchunkadded == MNG_UINT_IHDR) ||
  2236. (pData->iFirstchunkadded == MNG_UINT_JHDR) )
  2237. #else
  2238. if (pData->iFirstchunkadded == MNG_UINT_IHDR)
  2239. #endif
  2240. pData->bCreating = MNG_FALSE; /* should be last chunk !!! */
  2241. #ifdef MNG_SUPPORT_TRACE
  2242. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IEND, MNG_LC_END);
  2243. #endif
  2244. return MNG_NOERROR;
  2245. }
  2246. /* ************************************************************************** */
  2247. mng_retcode MNG_DECL mng_putchunk_trns (mng_handle hHandle,
  2248. mng_bool bEmpty,
  2249. mng_bool bGlobal,
  2250. mng_uint8 iType,
  2251. mng_uint32 iCount,
  2252. mng_uint8arr aAlphas,
  2253. mng_uint16 iGray,
  2254. mng_uint16 iRed,
  2255. mng_uint16 iGreen,
  2256. mng_uint16 iBlue,
  2257. mng_uint32 iRawlen,
  2258. mng_uint8arr aRawdata)
  2259. {
  2260. mng_datap pData;
  2261. mng_chunkp pChunk;
  2262. mng_retcode iRetcode;
  2263. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2264. mng_chunk_header sChunkheader =
  2265. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2266. {MNG_UINT_tRNS, mng_init_general, mng_free_general, mng_read_trns, mng_write_trns, mng_assign_general, 0, 0, sizeof(mng_trns)};
  2267. #else
  2268. {MNG_UINT_tRNS, mng_init_trns, mng_free_trns, mng_read_trns, mng_write_trns, mng_assign_trns, 0, 0};
  2269. #endif
  2270. #else
  2271. mng_chunk_header sChunkheader;
  2272. #endif
  2273. #ifdef MNG_SUPPORT_TRACE
  2274. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TRNS, MNG_LC_START);
  2275. #endif
  2276. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  2277. pData = (mng_datap)hHandle; /* and make it addressable */
  2278. if (!pData->bCreating) /* aren't we creating a new file ? */
  2279. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  2280. /* must have had a header first! */
  2281. if (pData->iFirstchunkadded == 0)
  2282. MNG_ERROR (pData, MNG_NOHEADER)
  2283. /* prevent misplaced TERM ! */
  2284. if (!check_term (pData, MNG_UINT_tRNS))
  2285. MNG_ERROR (pData, MNG_TERMSEQERROR)
  2286. /* create the chunk */
  2287. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2288. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2289. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2290. #else
  2291. iRetcode = mng_init_trns (pData, &sChunkheader, &pChunk);
  2292. #endif
  2293. #else
  2294. mng_get_chunkheader(MNG_UINT_tRNS, &sChunkheader);
  2295. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2296. #endif
  2297. if (iRetcode) /* on error bail out */
  2298. return iRetcode;
  2299. /* fill the chunk */
  2300. ((mng_trnsp)pChunk)->bEmpty = bEmpty;
  2301. ((mng_trnsp)pChunk)->bGlobal = bGlobal;
  2302. ((mng_trnsp)pChunk)->iType = iType;
  2303. ((mng_trnsp)pChunk)->iCount = iCount;
  2304. ((mng_trnsp)pChunk)->iGray = iGray;
  2305. ((mng_trnsp)pChunk)->iRed = iRed;
  2306. ((mng_trnsp)pChunk)->iGreen = iGreen;
  2307. ((mng_trnsp)pChunk)->iBlue = iBlue;
  2308. ((mng_trnsp)pChunk)->iRawlen = iRawlen;
  2309. MNG_COPY (((mng_trnsp)pChunk)->aEntries, aAlphas, sizeof (mng_uint8arr));
  2310. MNG_COPY (((mng_trnsp)pChunk)->aRawdata, aRawdata, sizeof (mng_uint8arr));
  2311. mng_add_chunk (pData, pChunk); /* add it to the list */
  2312. #ifdef MNG_SUPPORT_TRACE
  2313. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TRNS, MNG_LC_END);
  2314. #endif
  2315. return MNG_NOERROR;
  2316. }
  2317. /* ************************************************************************** */
  2318. #ifndef MNG_SKIPCHUNK_gAMA
  2319. mng_retcode MNG_DECL mng_putchunk_gama (mng_handle hHandle,
  2320. mng_bool bEmpty,
  2321. mng_uint32 iGamma)
  2322. {
  2323. mng_datap pData;
  2324. mng_chunkp pChunk;
  2325. mng_retcode iRetcode;
  2326. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2327. mng_chunk_header sChunkheader =
  2328. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2329. {MNG_UINT_gAMA, mng_init_general, mng_free_general, mng_read_gama, mng_write_gama, mng_assign_general, 0, 0, sizeof(mng_gama)};
  2330. #else
  2331. {MNG_UINT_gAMA, mng_init_gama, mng_free_gama, mng_read_gama, mng_write_gama, mng_assign_gama, 0, 0};
  2332. #endif
  2333. #else
  2334. mng_chunk_header sChunkheader;
  2335. #endif
  2336. #ifdef MNG_SUPPORT_TRACE
  2337. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_GAMA, MNG_LC_START);
  2338. #endif
  2339. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  2340. pData = (mng_datap)hHandle; /* and make it addressable */
  2341. if (!pData->bCreating) /* aren't we creating a new file ? */
  2342. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  2343. /* must have had a header first! */
  2344. if (pData->iFirstchunkadded == 0)
  2345. MNG_ERROR (pData, MNG_NOHEADER)
  2346. /* prevent misplaced TERM ! */
  2347. if (!check_term (pData, MNG_UINT_gAMA))
  2348. MNG_ERROR (pData, MNG_TERMSEQERROR)
  2349. /* create the chunk */
  2350. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2351. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2352. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2353. #else
  2354. iRetcode = mng_init_gama (pData, &sChunkheader, &pChunk);
  2355. #endif
  2356. #else
  2357. mng_get_chunkheader(MNG_UINT_gAMA, &sChunkheader);
  2358. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2359. #endif
  2360. if (iRetcode) /* on error bail out */
  2361. return iRetcode;
  2362. /* fill the chunk */
  2363. ((mng_gamap)pChunk)->bEmpty = bEmpty;
  2364. ((mng_gamap)pChunk)->iGamma = iGamma;
  2365. mng_add_chunk (pData, pChunk); /* add it to the list */
  2366. #ifdef MNG_SUPPORT_TRACE
  2367. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_GAMA, MNG_LC_END);
  2368. #endif
  2369. return MNG_NOERROR;
  2370. }
  2371. #endif
  2372. /* ************************************************************************** */
  2373. #ifndef MNG_SKIPCHUNK_cHRM
  2374. mng_retcode MNG_DECL mng_putchunk_chrm (mng_handle hHandle,
  2375. mng_bool bEmpty,
  2376. mng_uint32 iWhitepointx,
  2377. mng_uint32 iWhitepointy,
  2378. mng_uint32 iRedx,
  2379. mng_uint32 iRedy,
  2380. mng_uint32 iGreenx,
  2381. mng_uint32 iGreeny,
  2382. mng_uint32 iBluex,
  2383. mng_uint32 iBluey)
  2384. {
  2385. mng_datap pData;
  2386. mng_chunkp pChunk;
  2387. mng_retcode iRetcode;
  2388. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2389. mng_chunk_header sChunkheader =
  2390. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2391. {MNG_UINT_cHRM, mng_init_general, mng_free_general, mng_read_chrm, mng_write_chrm, mng_assign_general, 0, 0, sizeof(mng_chrm)};
  2392. #else
  2393. {MNG_UINT_cHRM, mng_init_chrm, mng_free_chrm, mng_read_chrm, mng_write_chrm, mng_assign_chrm, 0, 0};
  2394. #endif
  2395. #else
  2396. mng_chunk_header sChunkheader;
  2397. #endif
  2398. #ifdef MNG_SUPPORT_TRACE
  2399. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CHRM, MNG_LC_START);
  2400. #endif
  2401. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  2402. pData = (mng_datap)hHandle; /* and make it addressable */
  2403. if (!pData->bCreating) /* aren't we creating a new file ? */
  2404. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  2405. /* must have had a header first! */
  2406. if (pData->iFirstchunkadded == 0)
  2407. MNG_ERROR (pData, MNG_NOHEADER)
  2408. /* prevent misplaced TERM ! */
  2409. if (!check_term (pData, MNG_UINT_cHRM))
  2410. MNG_ERROR (pData, MNG_TERMSEQERROR)
  2411. /* create the chunk */
  2412. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2413. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2414. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2415. #else
  2416. iRetcode = mng_init_chrm (pData, &sChunkheader, &pChunk);
  2417. #endif
  2418. #else
  2419. mng_get_chunkheader(MNG_UINT_cHRM, &sChunkheader);
  2420. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2421. #endif
  2422. if (iRetcode) /* on error bail out */
  2423. return iRetcode;
  2424. /* fill the chunk */
  2425. ((mng_chrmp)pChunk)->bEmpty = bEmpty;
  2426. ((mng_chrmp)pChunk)->iWhitepointx = iWhitepointx;
  2427. ((mng_chrmp)pChunk)->iWhitepointy = iWhitepointy;
  2428. ((mng_chrmp)pChunk)->iRedx = iRedx;
  2429. ((mng_chrmp)pChunk)->iRedy = iRedy;
  2430. ((mng_chrmp)pChunk)->iGreenx = iGreenx;
  2431. ((mng_chrmp)pChunk)->iGreeny = iGreeny;
  2432. ((mng_chrmp)pChunk)->iBluex = iBluex;
  2433. ((mng_chrmp)pChunk)->iBluey = iBluey;
  2434. mng_add_chunk (pData, pChunk); /* add it to the list */
  2435. #ifdef MNG_SUPPORT_TRACE
  2436. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CHRM, MNG_LC_END);
  2437. #endif
  2438. return MNG_NOERROR;
  2439. }
  2440. #endif
  2441. /* ************************************************************************** */
  2442. #ifndef MNG_SKIPCHUNK_sRGB
  2443. mng_retcode MNG_DECL mng_putchunk_srgb (mng_handle hHandle,
  2444. mng_bool bEmpty,
  2445. mng_uint8 iRenderingintent)
  2446. {
  2447. mng_datap pData;
  2448. mng_chunkp pChunk;
  2449. mng_retcode iRetcode;
  2450. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2451. mng_chunk_header sChunkheader =
  2452. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2453. {MNG_UINT_sRGB, mng_init_general, mng_free_general, mng_read_srgb, mng_write_srgb, mng_assign_general, 0, 0, sizeof(mng_srgb)};
  2454. #else
  2455. {MNG_UINT_sRGB, mng_init_srgb, mng_free_srgb, mng_read_srgb, mng_write_srgb, mng_assign_srgb, 0, 0};
  2456. #endif
  2457. #else
  2458. mng_chunk_header sChunkheader;
  2459. #endif
  2460. #ifdef MNG_SUPPORT_TRACE
  2461. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SRGB, MNG_LC_START);
  2462. #endif
  2463. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  2464. pData = (mng_datap)hHandle; /* and make it addressable */
  2465. if (!pData->bCreating) /* aren't we creating a new file ? */
  2466. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  2467. /* must have had a header first! */
  2468. if (pData->iFirstchunkadded == 0)
  2469. MNG_ERROR (pData, MNG_NOHEADER)
  2470. /* prevent misplaced TERM ! */
  2471. if (!check_term (pData, MNG_UINT_sRGB))
  2472. MNG_ERROR (pData, MNG_TERMSEQERROR)
  2473. /* create the chunk */
  2474. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2475. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2476. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2477. #else
  2478. iRetcode = mng_init_srgb (pData, &sChunkheader, &pChunk);
  2479. #endif
  2480. #else
  2481. mng_get_chunkheader(MNG_UINT_sRGB, &sChunkheader);
  2482. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2483. #endif
  2484. if (iRetcode) /* on error bail out */
  2485. return iRetcode;
  2486. /* fill the chunk */
  2487. ((mng_srgbp)pChunk)->bEmpty = bEmpty;
  2488. ((mng_srgbp)pChunk)->iRenderingintent = iRenderingintent;
  2489. mng_add_chunk (pData, pChunk); /* add it to the list */
  2490. #ifdef MNG_SUPPORT_TRACE
  2491. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SRGB, MNG_LC_END);
  2492. #endif
  2493. return MNG_NOERROR;
  2494. }
  2495. #endif
  2496. /* ************************************************************************** */
  2497. #ifndef MNG_SKIPCHUNK_iCCP
  2498. mng_retcode MNG_DECL mng_putchunk_iccp (mng_handle hHandle,
  2499. mng_bool bEmpty,
  2500. mng_uint32 iNamesize,
  2501. mng_pchar zName,
  2502. mng_uint8 iCompression,
  2503. mng_uint32 iProfilesize,
  2504. mng_ptr pProfile)
  2505. {
  2506. mng_datap pData;
  2507. mng_chunkp pChunk;
  2508. mng_retcode iRetcode;
  2509. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2510. mng_chunk_header sChunkheader =
  2511. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2512. {MNG_UINT_iCCP, mng_init_general, mng_free_iccp, mng_read_iccp, mng_write_iccp, mng_assign_iccp, 0, 0, sizeof(mng_iccp)};
  2513. #else
  2514. {MNG_UINT_iCCP, mng_init_iccp, mng_free_iccp, mng_read_iccp, mng_write_iccp, mng_assign_iccp, 0, 0};
  2515. #endif
  2516. #else
  2517. mng_chunk_header sChunkheader;
  2518. #endif
  2519. #ifdef MNG_SUPPORT_TRACE
  2520. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ICCP, MNG_LC_START);
  2521. #endif
  2522. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  2523. pData = (mng_datap)hHandle; /* and make it addressable */
  2524. if (!pData->bCreating) /* aren't we creating a new file ? */
  2525. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  2526. /* must have had a header first! */
  2527. if (pData->iFirstchunkadded == 0)
  2528. MNG_ERROR (pData, MNG_NOHEADER)
  2529. /* prevent misplaced TERM ! */
  2530. if (!check_term (pData, MNG_UINT_iCCP))
  2531. MNG_ERROR (pData, MNG_TERMSEQERROR)
  2532. /* create the chunk */
  2533. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2534. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2535. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2536. #else
  2537. iRetcode = mng_init_iccp (pData, &sChunkheader, &pChunk);
  2538. #endif
  2539. #else
  2540. mng_get_chunkheader(MNG_UINT_iCCP, &sChunkheader);
  2541. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2542. #endif
  2543. if (iRetcode) /* on error bail out */
  2544. return iRetcode;
  2545. /* fill the chunk */
  2546. ((mng_iccpp)pChunk)->bEmpty = bEmpty;
  2547. ((mng_iccpp)pChunk)->iNamesize = iNamesize;
  2548. ((mng_iccpp)pChunk)->iCompression = iCompression;
  2549. ((mng_iccpp)pChunk)->iProfilesize = iProfilesize;
  2550. if (iNamesize)
  2551. {
  2552. MNG_ALLOC (pData, ((mng_iccpp)pChunk)->zName, iNamesize + 1);
  2553. MNG_COPY (((mng_iccpp)pChunk)->zName, zName, iNamesize);
  2554. }
  2555. if (iProfilesize)
  2556. {
  2557. MNG_ALLOC (pData, ((mng_iccpp)pChunk)->pProfile, iProfilesize);
  2558. MNG_COPY (((mng_iccpp)pChunk)->pProfile, pProfile, iProfilesize);
  2559. }
  2560. mng_add_chunk (pData, pChunk); /* add it to the list */
  2561. #ifdef MNG_SUPPORT_TRACE
  2562. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ICCP, MNG_LC_END);
  2563. #endif
  2564. return MNG_NOERROR;
  2565. }
  2566. #endif
  2567. /* ************************************************************************** */
  2568. #ifndef MNG_SKIPCHUNK_tEXt
  2569. mng_retcode MNG_DECL mng_putchunk_text (mng_handle hHandle,
  2570. mng_uint32 iKeywordsize,
  2571. mng_pchar zKeyword,
  2572. mng_uint32 iTextsize,
  2573. mng_pchar zText)
  2574. {
  2575. mng_datap pData;
  2576. mng_chunkp pChunk;
  2577. mng_retcode iRetcode;
  2578. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2579. mng_chunk_header sChunkheader =
  2580. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2581. {MNG_UINT_tEXt, mng_init_general, mng_free_text, mng_read_text, mng_write_text, mng_assign_text, 0, 0, sizeof(mng_text)};
  2582. #else
  2583. {MNG_UINT_tEXt, mng_init_text, mng_free_text, mng_read_text, mng_write_text, mng_assign_text, 0, 0};
  2584. #endif
  2585. #else
  2586. mng_chunk_header sChunkheader;
  2587. #endif
  2588. #ifdef MNG_SUPPORT_TRACE
  2589. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TEXT, MNG_LC_START);
  2590. #endif
  2591. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  2592. pData = (mng_datap)hHandle; /* and make it addressable */
  2593. if (!pData->bCreating) /* aren't we creating a new file ? */
  2594. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  2595. /* must have had a header first! */
  2596. if (pData->iFirstchunkadded == 0)
  2597. MNG_ERROR (pData, MNG_NOHEADER)
  2598. /* prevent misplaced TERM ! */
  2599. if (!check_term (pData, MNG_UINT_tEXt))
  2600. MNG_ERROR (pData, MNG_TERMSEQERROR)
  2601. /* create the chunk */
  2602. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2603. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2604. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2605. #else
  2606. iRetcode = mng_init_text (pData, &sChunkheader, &pChunk);
  2607. #endif
  2608. #else
  2609. mng_get_chunkheader(MNG_UINT_tEXt, &sChunkheader);
  2610. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2611. #endif
  2612. if (iRetcode) /* on error bail out */
  2613. return iRetcode;
  2614. /* fill the chunk */
  2615. ((mng_textp)pChunk)->iKeywordsize = iKeywordsize;
  2616. ((mng_textp)pChunk)->iTextsize = iTextsize;
  2617. if (iKeywordsize)
  2618. {
  2619. MNG_ALLOC (pData, ((mng_textp)pChunk)->zKeyword, iKeywordsize + 1);
  2620. MNG_COPY (((mng_textp)pChunk)->zKeyword, zKeyword, iKeywordsize);
  2621. }
  2622. if (iTextsize)
  2623. {
  2624. MNG_ALLOC (pData, ((mng_textp)pChunk)->zText, iTextsize + 1);
  2625. MNG_COPY (((mng_textp)pChunk)->zText, zText, iTextsize);
  2626. }
  2627. mng_add_chunk (pData, pChunk); /* add it to the list */
  2628. #ifdef MNG_SUPPORT_TRACE
  2629. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TEXT, MNG_LC_END);
  2630. #endif
  2631. return MNG_NOERROR;
  2632. }
  2633. #endif
  2634. /* ************************************************************************** */
  2635. #ifndef MNG_SKIPCHUNK_zTXt
  2636. mng_retcode MNG_DECL mng_putchunk_ztxt (mng_handle hHandle,
  2637. mng_uint32 iKeywordsize,
  2638. mng_pchar zKeyword,
  2639. mng_uint8 iCompression,
  2640. mng_uint32 iTextsize,
  2641. mng_pchar zText)
  2642. {
  2643. mng_datap pData;
  2644. mng_chunkp pChunk;
  2645. mng_retcode iRetcode;
  2646. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2647. mng_chunk_header sChunkheader =
  2648. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2649. {MNG_UINT_zTXt, mng_init_general, mng_free_ztxt, mng_read_ztxt, mng_write_ztxt, mng_assign_ztxt, 0, 0, sizeof(mng_ztxt)};
  2650. #else
  2651. {MNG_UINT_zTXt, mng_init_ztxt, mng_free_ztxt, mng_read_ztxt, mng_write_ztxt, mng_assign_ztxt, 0, 0};
  2652. #endif
  2653. #else
  2654. mng_chunk_header sChunkheader;
  2655. #endif
  2656. #ifdef MNG_SUPPORT_TRACE
  2657. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ZTXT, MNG_LC_START);
  2658. #endif
  2659. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  2660. pData = (mng_datap)hHandle; /* and make it addressable */
  2661. if (!pData->bCreating) /* aren't we creating a new file ? */
  2662. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  2663. /* must have had a header first! */
  2664. if (pData->iFirstchunkadded == 0)
  2665. MNG_ERROR (pData, MNG_NOHEADER)
  2666. /* prevent misplaced TERM ! */
  2667. if (!check_term (pData, MNG_UINT_zTXt))
  2668. MNG_ERROR (pData, MNG_TERMSEQERROR)
  2669. /* create the chunk */
  2670. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2671. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2672. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2673. #else
  2674. iRetcode = mng_init_ztxt (pData, &sChunkheader, &pChunk);
  2675. #endif
  2676. #else
  2677. mng_get_chunkheader(MNG_UINT_zTXt, &sChunkheader);
  2678. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2679. #endif
  2680. if (iRetcode) /* on error bail out */
  2681. return iRetcode;
  2682. /* fill the chunk */
  2683. ((mng_ztxtp)pChunk)->iKeywordsize = iKeywordsize;
  2684. ((mng_ztxtp)pChunk)->iCompression = iCompression;
  2685. ((mng_ztxtp)pChunk)->iTextsize = iTextsize;
  2686. if (iKeywordsize)
  2687. {
  2688. MNG_ALLOC (pData, ((mng_ztxtp)pChunk)->zKeyword, iKeywordsize + 1);
  2689. MNG_COPY (((mng_ztxtp)pChunk)->zKeyword, zKeyword, iKeywordsize);
  2690. }
  2691. if (iTextsize)
  2692. {
  2693. MNG_ALLOC (pData, ((mng_ztxtp)pChunk)->zText, iTextsize + 1);
  2694. MNG_COPY (((mng_ztxtp)pChunk)->zText, zText, iTextsize);
  2695. }
  2696. mng_add_chunk (pData, pChunk); /* add it to the list */
  2697. #ifdef MNG_SUPPORT_TRACE
  2698. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ZTXT, MNG_LC_END);
  2699. #endif
  2700. return MNG_NOERROR;
  2701. }
  2702. #endif
  2703. /* ************************************************************************** */
  2704. #ifndef MNG_SKIPCHUNK_iTXt
  2705. mng_retcode MNG_DECL mng_putchunk_itxt (mng_handle hHandle,
  2706. mng_uint32 iKeywordsize,
  2707. mng_pchar zKeyword,
  2708. mng_uint8 iCompressionflag,
  2709. mng_uint8 iCompressionmethod,
  2710. mng_uint32 iLanguagesize,
  2711. mng_pchar zLanguage,
  2712. mng_uint32 iTranslationsize,
  2713. mng_pchar zTranslation,
  2714. mng_uint32 iTextsize,
  2715. mng_pchar zText)
  2716. {
  2717. mng_datap pData;
  2718. mng_chunkp pChunk;
  2719. mng_retcode iRetcode;
  2720. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2721. mng_chunk_header sChunkheader =
  2722. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2723. {MNG_UINT_iTXt, mng_init_general, mng_free_itxt, mng_read_itxt, mng_write_itxt, mng_assign_itxt, 0, 0, sizeof(mng_itxt)};
  2724. #else
  2725. {MNG_UINT_iTXt, mng_init_itxt, mng_free_itxt, mng_read_itxt, mng_write_itxt, mng_assign_itxt, 0, 0};
  2726. #endif
  2727. #else
  2728. mng_chunk_header sChunkheader;
  2729. #endif
  2730. #ifdef MNG_SUPPORT_TRACE
  2731. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ITXT, MNG_LC_START);
  2732. #endif
  2733. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  2734. pData = (mng_datap)hHandle; /* and make it addressable */
  2735. if (!pData->bCreating) /* aren't we creating a new file ? */
  2736. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  2737. /* must have had a header first! */
  2738. if (pData->iFirstchunkadded == 0)
  2739. MNG_ERROR (pData, MNG_NOHEADER)
  2740. /* prevent misplaced TERM ! */
  2741. if (!check_term (pData, MNG_UINT_iTXt))
  2742. MNG_ERROR (pData, MNG_TERMSEQERROR)
  2743. /* create the chunk */
  2744. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2745. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2746. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2747. #else
  2748. iRetcode = mng_init_itxt (pData, &sChunkheader, &pChunk);
  2749. #endif
  2750. #else
  2751. mng_get_chunkheader(MNG_UINT_iTXt, &sChunkheader);
  2752. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2753. #endif
  2754. if (iRetcode) /* on error bail out */
  2755. return iRetcode;
  2756. /* fill the chunk */
  2757. ((mng_itxtp)pChunk)->iKeywordsize = iKeywordsize;
  2758. ((mng_itxtp)pChunk)->iCompressionflag = iCompressionflag;
  2759. ((mng_itxtp)pChunk)->iCompressionmethod = iCompressionmethod;
  2760. ((mng_itxtp)pChunk)->iLanguagesize = iLanguagesize;
  2761. ((mng_itxtp)pChunk)->iTranslationsize = iTranslationsize;
  2762. ((mng_itxtp)pChunk)->iTextsize = iTextsize;
  2763. if (iKeywordsize)
  2764. {
  2765. MNG_ALLOC (pData, ((mng_itxtp)pChunk)->zKeyword, iKeywordsize + 1);
  2766. MNG_COPY (((mng_itxtp)pChunk)->zKeyword, zKeyword, iKeywordsize);
  2767. }
  2768. if (iLanguagesize)
  2769. {
  2770. MNG_ALLOC (pData, ((mng_itxtp)pChunk)->zLanguage, iLanguagesize + 1);
  2771. MNG_COPY (((mng_itxtp)pChunk)->zLanguage, zLanguage, iLanguagesize);
  2772. }
  2773. if (iTranslationsize)
  2774. {
  2775. MNG_ALLOC (pData, ((mng_itxtp)pChunk)->zTranslation, iTranslationsize + 1);
  2776. MNG_COPY (((mng_itxtp)pChunk)->zTranslation, zTranslation, iTranslationsize);
  2777. }
  2778. if (iTextsize)
  2779. {
  2780. MNG_ALLOC (pData, ((mng_itxtp)pChunk)->zText, iTextsize + 1);
  2781. MNG_COPY (((mng_itxtp)pChunk)->zText, zText, iTextsize);
  2782. }
  2783. mng_add_chunk (pData, pChunk); /* add it to the list */
  2784. #ifdef MNG_SUPPORT_TRACE
  2785. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ITXT, MNG_LC_END);
  2786. #endif
  2787. return MNG_NOERROR;
  2788. }
  2789. #endif
  2790. /* ************************************************************************** */
  2791. #ifndef MNG_SKIPCHUNK_bKGD
  2792. mng_retcode MNG_DECL mng_putchunk_bkgd (mng_handle hHandle,
  2793. mng_bool bEmpty,
  2794. mng_uint8 iType,
  2795. mng_uint8 iIndex,
  2796. mng_uint16 iGray,
  2797. mng_uint16 iRed,
  2798. mng_uint16 iGreen,
  2799. mng_uint16 iBlue)
  2800. {
  2801. mng_datap pData;
  2802. mng_chunkp pChunk;
  2803. mng_retcode iRetcode;
  2804. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2805. mng_chunk_header sChunkheader =
  2806. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2807. {MNG_UINT_bKGD, mng_init_general, mng_free_general, mng_read_bkgd, mng_write_bkgd, mng_assign_general, 0, 0, sizeof(mng_bkgd)};
  2808. #else
  2809. {MNG_UINT_bKGD, mng_init_bkgd, mng_free_bkgd, mng_read_bkgd, mng_write_bkgd, mng_assign_bkgd, 0, 0};
  2810. #endif
  2811. #else
  2812. mng_chunk_header sChunkheader;
  2813. #endif
  2814. #ifdef MNG_SUPPORT_TRACE
  2815. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BKGD, MNG_LC_START);
  2816. #endif
  2817. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  2818. pData = (mng_datap)hHandle; /* and make it addressable */
  2819. if (!pData->bCreating) /* aren't we creating a new file ? */
  2820. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  2821. /* must have had a header first! */
  2822. if (pData->iFirstchunkadded == 0)
  2823. MNG_ERROR (pData, MNG_NOHEADER)
  2824. /* prevent misplaced TERM ! */
  2825. if (!check_term (pData, MNG_UINT_bKGD))
  2826. MNG_ERROR (pData, MNG_TERMSEQERROR)
  2827. /* create the chunk */
  2828. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2829. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2830. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2831. #else
  2832. iRetcode = mng_init_bkgd (pData, &sChunkheader, &pChunk);
  2833. #endif
  2834. #else
  2835. mng_get_chunkheader(MNG_UINT_bKGD, &sChunkheader);
  2836. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2837. #endif
  2838. if (iRetcode) /* on error bail out */
  2839. return iRetcode;
  2840. /* fill the chunk */
  2841. ((mng_bkgdp)pChunk)->bEmpty = bEmpty;
  2842. ((mng_bkgdp)pChunk)->iType = iType;
  2843. ((mng_bkgdp)pChunk)->iIndex = iIndex;
  2844. ((mng_bkgdp)pChunk)->iGray = iGray;
  2845. ((mng_bkgdp)pChunk)->iRed = iRed;
  2846. ((mng_bkgdp)pChunk)->iGreen = iGreen;
  2847. ((mng_bkgdp)pChunk)->iBlue = iBlue;
  2848. mng_add_chunk (pData, pChunk); /* add it to the list */
  2849. #ifdef MNG_SUPPORT_TRACE
  2850. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BKGD, MNG_LC_END);
  2851. #endif
  2852. return MNG_NOERROR;
  2853. }
  2854. #endif
  2855. /* ************************************************************************** */
  2856. #ifndef MNG_SKIPCHUNK_pHYs
  2857. mng_retcode MNG_DECL mng_putchunk_phys (mng_handle hHandle,
  2858. mng_bool bEmpty,
  2859. mng_uint32 iSizex,
  2860. mng_uint32 iSizey,
  2861. mng_uint8 iUnit)
  2862. {
  2863. mng_datap pData;
  2864. mng_chunkp pChunk;
  2865. mng_retcode iRetcode;
  2866. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2867. mng_chunk_header sChunkheader =
  2868. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2869. {MNG_UINT_pHYs, mng_init_general, mng_free_general, mng_read_phys, mng_write_phys, mng_assign_general, 0, 0, sizeof(mng_phys)};
  2870. #else
  2871. {MNG_UINT_pHYs, mng_init_phys, mng_free_phys, mng_read_phys, mng_write_phys, mng_assign_phys, 0, 0};
  2872. #endif
  2873. #else
  2874. mng_chunk_header sChunkheader;
  2875. #endif
  2876. #ifdef MNG_SUPPORT_TRACE
  2877. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PHYS, MNG_LC_START);
  2878. #endif
  2879. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  2880. pData = (mng_datap)hHandle; /* and make it addressable */
  2881. if (!pData->bCreating) /* aren't we creating a new file ? */
  2882. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  2883. /* must have had a header first! */
  2884. if (pData->iFirstchunkadded == 0)
  2885. MNG_ERROR (pData, MNG_NOHEADER)
  2886. /* prevent misplaced TERM ! */
  2887. if (!check_term (pData, MNG_UINT_pHYs))
  2888. MNG_ERROR (pData, MNG_TERMSEQERROR)
  2889. /* create the chunk */
  2890. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2891. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2892. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2893. #else
  2894. iRetcode = mng_init_phys (pData, &sChunkheader, &pChunk);
  2895. #endif
  2896. #else
  2897. mng_get_chunkheader(MNG_UINT_pHYs, &sChunkheader);
  2898. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2899. #endif
  2900. if (iRetcode) /* on error bail out */
  2901. return iRetcode;
  2902. /* fill the chunk */
  2903. ((mng_physp)pChunk)->bEmpty = bEmpty;
  2904. ((mng_physp)pChunk)->iSizex = iSizex;
  2905. ((mng_physp)pChunk)->iSizey = iSizey;
  2906. ((mng_physp)pChunk)->iUnit = iUnit;
  2907. mng_add_chunk (pData, pChunk); /* add it to the list */
  2908. #ifdef MNG_SUPPORT_TRACE
  2909. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PHYS, MNG_LC_END);
  2910. #endif
  2911. return MNG_NOERROR;
  2912. }
  2913. #endif
  2914. /* ************************************************************************** */
  2915. #ifndef MNG_SKIPCHUNK_sBIT
  2916. mng_retcode MNG_DECL mng_putchunk_sbit (mng_handle hHandle,
  2917. mng_bool bEmpty,
  2918. mng_uint8 iType,
  2919. mng_uint8arr4 aBits)
  2920. {
  2921. mng_datap pData;
  2922. mng_chunkp pChunk;
  2923. mng_retcode iRetcode;
  2924. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2925. mng_chunk_header sChunkheader =
  2926. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2927. {MNG_UINT_sBIT, mng_init_general, mng_free_general, mng_read_sbit, mng_write_sbit, mng_assign_general, 0, 0, sizeof(mng_sbit)};
  2928. #else
  2929. {MNG_UINT_sBIT, mng_init_sbit, mng_free_sbit, mng_read_sbit, mng_write_sbit, mng_assign_sbit, 0, 0};
  2930. #endif
  2931. #else
  2932. mng_chunk_header sChunkheader;
  2933. #endif
  2934. #ifdef MNG_SUPPORT_TRACE
  2935. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SBIT, MNG_LC_START);
  2936. #endif
  2937. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  2938. pData = (mng_datap)hHandle; /* and make it addressable */
  2939. if (!pData->bCreating) /* aren't we creating a new file ? */
  2940. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  2941. /* must have had a header first! */
  2942. if (pData->iFirstchunkadded == 0)
  2943. MNG_ERROR (pData, MNG_NOHEADER)
  2944. /* prevent misplaced TERM ! */
  2945. if (!check_term (pData, MNG_UINT_sBIT))
  2946. MNG_ERROR (pData, MNG_TERMSEQERROR)
  2947. /* create the chunk */
  2948. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2949. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2950. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2951. #else
  2952. iRetcode = mng_init_sbit (pData, &sChunkheader, &pChunk);
  2953. #endif
  2954. #else
  2955. mng_get_chunkheader(MNG_UINT_sBIT, &sChunkheader);
  2956. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  2957. #endif
  2958. if (iRetcode) /* on error bail out */
  2959. return iRetcode;
  2960. /* fill the chunk */
  2961. ((mng_sbitp)pChunk)->bEmpty = bEmpty;
  2962. ((mng_sbitp)pChunk)->iType = iType;
  2963. ((mng_sbitp)pChunk)->aBits[0] = aBits[0];
  2964. ((mng_sbitp)pChunk)->aBits[1] = aBits[1];
  2965. ((mng_sbitp)pChunk)->aBits[2] = aBits[2];
  2966. ((mng_sbitp)pChunk)->aBits[3] = aBits[3];
  2967. mng_add_chunk (pData, pChunk); /* add it to the list */
  2968. #ifdef MNG_SUPPORT_TRACE
  2969. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SBIT, MNG_LC_END);
  2970. #endif
  2971. return MNG_NOERROR;
  2972. }
  2973. #endif
  2974. /* ************************************************************************** */
  2975. #ifndef MNG_SKIPCHUNK_sPLT
  2976. mng_retcode MNG_DECL mng_putchunk_splt (mng_handle hHandle,
  2977. mng_bool bEmpty,
  2978. mng_uint32 iNamesize,
  2979. mng_pchar zName,
  2980. mng_uint8 iSampledepth,
  2981. mng_uint32 iEntrycount,
  2982. mng_ptr pEntries)
  2983. {
  2984. mng_datap pData;
  2985. mng_chunkp pChunk;
  2986. mng_retcode iRetcode;
  2987. #ifndef MNG_OPTIMIZE_CHUNKREADER
  2988. mng_chunk_header sChunkheader =
  2989. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  2990. {MNG_UINT_sPLT, mng_init_general, mng_free_splt, mng_read_splt, mng_write_splt, mng_assign_splt, 0, 0, sizeof(mng_splt)};
  2991. #else
  2992. {MNG_UINT_sPLT, mng_init_splt, mng_free_splt, mng_read_splt, mng_write_splt, mng_assign_splt, 0, 0};
  2993. #endif
  2994. #else
  2995. mng_chunk_header sChunkheader;
  2996. #endif
  2997. #ifdef MNG_SUPPORT_TRACE
  2998. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SPLT, MNG_LC_START);
  2999. #endif
  3000. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  3001. pData = (mng_datap)hHandle; /* and make it addressable */
  3002. if (!pData->bCreating) /* aren't we creating a new file ? */
  3003. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  3004. /* must have had a header first! */
  3005. if (pData->iFirstchunkadded == 0)
  3006. MNG_ERROR (pData, MNG_NOHEADER)
  3007. /* prevent misplaced TERM ! */
  3008. if (!check_term (pData, MNG_UINT_sPLT))
  3009. MNG_ERROR (pData, MNG_TERMSEQERROR)
  3010. /* create the chunk */
  3011. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3012. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3013. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3014. #else
  3015. iRetcode = mng_init_splt (pData, &sChunkheader, &pChunk);
  3016. #endif
  3017. #else
  3018. mng_get_chunkheader(MNG_UINT_sPLT, &sChunkheader);
  3019. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3020. #endif
  3021. if (iRetcode) /* on error bail out */
  3022. return iRetcode;
  3023. /* fill the chunk */
  3024. ((mng_spltp)pChunk)->bEmpty = bEmpty;
  3025. ((mng_spltp)pChunk)->iNamesize = iNamesize;
  3026. ((mng_spltp)pChunk)->iSampledepth = iSampledepth;
  3027. ((mng_spltp)pChunk)->iEntrycount = iEntrycount;
  3028. if (iNamesize)
  3029. {
  3030. MNG_ALLOC (pData, ((mng_spltp)pChunk)->zName, iNamesize + 1);
  3031. MNG_COPY (((mng_spltp)pChunk)->zName, zName, iNamesize);
  3032. }
  3033. if (iEntrycount)
  3034. {
  3035. mng_uint32 iSize = iEntrycount * ((iSampledepth >> 1) + 2);
  3036. MNG_ALLOC (pData, ((mng_spltp)pChunk)->pEntries, iSize);
  3037. MNG_COPY (((mng_spltp)pChunk)->pEntries, pEntries, iSize);
  3038. }
  3039. mng_add_chunk (pData, pChunk); /* add it to the list */
  3040. #ifdef MNG_SUPPORT_TRACE
  3041. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SPLT, MNG_LC_END);
  3042. #endif
  3043. return MNG_NOERROR;
  3044. }
  3045. #endif
  3046. /* ************************************************************************** */
  3047. #ifndef MNG_SKIPCHUNK_hIST
  3048. mng_retcode MNG_DECL mng_putchunk_hist (mng_handle hHandle,
  3049. mng_uint32 iEntrycount,
  3050. mng_uint16arr aEntries)
  3051. {
  3052. mng_datap pData;
  3053. mng_chunkp pChunk;
  3054. mng_retcode iRetcode;
  3055. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3056. mng_chunk_header sChunkheader =
  3057. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3058. {MNG_UINT_hIST, mng_init_general, mng_free_general, mng_read_hist, mng_write_hist, mng_assign_general, 0, 0, sizeof(mng_hist)};
  3059. #else
  3060. {MNG_UINT_hIST, mng_init_hist, mng_free_hist, mng_read_hist, mng_write_hist, mng_assign_hist, 0, 0};
  3061. #endif
  3062. #else
  3063. mng_chunk_header sChunkheader;
  3064. #endif
  3065. #ifdef MNG_SUPPORT_TRACE
  3066. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_HIST, MNG_LC_START);
  3067. #endif
  3068. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  3069. pData = (mng_datap)hHandle; /* and make it addressable */
  3070. if (!pData->bCreating) /* aren't we creating a new file ? */
  3071. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  3072. /* must have had a header first! */
  3073. if (pData->iFirstchunkadded == 0)
  3074. MNG_ERROR (pData, MNG_NOHEADER)
  3075. /* prevent misplaced TERM ! */
  3076. if (!check_term (pData, MNG_UINT_hIST))
  3077. MNG_ERROR (pData, MNG_TERMSEQERROR)
  3078. /* create the chunk */
  3079. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3080. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3081. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3082. #else
  3083. iRetcode = mng_init_hist (pData, &sChunkheader, &pChunk);
  3084. #endif
  3085. #else
  3086. mng_get_chunkheader(MNG_UINT_hIST, &sChunkheader);
  3087. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3088. #endif
  3089. if (iRetcode) /* on error bail out */
  3090. return iRetcode;
  3091. /* fill the chunk */
  3092. ((mng_histp)pChunk)->iEntrycount = iEntrycount;
  3093. MNG_COPY (((mng_histp)pChunk)->aEntries, aEntries, sizeof (mng_uint16arr));
  3094. mng_add_chunk (pData, pChunk); /* add it to the list */
  3095. #ifdef MNG_SUPPORT_TRACE
  3096. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_HIST, MNG_LC_END);
  3097. #endif
  3098. return MNG_NOERROR;
  3099. }
  3100. #endif
  3101. /* ************************************************************************** */
  3102. #ifndef MNG_SKIPCHUNK_tIME
  3103. mng_retcode MNG_DECL mng_putchunk_time (mng_handle hHandle,
  3104. mng_uint16 iYear,
  3105. mng_uint8 iMonth,
  3106. mng_uint8 iDay,
  3107. mng_uint8 iHour,
  3108. mng_uint8 iMinute,
  3109. mng_uint8 iSecond)
  3110. {
  3111. mng_datap pData;
  3112. mng_chunkp pChunk;
  3113. mng_retcode iRetcode;
  3114. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3115. mng_chunk_header sChunkheader =
  3116. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3117. {MNG_UINT_tIME, mng_init_general, mng_free_general, mng_read_time, mng_write_time, mng_assign_general, 0, 0, sizeof(mng_time)};
  3118. #else
  3119. {MNG_UINT_tIME, mng_init_time, mng_free_time, mng_read_time, mng_write_time, mng_assign_time, 0, 0};
  3120. #endif
  3121. #else
  3122. mng_chunk_header sChunkheader;
  3123. #endif
  3124. #ifdef MNG_SUPPORT_TRACE
  3125. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TIME, MNG_LC_START);
  3126. #endif
  3127. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  3128. pData = (mng_datap)hHandle; /* and make it addressable */
  3129. if (!pData->bCreating) /* aren't we creating a new file ? */
  3130. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  3131. /* prevent misplaced TERM ! */
  3132. if (!check_term (pData, MNG_UINT_tIME))
  3133. MNG_ERROR (pData, MNG_TERMSEQERROR)
  3134. /* must have had a header first! */
  3135. if (pData->iFirstchunkadded == 0)
  3136. MNG_ERROR (pData, MNG_NOHEADER)
  3137. /* create the chunk */
  3138. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3139. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3140. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3141. #else
  3142. iRetcode = mng_init_time (pData, &sChunkheader, &pChunk);
  3143. #endif
  3144. #else
  3145. mng_get_chunkheader(MNG_UINT_tIME, &sChunkheader);
  3146. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3147. #endif
  3148. if (iRetcode) /* on error bail out */
  3149. return iRetcode;
  3150. /* fill the chunk */
  3151. ((mng_timep)pChunk)->iYear = iYear;
  3152. ((mng_timep)pChunk)->iMonth = iMonth;
  3153. ((mng_timep)pChunk)->iDay = iDay;
  3154. ((mng_timep)pChunk)->iHour = iHour;
  3155. ((mng_timep)pChunk)->iMinute = iMinute;
  3156. ((mng_timep)pChunk)->iSecond = iSecond;
  3157. mng_add_chunk (pData, pChunk); /* add it to the list */
  3158. #ifdef MNG_SUPPORT_TRACE
  3159. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TIME, MNG_LC_END);
  3160. #endif
  3161. return MNG_NOERROR;
  3162. }
  3163. #endif
  3164. /* ************************************************************************** */
  3165. mng_retcode MNG_DECL mng_putchunk_mhdr (mng_handle hHandle,
  3166. mng_uint32 iWidth,
  3167. mng_uint32 iHeight,
  3168. mng_uint32 iTicks,
  3169. mng_uint32 iLayercount,
  3170. mng_uint32 iFramecount,
  3171. mng_uint32 iPlaytime,
  3172. mng_uint32 iSimplicity)
  3173. {
  3174. mng_datap pData;
  3175. mng_chunkp pChunk;
  3176. mng_retcode iRetcode;
  3177. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3178. mng_chunk_header sChunkheader =
  3179. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3180. {MNG_UINT_MHDR, mng_init_general, mng_free_general, mng_read_mhdr, mng_write_mhdr, mng_assign_general, 0, 0, sizeof(mng_mhdr)};
  3181. #else
  3182. {MNG_UINT_MHDR, mng_init_mhdr, mng_free_mhdr, mng_read_mhdr, mng_write_mhdr, mng_assign_mhdr, 0, 0};
  3183. #endif
  3184. #else
  3185. mng_chunk_header sChunkheader;
  3186. #endif
  3187. #ifdef MNG_SUPPORT_TRACE
  3188. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MHDR, MNG_LC_START);
  3189. #endif
  3190. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  3191. pData = (mng_datap)hHandle; /* and make it addressable */
  3192. if (!pData->bCreating) /* aren't we creating a new file ? */
  3193. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  3194. /* must be very first! */
  3195. if (pData->iFirstchunkadded != 0)
  3196. MNG_ERROR (pData, MNG_SEQUENCEERROR)
  3197. /* prevent misplaced TERM ! */
  3198. if (!check_term (pData, MNG_UINT_MHDR))
  3199. MNG_ERROR (pData, MNG_TERMSEQERROR)
  3200. /* create the chunk */
  3201. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3202. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3203. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3204. #else
  3205. iRetcode = mng_init_mhdr (pData, &sChunkheader, &pChunk);
  3206. #endif
  3207. #else
  3208. mng_get_chunkheader(MNG_UINT_MHDR, &sChunkheader);
  3209. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3210. #endif
  3211. if (iRetcode) /* on error bail out */
  3212. return iRetcode;
  3213. /* fill the chunk */
  3214. ((mng_mhdrp)pChunk)->iWidth = iWidth;
  3215. ((mng_mhdrp)pChunk)->iHeight = iHeight;
  3216. ((mng_mhdrp)pChunk)->iTicks = iTicks;
  3217. ((mng_mhdrp)pChunk)->iLayercount = iLayercount;
  3218. ((mng_mhdrp)pChunk)->iFramecount = iFramecount;
  3219. ((mng_mhdrp)pChunk)->iPlaytime = iPlaytime;
  3220. ((mng_mhdrp)pChunk)->iSimplicity = iSimplicity;
  3221. mng_add_chunk (pData, pChunk); /* add it to the list */
  3222. #ifdef MNG_SUPPORT_TRACE
  3223. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MHDR, MNG_LC_END);
  3224. #endif
  3225. return MNG_NOERROR;
  3226. }
  3227. /* ************************************************************************** */
  3228. mng_retcode MNG_DECL mng_putchunk_mend (mng_handle hHandle)
  3229. {
  3230. mng_datap pData;
  3231. mng_chunkp pChunk;
  3232. mng_retcode iRetcode;
  3233. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3234. mng_chunk_header sChunkheader =
  3235. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3236. {MNG_UINT_MEND, mng_init_general, mng_free_general, mng_read_mend, mng_write_mend, mng_assign_general, 0, 0, sizeof(mng_mend)};
  3237. #else
  3238. {MNG_UINT_MEND, mng_init_mend, mng_free_mend, mng_read_mend, mng_write_mend, mng_assign_mend, 0, 0};
  3239. #endif
  3240. #else
  3241. mng_chunk_header sChunkheader;
  3242. #endif
  3243. #ifdef MNG_SUPPORT_TRACE
  3244. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MEND, MNG_LC_START);
  3245. #endif
  3246. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  3247. pData = (mng_datap)hHandle; /* and make it addressable */
  3248. if (!pData->bCreating) /* aren't we creating a new file ? */
  3249. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  3250. /* must have had a header first! */
  3251. if (pData->iFirstchunkadded == 0)
  3252. MNG_ERROR (pData, MNG_NOHEADER)
  3253. /* prevent misplaced TERM ! */
  3254. if (!check_term (pData, MNG_UINT_MEND))
  3255. MNG_ERROR (pData, MNG_TERMSEQERROR)
  3256. /* create the chunk */
  3257. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3258. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3259. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3260. #else
  3261. iRetcode = mng_init_mend (pData, &sChunkheader, &pChunk);
  3262. #endif
  3263. #else
  3264. mng_get_chunkheader(MNG_UINT_MEND, &sChunkheader);
  3265. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3266. #endif
  3267. if (iRetcode) /* on error bail out */
  3268. return iRetcode;
  3269. mng_add_chunk (pData, pChunk); /* add it to the list */
  3270. pData->bCreating = MNG_FALSE; /* should be last chunk !!! */
  3271. #ifdef MNG_SUPPORT_TRACE
  3272. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MEND, MNG_LC_END);
  3273. #endif
  3274. return MNG_NOERROR;
  3275. }
  3276. /* ************************************************************************** */
  3277. #ifndef MNG_SKIPCHUNK_LOOP
  3278. mng_retcode MNG_DECL mng_putchunk_loop (mng_handle hHandle,
  3279. mng_uint8 iLevel,
  3280. mng_uint32 iRepeat,
  3281. mng_uint8 iTermination,
  3282. mng_uint32 iItermin,
  3283. mng_uint32 iItermax,
  3284. mng_uint32 iCount,
  3285. mng_uint32p pSignals)
  3286. {
  3287. mng_datap pData;
  3288. mng_chunkp pChunk;
  3289. mng_retcode iRetcode;
  3290. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3291. mng_chunk_header sChunkheader =
  3292. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3293. {MNG_UINT_LOOP, mng_init_general, mng_free_loop, mng_read_loop, mng_write_loop, mng_assign_loop, 0, 0, sizeof(mng_loop)};
  3294. #else
  3295. {MNG_UINT_LOOP, mng_init_loop, mng_free_loop, mng_read_loop, mng_write_loop, mng_assign_loop, 0, 0};
  3296. #endif
  3297. #else
  3298. mng_chunk_header sChunkheader;
  3299. #endif
  3300. #ifdef MNG_SUPPORT_TRACE
  3301. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_LOOP, MNG_LC_START);
  3302. #endif
  3303. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  3304. pData = (mng_datap)hHandle; /* and make it addressable */
  3305. if (!pData->bCreating) /* aren't we creating a new file ? */
  3306. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  3307. /* must have had a MHDR first! */
  3308. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  3309. MNG_ERROR (pData, MNG_NOHEADER)
  3310. /* prevent misplaced TERM ! */
  3311. if (!check_term (pData, MNG_UINT_LOOP))
  3312. MNG_ERROR (pData, MNG_TERMSEQERROR)
  3313. /* create the chunk */
  3314. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3315. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3316. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3317. #else
  3318. iRetcode = mng_init_loop (pData, &sChunkheader, &pChunk);
  3319. #endif
  3320. #else
  3321. mng_get_chunkheader(MNG_UINT_LOOP, &sChunkheader);
  3322. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3323. #endif
  3324. if (iRetcode) /* on error bail out */
  3325. return iRetcode;
  3326. /* fill the chunk */
  3327. ((mng_loopp)pChunk)->iLevel = iLevel;
  3328. ((mng_loopp)pChunk)->iRepeat = iRepeat;
  3329. ((mng_loopp)pChunk)->iTermination = iTermination;
  3330. ((mng_loopp)pChunk)->iItermin = iItermin;
  3331. ((mng_loopp)pChunk)->iItermax = iItermax;
  3332. ((mng_loopp)pChunk)->iCount = iCount;
  3333. ((mng_loopp)pChunk)->pSignals = pSignals;
  3334. mng_add_chunk (pData, pChunk); /* add it to the list */
  3335. #ifdef MNG_SUPPORT_TRACE
  3336. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_LOOP, MNG_LC_END);
  3337. #endif
  3338. return MNG_NOERROR;
  3339. }
  3340. /* ************************************************************************** */
  3341. mng_retcode MNG_DECL mng_putchunk_endl (mng_handle hHandle,
  3342. mng_uint8 iLevel)
  3343. {
  3344. mng_datap pData;
  3345. mng_chunkp pChunk;
  3346. mng_retcode iRetcode;
  3347. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3348. mng_chunk_header sChunkheader =
  3349. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3350. {MNG_UINT_ENDL, mng_init_general, mng_free_general, mng_read_endl, mng_write_endl, mng_assign_general, 0, 0, sizeof(mng_endl)};
  3351. #else
  3352. {MNG_UINT_ENDL, mng_init_endl, mng_free_endl, mng_read_endl, mng_write_endl, mng_assign_endl, 0, 0};
  3353. #endif
  3354. #else
  3355. mng_chunk_header sChunkheader;
  3356. #endif
  3357. #ifdef MNG_SUPPORT_TRACE
  3358. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ENDL, MNG_LC_START);
  3359. #endif
  3360. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  3361. pData = (mng_datap)hHandle; /* and make it addressable */
  3362. if (!pData->bCreating) /* aren't we creating a new file ? */
  3363. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  3364. /* must have had a MHDR first! */
  3365. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  3366. MNG_ERROR (pData, MNG_NOHEADER)
  3367. /* prevent misplaced TERM ! */
  3368. if (!check_term (pData, MNG_UINT_ENDL))
  3369. MNG_ERROR (pData, MNG_TERMSEQERROR)
  3370. /* create the chunk */
  3371. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3372. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3373. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3374. #else
  3375. iRetcode = mng_init_endl (pData, &sChunkheader, &pChunk);
  3376. #endif
  3377. #else
  3378. mng_get_chunkheader(MNG_UINT_ENDL, &sChunkheader);
  3379. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3380. #endif
  3381. if (iRetcode) /* on error bail out */
  3382. return iRetcode;
  3383. /* fill the chunk */
  3384. ((mng_endlp)pChunk)->iLevel = iLevel;
  3385. mng_add_chunk (pData, pChunk); /* add it to the list */
  3386. #ifdef MNG_SUPPORT_TRACE
  3387. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ENDL, MNG_LC_END);
  3388. #endif
  3389. return MNG_NOERROR;
  3390. }
  3391. #endif
  3392. /* ************************************************************************** */
  3393. #ifndef MNG_SKIPCHUNK_DEFI
  3394. mng_retcode MNG_DECL mng_putchunk_defi (mng_handle hHandle,
  3395. mng_uint16 iObjectid,
  3396. mng_uint8 iDonotshow,
  3397. mng_uint8 iConcrete,
  3398. mng_bool bHasloca,
  3399. mng_int32 iXlocation,
  3400. mng_int32 iYlocation,
  3401. mng_bool bHasclip,
  3402. mng_int32 iLeftcb,
  3403. mng_int32 iRightcb,
  3404. mng_int32 iTopcb,
  3405. mng_int32 iBottomcb)
  3406. {
  3407. mng_datap pData;
  3408. mng_chunkp pChunk;
  3409. mng_retcode iRetcode;
  3410. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3411. mng_chunk_header sChunkheader =
  3412. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3413. {MNG_UINT_DEFI, mng_init_general, mng_free_general, mng_read_defi, mng_write_defi, mng_assign_general, 0, 0, sizeof(mng_defi)};
  3414. #else
  3415. {MNG_UINT_DEFI, mng_init_defi, mng_free_defi, mng_read_defi, mng_write_defi, mng_assign_defi, 0, 0};
  3416. #endif
  3417. #else
  3418. mng_chunk_header sChunkheader;
  3419. #endif
  3420. #ifdef MNG_SUPPORT_TRACE
  3421. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DEFI, MNG_LC_START);
  3422. #endif
  3423. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  3424. pData = (mng_datap)hHandle; /* and make it addressable */
  3425. if (!pData->bCreating) /* aren't we creating a new file ? */
  3426. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  3427. /* must have had a MHDR first! */
  3428. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  3429. MNG_ERROR (pData, MNG_NOHEADER)
  3430. /* prevent misplaced TERM ! */
  3431. if (!check_term (pData, MNG_UINT_DEFI))
  3432. MNG_ERROR (pData, MNG_TERMSEQERROR)
  3433. /* create the chunk */
  3434. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3435. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3436. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3437. #else
  3438. iRetcode = mng_init_defi (pData, &sChunkheader, &pChunk);
  3439. #endif
  3440. #else
  3441. mng_get_chunkheader(MNG_UINT_DEFI, &sChunkheader);
  3442. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3443. #endif
  3444. if (iRetcode) /* on error bail out */
  3445. return iRetcode;
  3446. /* fill the chunk */
  3447. ((mng_defip)pChunk)->iObjectid = iObjectid;
  3448. ((mng_defip)pChunk)->iDonotshow = iDonotshow;
  3449. ((mng_defip)pChunk)->iConcrete = iConcrete;
  3450. ((mng_defip)pChunk)->bHasloca = bHasloca;
  3451. ((mng_defip)pChunk)->iXlocation = iXlocation;
  3452. ((mng_defip)pChunk)->iYlocation = iYlocation;
  3453. ((mng_defip)pChunk)->bHasclip = bHasclip;
  3454. ((mng_defip)pChunk)->iLeftcb = iLeftcb;
  3455. ((mng_defip)pChunk)->iRightcb = iRightcb;
  3456. ((mng_defip)pChunk)->iTopcb = iTopcb;
  3457. ((mng_defip)pChunk)->iBottomcb = iBottomcb;
  3458. mng_add_chunk (pData, pChunk); /* add it to the list */
  3459. #ifdef MNG_SUPPORT_TRACE
  3460. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DEFI, MNG_LC_END);
  3461. #endif
  3462. return MNG_NOERROR;
  3463. }
  3464. #endif
  3465. /* ************************************************************************** */
  3466. #ifndef MNG_SKIPCHUNK_BASI
  3467. mng_retcode MNG_DECL mng_putchunk_basi (mng_handle hHandle,
  3468. mng_uint32 iWidth,
  3469. mng_uint32 iHeight,
  3470. mng_uint8 iBitdepth,
  3471. mng_uint8 iColortype,
  3472. mng_uint8 iCompression,
  3473. mng_uint8 iFilter,
  3474. mng_uint8 iInterlace,
  3475. mng_uint16 iRed,
  3476. mng_uint16 iGreen,
  3477. mng_uint16 iBlue,
  3478. mng_uint16 iAlpha,
  3479. mng_uint8 iViewable)
  3480. {
  3481. mng_datap pData;
  3482. mng_chunkp pChunk;
  3483. mng_retcode iRetcode;
  3484. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3485. mng_chunk_header sChunkheader =
  3486. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3487. {MNG_UINT_BASI, mng_init_general, mng_free_general, mng_read_basi, mng_write_basi, mng_assign_general, 0, 0, sizeof(mng_basi)};
  3488. #else
  3489. {MNG_UINT_BASI, mng_init_basi, mng_free_basi, mng_read_basi, mng_write_basi, mng_assign_basi, 0, 0};
  3490. #endif
  3491. #else
  3492. mng_chunk_header sChunkheader;
  3493. #endif
  3494. #ifdef MNG_SUPPORT_TRACE
  3495. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BASI, MNG_LC_START);
  3496. #endif
  3497. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  3498. pData = (mng_datap)hHandle; /* and make it addressable */
  3499. if (!pData->bCreating) /* aren't we creating a new file ? */
  3500. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  3501. /* must have had a MHDR first! */
  3502. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  3503. MNG_ERROR (pData, MNG_NOHEADER)
  3504. /* prevent misplaced TERM ! */
  3505. if (!check_term (pData, MNG_UINT_BASI))
  3506. MNG_ERROR (pData, MNG_TERMSEQERROR)
  3507. /* create the chunk */
  3508. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3509. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3510. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3511. #else
  3512. iRetcode = mng_init_basi (pData, &sChunkheader, &pChunk);
  3513. #endif
  3514. #else
  3515. mng_get_chunkheader(MNG_UINT_BASI, &sChunkheader);
  3516. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3517. #endif
  3518. if (iRetcode) /* on error bail out */
  3519. return iRetcode;
  3520. /* fill the chunk */
  3521. ((mng_basip)pChunk)->iWidth = iWidth;
  3522. ((mng_basip)pChunk)->iHeight = iHeight;
  3523. ((mng_basip)pChunk)->iBitdepth = iBitdepth;
  3524. ((mng_basip)pChunk)->iColortype = iColortype;
  3525. ((mng_basip)pChunk)->iCompression = iCompression;
  3526. ((mng_basip)pChunk)->iFilter = iFilter;
  3527. ((mng_basip)pChunk)->iInterlace = iInterlace;
  3528. ((mng_basip)pChunk)->iRed = iRed;
  3529. ((mng_basip)pChunk)->iGreen = iGreen;
  3530. ((mng_basip)pChunk)->iBlue = iBlue;
  3531. ((mng_basip)pChunk)->iAlpha = iAlpha;
  3532. ((mng_basip)pChunk)->iViewable = iViewable;
  3533. mng_add_chunk (pData, pChunk); /* add it to the list */
  3534. #ifdef MNG_SUPPORT_TRACE
  3535. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BASI, MNG_LC_END);
  3536. #endif
  3537. return MNG_NOERROR;
  3538. }
  3539. #endif
  3540. /* ************************************************************************** */
  3541. #ifndef MNG_SKIPCHUNK_CLON
  3542. mng_retcode MNG_DECL mng_putchunk_clon (mng_handle hHandle,
  3543. mng_uint16 iSourceid,
  3544. mng_uint16 iCloneid,
  3545. mng_uint8 iClonetype,
  3546. mng_uint8 iDonotshow,
  3547. mng_uint8 iConcrete,
  3548. mng_bool bHasloca,
  3549. mng_uint8 iLocationtype,
  3550. mng_int32 iLocationx,
  3551. mng_int32 iLocationy)
  3552. {
  3553. mng_datap pData;
  3554. mng_chunkp pChunk;
  3555. mng_retcode iRetcode;
  3556. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3557. mng_chunk_header sChunkheader =
  3558. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3559. {MNG_UINT_CLON, mng_init_general, mng_free_general, mng_read_clon, mng_write_clon, mng_assign_general, 0, 0, sizeof(mng_clon)};
  3560. #else
  3561. {MNG_UINT_CLON, mng_init_clon, mng_free_clon, mng_read_clon, mng_write_clon, mng_assign_clon, 0, 0};
  3562. #endif
  3563. #else
  3564. mng_chunk_header sChunkheader;
  3565. #endif
  3566. #ifdef MNG_SUPPORT_TRACE
  3567. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CLON, MNG_LC_START);
  3568. #endif
  3569. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  3570. pData = (mng_datap)hHandle; /* and make it addressable */
  3571. if (!pData->bCreating) /* aren't we creating a new file ? */
  3572. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  3573. /* must have had a MHDR first! */
  3574. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  3575. MNG_ERROR (pData, MNG_NOHEADER)
  3576. /* prevent misplaced TERM ! */
  3577. if (!check_term (pData, MNG_UINT_CLON))
  3578. MNG_ERROR (pData, MNG_TERMSEQERROR)
  3579. /* create the chunk */
  3580. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3581. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3582. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3583. #else
  3584. iRetcode = mng_init_clon (pData, &sChunkheader, &pChunk);
  3585. #endif
  3586. #else
  3587. mng_get_chunkheader(MNG_UINT_CLON, &sChunkheader);
  3588. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3589. #endif
  3590. if (iRetcode) /* on error bail out */
  3591. return iRetcode;
  3592. /* fill the chunk */
  3593. ((mng_clonp)pChunk)->iSourceid = iSourceid;
  3594. ((mng_clonp)pChunk)->iCloneid = iCloneid;
  3595. ((mng_clonp)pChunk)->iClonetype = iClonetype;
  3596. ((mng_clonp)pChunk)->iDonotshow = iDonotshow;
  3597. ((mng_clonp)pChunk)->iConcrete = iConcrete;
  3598. ((mng_clonp)pChunk)->bHasloca = bHasloca;
  3599. ((mng_clonp)pChunk)->iLocationtype = iLocationtype;
  3600. ((mng_clonp)pChunk)->iLocationx = iLocationx;
  3601. ((mng_clonp)pChunk)->iLocationy = iLocationy;
  3602. mng_add_chunk (pData, pChunk); /* add it to the list */
  3603. #ifdef MNG_SUPPORT_TRACE
  3604. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CLON, MNG_LC_END);
  3605. #endif
  3606. return MNG_NOERROR;
  3607. }
  3608. #endif
  3609. /* ************************************************************************** */
  3610. #ifndef MNG_SKIPCHUNK_PAST
  3611. mng_retcode MNG_DECL mng_putchunk_past (mng_handle hHandle,
  3612. mng_uint16 iDestid,
  3613. mng_uint8 iTargettype,
  3614. mng_int32 iTargetx,
  3615. mng_int32 iTargety,
  3616. mng_uint32 iCount)
  3617. {
  3618. mng_datap pData;
  3619. mng_chunkp pChunk;
  3620. mng_retcode iRetcode;
  3621. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3622. mng_chunk_header sChunkheader =
  3623. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3624. {MNG_UINT_PAST, mng_init_general, mng_free_past, mng_read_past, mng_write_past, mng_assign_past, 0, 0, sizeof(mng_past)};
  3625. #else
  3626. {MNG_UINT_PAST, mng_init_past, mng_free_past, mng_read_past, mng_write_past, mng_assign_past, 0, 0};
  3627. #endif
  3628. #else
  3629. mng_chunk_header sChunkheader;
  3630. #endif
  3631. #ifdef MNG_SUPPORT_TRACE
  3632. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PAST, MNG_LC_START);
  3633. #endif
  3634. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  3635. pData = (mng_datap)hHandle; /* and make it addressable */
  3636. if (!pData->bCreating) /* aren't we creating a new file ? */
  3637. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  3638. /* must have had a MHDR first! */
  3639. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  3640. MNG_ERROR (pData, MNG_NOHEADER)
  3641. /* prevent misplaced TERM ! */
  3642. if (!check_term (pData, MNG_UINT_PAST))
  3643. MNG_ERROR (pData, MNG_TERMSEQERROR)
  3644. /* create the chunk */
  3645. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3646. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3647. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3648. #else
  3649. iRetcode = mng_init_past (pData, &sChunkheader, &pChunk);
  3650. #endif
  3651. #else
  3652. mng_get_chunkheader(MNG_UINT_PAST, &sChunkheader);
  3653. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3654. #endif
  3655. if (iRetcode) /* on error bail out */
  3656. return iRetcode;
  3657. /* fill the chunk */
  3658. ((mng_pastp)pChunk)->iDestid = iDestid;
  3659. ((mng_pastp)pChunk)->iTargettype = iTargettype;
  3660. ((mng_pastp)pChunk)->iTargetx = iTargetx;
  3661. ((mng_pastp)pChunk)->iTargety = iTargety;
  3662. ((mng_pastp)pChunk)->iCount = iCount;
  3663. if (iCount)
  3664. MNG_ALLOC (pData, ((mng_pastp)pChunk)->pSources, iCount * sizeof (mng_past_source));
  3665. mng_add_chunk (pData, pChunk); /* add it to the list */
  3666. #ifdef MNG_SUPPORT_TRACE
  3667. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PAST, MNG_LC_END);
  3668. #endif
  3669. return MNG_NOERROR;
  3670. }
  3671. #endif
  3672. /* ************************************************************************** */
  3673. #ifndef MNG_SKIPCHUNK_PAST
  3674. mng_retcode MNG_DECL mng_putchunk_past_src (mng_handle hHandle,
  3675. mng_uint32 iEntry,
  3676. mng_uint16 iSourceid,
  3677. mng_uint8 iComposition,
  3678. mng_uint8 iOrientation,
  3679. mng_uint8 iOffsettype,
  3680. mng_int32 iOffsetx,
  3681. mng_int32 iOffsety,
  3682. mng_uint8 iBoundarytype,
  3683. mng_int32 iBoundaryl,
  3684. mng_int32 iBoundaryr,
  3685. mng_int32 iBoundaryt,
  3686. mng_int32 iBoundaryb)
  3687. {
  3688. mng_datap pData;
  3689. mng_chunkp pChunk;
  3690. mng_past_sourcep pEntry;
  3691. #ifdef MNG_SUPPORT_TRACE
  3692. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PAST_SRC, MNG_LC_START);
  3693. #endif
  3694. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  3695. pData = (mng_datap)hHandle; /* and make it addressable */
  3696. if (!pData->bCreating) /* aren't we creating a new file ? */
  3697. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  3698. /* must have had a MHDR first! */
  3699. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  3700. MNG_ERROR (pData, MNG_NOHEADER)
  3701. pChunk = pData->pLastchunk; /* last one must have been PAST ! */
  3702. if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_PAST)
  3703. MNG_ERROR (pData, MNG_NOCORRCHUNK)
  3704. /* index out of bounds ? */
  3705. if (iEntry >= ((mng_pastp)pChunk)->iCount)
  3706. MNG_ERROR (pData, MNG_INVALIDENTRYIX)
  3707. /* address proper entry */
  3708. pEntry = ((mng_pastp)pChunk)->pSources + iEntry;
  3709. pEntry->iSourceid = iSourceid; /* fill entry */
  3710. pEntry->iComposition = iComposition;
  3711. pEntry->iOrientation = iOrientation;
  3712. pEntry->iOffsettype = iOffsettype;
  3713. pEntry->iOffsetx = iOffsetx;
  3714. pEntry->iOffsety = iOffsety;
  3715. pEntry->iBoundarytype = iBoundarytype;
  3716. pEntry->iBoundaryl = iBoundaryl;
  3717. pEntry->iBoundaryr = iBoundaryr;
  3718. pEntry->iBoundaryt = iBoundaryt;
  3719. pEntry->iBoundaryb = iBoundaryb;
  3720. #ifdef MNG_SUPPORT_TRACE
  3721. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PAST_SRC, MNG_LC_END);
  3722. #endif
  3723. return MNG_NOERROR;
  3724. }
  3725. #endif
  3726. /* ************************************************************************** */
  3727. #ifndef MNG_SKIPCHUNK_DISC
  3728. mng_retcode MNG_DECL mng_putchunk_disc (mng_handle hHandle,
  3729. mng_uint32 iCount,
  3730. mng_uint16p pObjectids)
  3731. {
  3732. mng_datap pData;
  3733. mng_chunkp pChunk;
  3734. mng_retcode iRetcode;
  3735. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3736. mng_chunk_header sChunkheader =
  3737. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3738. {MNG_UINT_DISC, mng_init_general, mng_free_disc, mng_read_disc, mng_write_disc, mng_assign_disc, 0, 0, sizeof(mng_disc)};
  3739. #else
  3740. {MNG_UINT_DISC, mng_init_disc, mng_free_disc, mng_read_disc, mng_write_disc, mng_assign_disc, 0, 0};
  3741. #endif
  3742. #else
  3743. mng_chunk_header sChunkheader;
  3744. #endif
  3745. #ifdef MNG_SUPPORT_TRACE
  3746. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DISC, MNG_LC_START);
  3747. #endif
  3748. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  3749. pData = (mng_datap)hHandle; /* and make it addressable */
  3750. if (!pData->bCreating) /* aren't we creating a new file ? */
  3751. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  3752. /* must have had a MHDR first! */
  3753. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  3754. MNG_ERROR (pData, MNG_NOHEADER)
  3755. /* prevent misplaced TERM ! */
  3756. if (!check_term (pData, MNG_UINT_DISC))
  3757. MNG_ERROR (pData, MNG_TERMSEQERROR)
  3758. /* create the chunk */
  3759. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3760. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3761. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3762. #else
  3763. iRetcode = mng_init_disc (pData, &sChunkheader, &pChunk);
  3764. #endif
  3765. #else
  3766. mng_get_chunkheader(MNG_UINT_DISC, &sChunkheader);
  3767. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3768. #endif
  3769. if (iRetcode) /* on error bail out */
  3770. return iRetcode;
  3771. /* fill the chunk */
  3772. ((mng_discp)pChunk)->iCount = iCount;
  3773. if (iCount)
  3774. {
  3775. mng_uint32 iSize = iCount * sizeof (mng_uint32);
  3776. MNG_ALLOC (pData, ((mng_discp)pChunk)->pObjectids, iSize);
  3777. MNG_COPY (((mng_discp)pChunk)->pObjectids, pObjectids, iSize);
  3778. }
  3779. mng_add_chunk (pData, pChunk); /* add it to the list */
  3780. #ifdef MNG_SUPPORT_TRACE
  3781. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DISC, MNG_LC_END);
  3782. #endif
  3783. return MNG_NOERROR;
  3784. }
  3785. #endif
  3786. /* ************************************************************************** */
  3787. #ifndef MNG_SKIPCHUNK_BACK
  3788. mng_retcode MNG_DECL mng_putchunk_back (mng_handle hHandle,
  3789. mng_uint16 iRed,
  3790. mng_uint16 iGreen,
  3791. mng_uint16 iBlue,
  3792. mng_uint8 iMandatory,
  3793. mng_uint16 iImageid,
  3794. mng_uint8 iTile)
  3795. {
  3796. mng_datap pData;
  3797. mng_chunkp pChunk;
  3798. mng_retcode iRetcode;
  3799. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3800. mng_chunk_header sChunkheader =
  3801. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3802. {MNG_UINT_BACK, mng_init_general, mng_free_general, mng_read_back, mng_write_back, mng_assign_general, 0, 0, sizeof(mng_back)};
  3803. #else
  3804. {MNG_UINT_BACK, mng_init_back, mng_free_back, mng_read_back, mng_write_back, mng_assign_back, 0, 0};
  3805. #endif
  3806. #else
  3807. mng_chunk_header sChunkheader;
  3808. #endif
  3809. #ifdef MNG_SUPPORT_TRACE
  3810. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BACK, MNG_LC_START);
  3811. #endif
  3812. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  3813. pData = (mng_datap)hHandle; /* and make it addressable */
  3814. if (!pData->bCreating) /* aren't we creating a new file ? */
  3815. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  3816. /* must have had a MHDR first! */
  3817. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  3818. MNG_ERROR (pData, MNG_NOHEADER)
  3819. /* prevent misplaced TERM ! */
  3820. if (!check_term (pData, MNG_UINT_BACK))
  3821. MNG_ERROR (pData, MNG_TERMSEQERROR)
  3822. /* create the chunk */
  3823. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3824. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3825. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3826. #else
  3827. iRetcode = mng_init_back (pData, &sChunkheader, &pChunk);
  3828. #endif
  3829. #else
  3830. mng_get_chunkheader(MNG_UINT_BACK, &sChunkheader);
  3831. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3832. #endif
  3833. if (iRetcode) /* on error bail out */
  3834. return iRetcode;
  3835. /* fill the chunk */
  3836. ((mng_backp)pChunk)->iRed = iRed;
  3837. ((mng_backp)pChunk)->iGreen = iGreen;
  3838. ((mng_backp)pChunk)->iBlue = iBlue;
  3839. ((mng_backp)pChunk)->iMandatory = iMandatory;
  3840. ((mng_backp)pChunk)->iImageid = iImageid;
  3841. ((mng_backp)pChunk)->iTile = iTile;
  3842. mng_add_chunk (pData, pChunk); /* add it to the list */
  3843. #ifdef MNG_SUPPORT_TRACE
  3844. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BACK, MNG_LC_END);
  3845. #endif
  3846. return MNG_NOERROR;
  3847. }
  3848. #endif
  3849. /* ************************************************************************** */
  3850. #ifndef MNG_SKIPCHUNK_FRAM
  3851. mng_retcode MNG_DECL mng_putchunk_fram (mng_handle hHandle,
  3852. mng_bool bEmpty,
  3853. mng_uint8 iMode,
  3854. mng_uint32 iNamesize,
  3855. mng_pchar zName,
  3856. mng_uint8 iChangedelay,
  3857. mng_uint8 iChangetimeout,
  3858. mng_uint8 iChangeclipping,
  3859. mng_uint8 iChangesyncid,
  3860. mng_uint32 iDelay,
  3861. mng_uint32 iTimeout,
  3862. mng_uint8 iBoundarytype,
  3863. mng_int32 iBoundaryl,
  3864. mng_int32 iBoundaryr,
  3865. mng_int32 iBoundaryt,
  3866. mng_int32 iBoundaryb,
  3867. mng_uint32 iCount,
  3868. mng_uint32p pSyncids)
  3869. {
  3870. mng_datap pData;
  3871. mng_chunkp pChunk;
  3872. mng_retcode iRetcode;
  3873. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3874. mng_chunk_header sChunkheader =
  3875. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3876. {MNG_UINT_FRAM, mng_init_general, mng_free_fram, mng_read_fram, mng_write_fram, mng_assign_fram, 0, 0, sizeof(mng_fram)};
  3877. #else
  3878. {MNG_UINT_FRAM, mng_init_fram, mng_free_fram, mng_read_fram, mng_write_fram, mng_assign_fram, 0, 0};
  3879. #endif
  3880. #else
  3881. mng_chunk_header sChunkheader;
  3882. #endif
  3883. #ifdef MNG_SUPPORT_TRACE
  3884. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_FRAM, MNG_LC_START);
  3885. #endif
  3886. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  3887. pData = (mng_datap)hHandle; /* and make it addressable */
  3888. if (!pData->bCreating) /* aren't we creating a new file ? */
  3889. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  3890. /* must have had a MHDR first! */
  3891. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  3892. MNG_ERROR (pData, MNG_NOHEADER)
  3893. /* prevent misplaced TERM ! */
  3894. if (!check_term (pData, MNG_UINT_FRAM))
  3895. MNG_ERROR (pData, MNG_TERMSEQERROR)
  3896. /* create the chunk */
  3897. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3898. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3899. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3900. #else
  3901. iRetcode = mng_init_fram (pData, &sChunkheader, &pChunk);
  3902. #endif
  3903. #else
  3904. mng_get_chunkheader(MNG_UINT_FRAM, &sChunkheader);
  3905. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3906. #endif
  3907. if (iRetcode) /* on error bail out */
  3908. return iRetcode;
  3909. /* fill the chunk */
  3910. ((mng_framp)pChunk)->bEmpty = bEmpty;
  3911. ((mng_framp)pChunk)->iMode = iMode;
  3912. ((mng_framp)pChunk)->iNamesize = iNamesize;
  3913. ((mng_framp)pChunk)->iChangedelay = iChangedelay;
  3914. ((mng_framp)pChunk)->iChangetimeout = iChangetimeout;
  3915. ((mng_framp)pChunk)->iChangeclipping = iChangeclipping;
  3916. ((mng_framp)pChunk)->iChangesyncid = iChangesyncid;
  3917. ((mng_framp)pChunk)->iDelay = iDelay;
  3918. ((mng_framp)pChunk)->iTimeout = iTimeout;
  3919. ((mng_framp)pChunk)->iBoundarytype = iBoundarytype;
  3920. ((mng_framp)pChunk)->iBoundaryl = iBoundaryl;
  3921. ((mng_framp)pChunk)->iBoundaryr = iBoundaryr;
  3922. ((mng_framp)pChunk)->iBoundaryt = iBoundaryt;
  3923. ((mng_framp)pChunk)->iBoundaryb = iBoundaryb;
  3924. ((mng_framp)pChunk)->iCount = iCount;
  3925. if (iNamesize)
  3926. {
  3927. MNG_ALLOC (pData, ((mng_framp)pChunk)->zName, iNamesize + 1);
  3928. MNG_COPY (((mng_framp)pChunk)->zName, zName, iNamesize);
  3929. }
  3930. if (iCount)
  3931. {
  3932. mng_uint32 iSize = iCount * sizeof (mng_uint32);
  3933. MNG_ALLOC (pData, ((mng_framp)pChunk)->pSyncids, iSize);
  3934. MNG_COPY (((mng_framp)pChunk)->pSyncids, pSyncids, iSize);
  3935. }
  3936. mng_add_chunk (pData, pChunk); /* add it to the list */
  3937. #ifdef MNG_SUPPORT_TRACE
  3938. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_FRAM, MNG_LC_END);
  3939. #endif
  3940. return MNG_NOERROR;
  3941. }
  3942. #endif
  3943. /* ************************************************************************** */
  3944. #ifndef MNG_SKIPCHUNK_MOVE
  3945. mng_retcode MNG_DECL mng_putchunk_move (mng_handle hHandle,
  3946. mng_uint16 iFirstid,
  3947. mng_uint16 iLastid,
  3948. mng_uint8 iMovetype,
  3949. mng_int32 iMovex,
  3950. mng_int32 iMovey)
  3951. {
  3952. mng_datap pData;
  3953. mng_chunkp pChunk;
  3954. mng_retcode iRetcode;
  3955. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3956. mng_chunk_header sChunkheader =
  3957. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3958. {MNG_UINT_MOVE, mng_init_general, mng_free_general, mng_read_move, mng_write_move, mng_assign_general, 0, 0, sizeof(mng_move)};
  3959. #else
  3960. {MNG_UINT_MOVE, mng_init_move, mng_free_move, mng_read_move, mng_write_move, mng_assign_move, 0, 0};
  3961. #endif
  3962. #else
  3963. mng_chunk_header sChunkheader;
  3964. #endif
  3965. #ifdef MNG_SUPPORT_TRACE
  3966. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MOVE, MNG_LC_START);
  3967. #endif
  3968. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  3969. pData = (mng_datap)hHandle; /* and make it addressable */
  3970. if (!pData->bCreating) /* aren't we creating a new file ? */
  3971. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  3972. /* must have had a MHDR first! */
  3973. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  3974. MNG_ERROR (pData, MNG_NOHEADER)
  3975. /* prevent misplaced TERM ! */
  3976. if (!check_term (pData, MNG_UINT_MOVE))
  3977. MNG_ERROR (pData, MNG_TERMSEQERROR)
  3978. /* create the chunk */
  3979. #ifndef MNG_OPTIMIZE_CHUNKREADER
  3980. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  3981. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3982. #else
  3983. iRetcode = mng_init_move (pData, &sChunkheader, &pChunk);
  3984. #endif
  3985. #else
  3986. mng_get_chunkheader(MNG_UINT_MOVE, &sChunkheader);
  3987. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  3988. #endif
  3989. if (iRetcode) /* on error bail out */
  3990. return iRetcode;
  3991. /* fill the chunk */
  3992. ((mng_movep)pChunk)->iFirstid = iFirstid;
  3993. ((mng_movep)pChunk)->iLastid = iLastid;
  3994. ((mng_movep)pChunk)->iMovetype = iMovetype;
  3995. ((mng_movep)pChunk)->iMovex = iMovex;
  3996. ((mng_movep)pChunk)->iMovey = iMovey;
  3997. mng_add_chunk (pData, pChunk); /* add it to the list */
  3998. #ifdef MNG_SUPPORT_TRACE
  3999. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MOVE, MNG_LC_END);
  4000. #endif
  4001. return MNG_NOERROR;
  4002. }
  4003. #endif
  4004. /* ************************************************************************** */
  4005. #ifndef MNG_SKIPCHUNK_CLIP
  4006. mng_retcode MNG_DECL mng_putchunk_clip (mng_handle hHandle,
  4007. mng_uint16 iFirstid,
  4008. mng_uint16 iLastid,
  4009. mng_uint8 iCliptype,
  4010. mng_int32 iClipl,
  4011. mng_int32 iClipr,
  4012. mng_int32 iClipt,
  4013. mng_int32 iClipb)
  4014. {
  4015. mng_datap pData;
  4016. mng_chunkp pChunk;
  4017. mng_retcode iRetcode;
  4018. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4019. mng_chunk_header sChunkheader =
  4020. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4021. {MNG_UINT_CLIP, mng_init_general, mng_free_general, mng_read_clip, mng_write_clip, mng_assign_general, 0, 0, sizeof(mng_clip)};
  4022. #else
  4023. {MNG_UINT_CLIP, mng_init_clip, mng_free_clip, mng_read_clip, mng_write_clip, mng_assign_clip, 0, 0};
  4024. #endif
  4025. #else
  4026. mng_chunk_header sChunkheader;
  4027. #endif
  4028. #ifdef MNG_SUPPORT_TRACE
  4029. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CLIP, MNG_LC_START);
  4030. #endif
  4031. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  4032. pData = (mng_datap)hHandle; /* and make it addressable */
  4033. if (!pData->bCreating) /* aren't we creating a new file ? */
  4034. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  4035. /* must have had a MHDR first! */
  4036. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  4037. MNG_ERROR (pData, MNG_NOHEADER)
  4038. /* prevent misplaced TERM ! */
  4039. if (!check_term (pData, MNG_UINT_CLIP))
  4040. MNG_ERROR (pData, MNG_TERMSEQERROR)
  4041. /* create the chunk */
  4042. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4043. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4044. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4045. #else
  4046. iRetcode = mng_init_clip (pData, &sChunkheader, &pChunk);
  4047. #endif
  4048. #else
  4049. mng_get_chunkheader(MNG_UINT_CLIP, &sChunkheader);
  4050. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4051. #endif
  4052. if (iRetcode) /* on error bail out */
  4053. return iRetcode;
  4054. /* fill the chunk */
  4055. ((mng_clipp)pChunk)->iFirstid = iFirstid;
  4056. ((mng_clipp)pChunk)->iLastid = iLastid;
  4057. ((mng_clipp)pChunk)->iCliptype = iCliptype;
  4058. ((mng_clipp)pChunk)->iClipl = iClipl;
  4059. ((mng_clipp)pChunk)->iClipr = iClipr;
  4060. ((mng_clipp)pChunk)->iClipt = iClipt;
  4061. ((mng_clipp)pChunk)->iClipb = iClipb;
  4062. mng_add_chunk (pData, pChunk); /* add it to the list */
  4063. #ifdef MNG_SUPPORT_TRACE
  4064. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CLIP, MNG_LC_END);
  4065. #endif
  4066. return MNG_NOERROR;
  4067. }
  4068. #endif
  4069. /* ************************************************************************** */
  4070. #ifndef MNG_SKIPCHUNK_SHOW
  4071. mng_retcode MNG_DECL mng_putchunk_show (mng_handle hHandle,
  4072. mng_bool bEmpty,
  4073. mng_uint16 iFirstid,
  4074. mng_uint16 iLastid,
  4075. mng_uint8 iMode)
  4076. {
  4077. mng_datap pData;
  4078. mng_chunkp pChunk;
  4079. mng_retcode iRetcode;
  4080. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4081. mng_chunk_header sChunkheader =
  4082. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4083. {MNG_UINT_SHOW, mng_init_general, mng_free_general, mng_read_show, mng_write_show, mng_assign_general, 0, 0, sizeof(mng_show)};
  4084. #else
  4085. {MNG_UINT_SHOW, mng_init_show, mng_free_show, mng_read_show, mng_write_show, mng_assign_show, 0, 0};
  4086. #endif
  4087. #else
  4088. mng_chunk_header sChunkheader;
  4089. #endif
  4090. #ifdef MNG_SUPPORT_TRACE
  4091. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SHOW, MNG_LC_START);
  4092. #endif
  4093. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  4094. pData = (mng_datap)hHandle; /* and make it addressable */
  4095. if (!pData->bCreating) /* aren't we creating a new file ? */
  4096. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  4097. /* must have had a MHDR first! */
  4098. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  4099. MNG_ERROR (pData, MNG_NOHEADER)
  4100. /* prevent misplaced TERM ! */
  4101. if (!check_term (pData, MNG_UINT_SHOW))
  4102. MNG_ERROR (pData, MNG_TERMSEQERROR)
  4103. /* create the chunk */
  4104. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4105. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4106. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4107. #else
  4108. iRetcode = mng_init_show (pData, &sChunkheader, &pChunk);
  4109. #endif
  4110. #else
  4111. mng_get_chunkheader(MNG_UINT_SHOW, &sChunkheader);
  4112. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4113. #endif
  4114. if (iRetcode) /* on error bail out */
  4115. return iRetcode;
  4116. /* fill the chunk */
  4117. ((mng_showp)pChunk)->bEmpty = bEmpty;
  4118. ((mng_showp)pChunk)->iFirstid = iFirstid;
  4119. ((mng_showp)pChunk)->iLastid = iLastid;
  4120. ((mng_showp)pChunk)->iMode = iMode;
  4121. mng_add_chunk (pData, pChunk); /* add it to the list */
  4122. #ifdef MNG_SUPPORT_TRACE
  4123. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SHOW, MNG_LC_END);
  4124. #endif
  4125. return MNG_NOERROR;
  4126. }
  4127. #endif
  4128. /* ************************************************************************** */
  4129. #ifndef MNG_SKIPCHUNK_TERM
  4130. mng_retcode MNG_DECL mng_putchunk_term (mng_handle hHandle,
  4131. mng_uint8 iTermaction,
  4132. mng_uint8 iIteraction,
  4133. mng_uint32 iDelay,
  4134. mng_uint32 iItermax)
  4135. {
  4136. mng_datap pData;
  4137. mng_chunkp pChunk;
  4138. mng_retcode iRetcode;
  4139. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4140. mng_chunk_header sChunkheader =
  4141. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4142. {MNG_UINT_TERM, mng_init_general, mng_free_general, mng_read_term, mng_write_term, mng_assign_general, 0, 0, sizeof(mng_term)};
  4143. #else
  4144. {MNG_UINT_TERM, mng_init_term, mng_free_term, mng_read_term, mng_write_term, mng_assign_term, 0, 0};
  4145. #endif
  4146. #else
  4147. mng_chunk_header sChunkheader;
  4148. #endif
  4149. #ifdef MNG_SUPPORT_TRACE
  4150. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TERM, MNG_LC_START);
  4151. #endif
  4152. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  4153. pData = (mng_datap)hHandle; /* and make it addressable */
  4154. if (!pData->bCreating) /* aren't we creating a new file ? */
  4155. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  4156. /* must have had a MHDR first! */
  4157. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  4158. MNG_ERROR (pData, MNG_NOHEADER)
  4159. /* create the chunk */
  4160. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4161. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4162. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4163. #else
  4164. iRetcode = mng_init_term (pData, &sChunkheader, &pChunk);
  4165. #endif
  4166. #else
  4167. mng_get_chunkheader(MNG_UINT_TERM, &sChunkheader);
  4168. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4169. #endif
  4170. if (iRetcode) /* on error bail out */
  4171. return iRetcode;
  4172. /* fill the chunk */
  4173. ((mng_termp)pChunk)->iTermaction = iTermaction;
  4174. ((mng_termp)pChunk)->iIteraction = iIteraction;
  4175. ((mng_termp)pChunk)->iDelay = iDelay;
  4176. ((mng_termp)pChunk)->iItermax = iItermax;
  4177. mng_add_chunk (pData, pChunk); /* add it to the list */
  4178. #ifdef MNG_SUPPORT_TRACE
  4179. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TERM, MNG_LC_END);
  4180. #endif
  4181. return MNG_NOERROR;
  4182. }
  4183. #endif
  4184. /* ************************************************************************** */
  4185. #ifndef MNG_SKIPCHUNK_SAVE
  4186. mng_retcode MNG_DECL mng_putchunk_save (mng_handle hHandle,
  4187. mng_bool bEmpty,
  4188. mng_uint8 iOffsettype,
  4189. mng_uint32 iCount)
  4190. {
  4191. mng_datap pData;
  4192. mng_chunkp pChunk;
  4193. mng_retcode iRetcode;
  4194. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4195. mng_chunk_header sChunkheader =
  4196. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4197. {MNG_UINT_SAVE, mng_init_general, mng_free_save, mng_read_save, mng_write_save, mng_assign_save, 0, 0, sizeof(mng_save)};
  4198. #else
  4199. {MNG_UINT_SAVE, mng_init_save, mng_free_save, mng_read_save, mng_write_save, mng_assign_save, 0, 0};
  4200. #endif
  4201. #else
  4202. mng_chunk_header sChunkheader;
  4203. #endif
  4204. #ifdef MNG_SUPPORT_TRACE
  4205. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SAVE, MNG_LC_START);
  4206. #endif
  4207. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  4208. pData = (mng_datap)hHandle; /* and make it addressable */
  4209. if (!pData->bCreating) /* aren't we creating a new file ? */
  4210. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  4211. /* must have had a MHDR first! */
  4212. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  4213. MNG_ERROR (pData, MNG_NOHEADER)
  4214. /* prevent misplaced TERM ! */
  4215. if (!check_term (pData, MNG_UINT_SAVE))
  4216. MNG_ERROR (pData, MNG_TERMSEQERROR)
  4217. /* create the chunk */
  4218. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4219. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4220. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4221. #else
  4222. iRetcode = mng_init_save (pData, &sChunkheader, &pChunk);
  4223. #endif
  4224. #else
  4225. mng_get_chunkheader(MNG_UINT_SAVE, &sChunkheader);
  4226. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4227. #endif
  4228. if (iRetcode) /* on error bail out */
  4229. return iRetcode;
  4230. /* fill the chunk */
  4231. ((mng_savep)pChunk)->bEmpty = bEmpty;
  4232. ((mng_savep)pChunk)->iOffsettype = iOffsettype;
  4233. ((mng_savep)pChunk)->iCount = iCount;
  4234. if (iCount)
  4235. MNG_ALLOC (pData, ((mng_savep)pChunk)->pEntries, iCount * sizeof (mng_save_entry));
  4236. mng_add_chunk (pData, pChunk); /* add it to the list */
  4237. #ifdef MNG_SUPPORT_TRACE
  4238. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SAVE, MNG_LC_END);
  4239. #endif
  4240. return MNG_NOERROR;
  4241. }
  4242. /* ************************************************************************** */
  4243. mng_retcode MNG_DECL mng_putchunk_save_entry (mng_handle hHandle,
  4244. mng_uint32 iEntry,
  4245. mng_uint8 iEntrytype,
  4246. mng_uint32arr2 iOffset,
  4247. mng_uint32arr2 iStarttime,
  4248. mng_uint32 iLayernr,
  4249. mng_uint32 iFramenr,
  4250. mng_uint32 iNamesize,
  4251. mng_pchar zName)
  4252. {
  4253. mng_datap pData;
  4254. mng_chunkp pChunk;
  4255. mng_save_entryp pEntry;
  4256. #ifdef MNG_SUPPORT_TRACE
  4257. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SAVE_ENTRY, MNG_LC_START);
  4258. #endif
  4259. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  4260. pData = (mng_datap)hHandle; /* and make it addressable */
  4261. if (!pData->bCreating) /* aren't we creating a new file ? */
  4262. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  4263. /* must have had a MHDR first! */
  4264. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  4265. MNG_ERROR (pData, MNG_NOHEADER)
  4266. pChunk = pData->pLastchunk; /* last one must have been SAVE ! */
  4267. if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_SAVE)
  4268. MNG_ERROR (pData, MNG_NOCORRCHUNK)
  4269. /* index out of bounds ? */
  4270. if (iEntry >= ((mng_savep)pChunk)->iCount)
  4271. MNG_ERROR (pData, MNG_INVALIDENTRYIX)
  4272. /* address proper entry */
  4273. pEntry = ((mng_savep)pChunk)->pEntries + iEntry;
  4274. pEntry->iEntrytype = iEntrytype; /* fill entry */
  4275. pEntry->iOffset[0] = iOffset[0];
  4276. pEntry->iOffset[1] = iOffset[1];
  4277. pEntry->iStarttime[0] = iStarttime[0];
  4278. pEntry->iStarttime[1] = iStarttime[1];
  4279. pEntry->iLayernr = iLayernr;
  4280. pEntry->iFramenr = iFramenr;
  4281. pEntry->iNamesize = iNamesize;
  4282. if (iNamesize)
  4283. {
  4284. MNG_ALLOC (pData, pEntry->zName, iNamesize + 1);
  4285. MNG_COPY (pEntry->zName, zName, iNamesize);
  4286. }
  4287. #ifdef MNG_SUPPORT_TRACE
  4288. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SAVE_ENTRY, MNG_LC_END);
  4289. #endif
  4290. return MNG_NOERROR;
  4291. }
  4292. #endif
  4293. /* ************************************************************************** */
  4294. #ifndef MNG_SKIPCHUNK_SEEK
  4295. mng_retcode MNG_DECL mng_putchunk_seek (mng_handle hHandle,
  4296. mng_uint32 iNamesize,
  4297. mng_pchar zName)
  4298. {
  4299. mng_datap pData;
  4300. mng_chunkp pChunk;
  4301. mng_retcode iRetcode;
  4302. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4303. mng_chunk_header sChunkheader =
  4304. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4305. {MNG_UINT_SEEK, mng_init_general, mng_free_seek, mng_read_seek, mng_write_seek, mng_assign_seek, 0, 0, sizeof(mng_seek)};
  4306. #else
  4307. {MNG_UINT_SEEK, mng_init_seek, mng_free_seek, mng_read_seek, mng_write_seek, mng_assign_seek, 0, 0};
  4308. #endif
  4309. #else
  4310. mng_chunk_header sChunkheader;
  4311. #endif
  4312. #ifdef MNG_SUPPORT_TRACE
  4313. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SEEK, MNG_LC_START);
  4314. #endif
  4315. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  4316. pData = (mng_datap)hHandle; /* and make it addressable */
  4317. if (!pData->bCreating) /* aren't we creating a new file ? */
  4318. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  4319. /* must have had a MHDR first! */
  4320. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  4321. MNG_ERROR (pData, MNG_NOHEADER)
  4322. /* prevent misplaced TERM ! */
  4323. if (!check_term (pData, MNG_UINT_SEEK))
  4324. MNG_ERROR (pData, MNG_TERMSEQERROR)
  4325. /* create the chunk */
  4326. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4327. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4328. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4329. #else
  4330. iRetcode = mng_init_seek (pData, &sChunkheader, &pChunk);
  4331. #endif
  4332. #else
  4333. mng_get_chunkheader(MNG_UINT_SEEK, &sChunkheader);
  4334. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4335. #endif
  4336. if (iRetcode) /* on error bail out */
  4337. return iRetcode;
  4338. /* fill the chunk */
  4339. ((mng_seekp)pChunk)->iNamesize = iNamesize;
  4340. if (iNamesize)
  4341. {
  4342. MNG_ALLOC (pData, ((mng_seekp)pChunk)->zName, iNamesize + 1);
  4343. MNG_COPY (((mng_seekp)pChunk)->zName, zName, iNamesize);
  4344. }
  4345. mng_add_chunk (pData, pChunk); /* add it to the list */
  4346. #ifdef MNG_SUPPORT_TRACE
  4347. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SEEK, MNG_LC_END);
  4348. #endif
  4349. return MNG_NOERROR;
  4350. }
  4351. #endif
  4352. /* ************************************************************************** */
  4353. #ifndef MNG_SKIPCHUNK_eXPI
  4354. mng_retcode MNG_DECL mng_putchunk_expi (mng_handle hHandle,
  4355. mng_uint16 iSnapshotid,
  4356. mng_uint32 iNamesize,
  4357. mng_pchar zName)
  4358. {
  4359. mng_datap pData;
  4360. mng_chunkp pChunk;
  4361. mng_retcode iRetcode;
  4362. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4363. mng_chunk_header sChunkheader =
  4364. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4365. {MNG_UINT_eXPI, mng_init_general, mng_free_expi, mng_read_expi, mng_write_expi, mng_assign_general, 0, 0, sizeof(mng_expi)};
  4366. #else
  4367. {MNG_UINT_eXPI, mng_init_expi, mng_free_expi, mng_read_expi, mng_write_expi, mng_assign_expi, 0, 0};
  4368. #endif
  4369. #else
  4370. mng_chunk_header sChunkheader;
  4371. #endif
  4372. #ifdef MNG_SUPPORT_TRACE
  4373. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_EXPI, MNG_LC_START);
  4374. #endif
  4375. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  4376. pData = (mng_datap)hHandle; /* and make it addressable */
  4377. if (!pData->bCreating) /* aren't we creating a new file ? */
  4378. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  4379. /* must have had a MHDR first! */
  4380. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  4381. MNG_ERROR (pData, MNG_NOHEADER)
  4382. /* prevent misplaced TERM ! */
  4383. if (!check_term (pData, MNG_UINT_eXPI))
  4384. MNG_ERROR (pData, MNG_TERMSEQERROR)
  4385. /* create the chunk */
  4386. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4387. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4388. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4389. #else
  4390. iRetcode = mng_init_expi (pData, &sChunkheader, &pChunk);
  4391. #endif
  4392. #else
  4393. mng_get_chunkheader(MNG_UINT_eXPI, &sChunkheader);
  4394. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4395. #endif
  4396. if (iRetcode) /* on error bail out */
  4397. return iRetcode;
  4398. /* fill the chunk */
  4399. ((mng_expip)pChunk)->iSnapshotid = iSnapshotid;
  4400. ((mng_expip)pChunk)->iNamesize = iNamesize;
  4401. if (iNamesize)
  4402. {
  4403. MNG_ALLOC (pData, ((mng_expip)pChunk)->zName, iNamesize + 1);
  4404. MNG_COPY (((mng_expip)pChunk)->zName, zName, iNamesize);
  4405. }
  4406. mng_add_chunk (pData, pChunk); /* add it to the list */
  4407. #ifdef MNG_SUPPORT_TRACE
  4408. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_EXPI, MNG_LC_END);
  4409. #endif
  4410. return MNG_NOERROR;
  4411. }
  4412. #endif
  4413. /* ************************************************************************** */
  4414. #ifndef MNG_SKIPCHUNK_fPRI
  4415. mng_retcode MNG_DECL mng_putchunk_fpri (mng_handle hHandle,
  4416. mng_uint8 iDeltatype,
  4417. mng_uint8 iPriority)
  4418. {
  4419. mng_datap pData;
  4420. mng_chunkp pChunk;
  4421. mng_retcode iRetcode;
  4422. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4423. mng_chunk_header sChunkheader =
  4424. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4425. {MNG_UINT_fPRI, mng_init_general, mng_free_general, mng_read_fpri, mng_write_fpri, mng_assign_general, 0, 0, sizeof(mng_fpri)};
  4426. #else
  4427. {MNG_UINT_fPRI, mng_init_fpri, mng_free_fpri, mng_read_fpri, mng_write_fpri, mng_assign_fpri, 0, 0};
  4428. #endif
  4429. #else
  4430. mng_chunk_header sChunkheader;
  4431. #endif
  4432. #ifdef MNG_SUPPORT_TRACE
  4433. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_FPRI, MNG_LC_START);
  4434. #endif
  4435. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  4436. pData = (mng_datap)hHandle; /* and make it addressable */
  4437. if (!pData->bCreating) /* aren't we creating a new file ? */
  4438. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  4439. /* must have had a MHDR first! */
  4440. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  4441. MNG_ERROR (pData, MNG_NOHEADER)
  4442. /* prevent misplaced TERM ! */
  4443. if (!check_term (pData, MNG_UINT_fPRI))
  4444. MNG_ERROR (pData, MNG_TERMSEQERROR)
  4445. /* create the chunk */
  4446. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4447. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4448. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4449. #else
  4450. iRetcode = mng_init_fpri (pData, &sChunkheader, &pChunk);
  4451. #endif
  4452. #else
  4453. mng_get_chunkheader(MNG_UINT_fPRI, &sChunkheader);
  4454. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4455. #endif
  4456. if (iRetcode) /* on error bail out */
  4457. return iRetcode;
  4458. /* fill the chunk */
  4459. ((mng_fprip)pChunk)->iDeltatype = iDeltatype;
  4460. ((mng_fprip)pChunk)->iPriority = iPriority;
  4461. mng_add_chunk (pData, pChunk); /* add it to the list */
  4462. #ifdef MNG_SUPPORT_TRACE
  4463. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_FPRI, MNG_LC_END);
  4464. #endif
  4465. return MNG_NOERROR;
  4466. }
  4467. #endif
  4468. /* ************************************************************************** */
  4469. #ifndef MNG_SKIPCHUNK_nEED
  4470. mng_retcode MNG_DECL mng_putchunk_need (mng_handle hHandle,
  4471. mng_uint32 iKeywordssize,
  4472. mng_pchar zKeywords)
  4473. {
  4474. mng_datap pData;
  4475. mng_chunkp pChunk;
  4476. mng_retcode iRetcode;
  4477. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4478. mng_chunk_header sChunkheader =
  4479. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4480. {MNG_UINT_nEED, mng_init_general, mng_free_need, mng_read_need, mng_write_need, mng_assign_need, 0, 0, sizeof(mng_need)};
  4481. #else
  4482. {MNG_UINT_nEED, mng_init_need, mng_free_need, mng_read_need, mng_write_need, mng_assign_need, 0, 0};
  4483. #endif
  4484. #else
  4485. mng_chunk_header sChunkheader;
  4486. #endif
  4487. #ifdef MNG_SUPPORT_TRACE
  4488. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_NEED, MNG_LC_START);
  4489. #endif
  4490. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  4491. pData = (mng_datap)hHandle; /* and make it addressable */
  4492. if (!pData->bCreating) /* aren't we creating a new file ? */
  4493. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  4494. /* must have had a MHDR first! */
  4495. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  4496. MNG_ERROR (pData, MNG_NOHEADER)
  4497. /* prevent misplaced TERM ! */
  4498. if (!check_term (pData, MNG_UINT_nEED))
  4499. MNG_ERROR (pData, MNG_TERMSEQERROR)
  4500. /* create the chunk */
  4501. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4502. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4503. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4504. #else
  4505. iRetcode = mng_init_need (pData, &sChunkheader, &pChunk);
  4506. #endif
  4507. #else
  4508. mng_get_chunkheader(MNG_UINT_nEED, &sChunkheader);
  4509. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4510. #endif
  4511. if (iRetcode) /* on error bail out */
  4512. return iRetcode;
  4513. /* fill the chunk */
  4514. ((mng_needp)pChunk)->iKeywordssize = iKeywordssize;
  4515. if (iKeywordssize)
  4516. {
  4517. MNG_ALLOC (pData, ((mng_needp)pChunk)->zKeywords, iKeywordssize + 1);
  4518. MNG_COPY (((mng_needp)pChunk)->zKeywords, zKeywords, iKeywordssize);
  4519. }
  4520. mng_add_chunk (pData, pChunk); /* add it to the list */
  4521. #ifdef MNG_SUPPORT_TRACE
  4522. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_NEED, MNG_LC_END);
  4523. #endif
  4524. return MNG_NOERROR;
  4525. }
  4526. #endif
  4527. /* ************************************************************************** */
  4528. #ifndef MNG_SKIPCHUNK_pHYg
  4529. mng_retcode MNG_DECL mng_putchunk_phyg (mng_handle hHandle,
  4530. mng_bool bEmpty,
  4531. mng_uint32 iSizex,
  4532. mng_uint32 iSizey,
  4533. mng_uint8 iUnit)
  4534. {
  4535. mng_datap pData;
  4536. mng_chunkp pChunk;
  4537. mng_retcode iRetcode;
  4538. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4539. mng_chunk_header sChunkheader =
  4540. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4541. {MNG_UINT_pHYg, mng_init_general, mng_free_general, mng_read_phyg, mng_write_phyg, mng_assign_general, 0, 0, sizeof(mng_phyg)};
  4542. #else
  4543. {MNG_UINT_pHYg, mng_init_phyg, mng_free_phyg, mng_read_phyg, mng_write_phyg, mng_assign_phyg, 0, 0};
  4544. #endif
  4545. #else
  4546. mng_chunk_header sChunkheader;
  4547. #endif
  4548. #ifdef MNG_SUPPORT_TRACE
  4549. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PHYG, MNG_LC_START);
  4550. #endif
  4551. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  4552. pData = (mng_datap)hHandle; /* and make it addressable */
  4553. if (!pData->bCreating) /* aren't we creating a new file ? */
  4554. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  4555. /* must have had a MHDR first! */
  4556. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  4557. MNG_ERROR (pData, MNG_NOHEADER)
  4558. /* prevent misplaced TERM ! */
  4559. if (!check_term (pData, MNG_UINT_pHYg))
  4560. MNG_ERROR (pData, MNG_TERMSEQERROR)
  4561. /* create the chunk */
  4562. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4563. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4564. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4565. #else
  4566. iRetcode = mng_init_phyg (pData, &sChunkheader, &pChunk);
  4567. #endif
  4568. #else
  4569. mng_get_chunkheader(MNG_UINT_pHYg, &sChunkheader);
  4570. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4571. #endif
  4572. if (iRetcode) /* on error bail out */
  4573. return iRetcode;
  4574. /* fill the chunk */
  4575. ((mng_phygp)pChunk)->bEmpty = bEmpty;
  4576. ((mng_phygp)pChunk)->iSizex = iSizex;
  4577. ((mng_phygp)pChunk)->iSizey = iSizey;
  4578. ((mng_phygp)pChunk)->iUnit = iUnit;
  4579. mng_add_chunk (pData, pChunk); /* add it to the list */
  4580. #ifdef MNG_SUPPORT_TRACE
  4581. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PHYG, MNG_LC_END);
  4582. #endif
  4583. return MNG_NOERROR;
  4584. }
  4585. #endif
  4586. /* ************************************************************************** */
  4587. #ifdef MNG_INCLUDE_JNG
  4588. mng_retcode MNG_DECL mng_putchunk_jhdr (mng_handle hHandle,
  4589. mng_uint32 iWidth,
  4590. mng_uint32 iHeight,
  4591. mng_uint8 iColortype,
  4592. mng_uint8 iImagesampledepth,
  4593. mng_uint8 iImagecompression,
  4594. mng_uint8 iImageinterlace,
  4595. mng_uint8 iAlphasampledepth,
  4596. mng_uint8 iAlphacompression,
  4597. mng_uint8 iAlphafilter,
  4598. mng_uint8 iAlphainterlace)
  4599. {
  4600. mng_datap pData;
  4601. mng_chunkp pChunk;
  4602. mng_retcode iRetcode;
  4603. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4604. mng_chunk_header sChunkheader =
  4605. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4606. {MNG_UINT_JHDR, mng_init_general, mng_free_general, mng_read_jhdr, mng_write_jhdr, mng_assign_general, 0, 0, sizeof(mng_jhdr)};
  4607. #else
  4608. {MNG_UINT_JHDR, mng_init_jhdr, mng_free_jhdr, mng_read_jhdr, mng_write_jhdr, mng_assign_jhdr, 0, 0};
  4609. #endif
  4610. #else
  4611. mng_chunk_header sChunkheader;
  4612. #endif
  4613. #ifdef MNG_SUPPORT_TRACE
  4614. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JHDR, MNG_LC_START);
  4615. #endif
  4616. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  4617. pData = (mng_datap)hHandle; /* and make it addressable */
  4618. if (!pData->bCreating) /* aren't we creating a new file ? */
  4619. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  4620. /* prevent misplaced TERM ! */
  4621. if (!check_term (pData, MNG_UINT_JHDR))
  4622. MNG_ERROR (pData, MNG_TERMSEQERROR)
  4623. /* create the chunk */
  4624. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4625. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4626. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4627. #else
  4628. iRetcode = mng_init_jhdr (pData, &sChunkheader, &pChunk);
  4629. #endif
  4630. #else
  4631. mng_get_chunkheader(MNG_UINT_JHDR, &sChunkheader);
  4632. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4633. #endif
  4634. if (iRetcode) /* on error bail out */
  4635. return iRetcode;
  4636. /* fill the chunk */
  4637. ((mng_jhdrp)pChunk)->iWidth = iWidth;
  4638. ((mng_jhdrp)pChunk)->iHeight = iHeight;
  4639. ((mng_jhdrp)pChunk)->iColortype = iColortype;
  4640. ((mng_jhdrp)pChunk)->iImagesampledepth = iImagesampledepth;
  4641. ((mng_jhdrp)pChunk)->iImagecompression = iImagecompression;
  4642. ((mng_jhdrp)pChunk)->iImageinterlace = iImageinterlace;
  4643. ((mng_jhdrp)pChunk)->iAlphasampledepth = iAlphasampledepth;
  4644. ((mng_jhdrp)pChunk)->iAlphacompression = iAlphacompression;
  4645. ((mng_jhdrp)pChunk)->iAlphafilter = iAlphafilter;
  4646. ((mng_jhdrp)pChunk)->iAlphainterlace = iAlphainterlace;
  4647. mng_add_chunk (pData, pChunk); /* add it to the list */
  4648. #ifdef MNG_SUPPORT_TRACE
  4649. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JHDR, MNG_LC_END);
  4650. #endif
  4651. return MNG_NOERROR;
  4652. }
  4653. #endif /* MNG_INCLUDE_JNG */
  4654. /* ************************************************************************** */
  4655. #ifdef MNG_INCLUDE_JNG
  4656. mng_retcode MNG_DECL mng_putchunk_jdat (mng_handle hHandle,
  4657. mng_uint32 iRawlen,
  4658. mng_ptr pRawdata)
  4659. {
  4660. mng_datap pData;
  4661. mng_chunkp pChunk;
  4662. mng_retcode iRetcode;
  4663. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4664. mng_chunk_header sChunkheader =
  4665. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4666. {MNG_UINT_JDAT, mng_init_general, mng_free_jdat, mng_read_jdat, mng_write_jdat, mng_assign_jdat, 0, 0, sizeof(mng_jdat)};
  4667. #else
  4668. {MNG_UINT_JDAT, mng_init_jdat, mng_free_jdat, mng_read_jdat, mng_write_jdat, mng_assign_jdat, 0, 0};
  4669. #endif
  4670. #else
  4671. mng_chunk_header sChunkheader;
  4672. #endif
  4673. #ifdef MNG_SUPPORT_TRACE
  4674. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JDAT, MNG_LC_START);
  4675. #endif
  4676. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  4677. pData = (mng_datap)hHandle; /* and make it addressable */
  4678. if (!pData->bCreating) /* aren't we creating a new file ? */
  4679. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  4680. /* must have had a MHDR or JHDR first! */
  4681. if ((pData->iFirstchunkadded != MNG_UINT_MHDR) &&
  4682. (pData->iFirstchunkadded != MNG_UINT_JHDR) )
  4683. MNG_ERROR (pData, MNG_NOHEADER)
  4684. /* prevent misplaced TERM ! */
  4685. if (!check_term (pData, MNG_UINT_JDAT))
  4686. MNG_ERROR (pData, MNG_TERMSEQERROR)
  4687. /* create the chunk */
  4688. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4689. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4690. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4691. #else
  4692. iRetcode = mng_init_jdat (pData, &sChunkheader, &pChunk);
  4693. #endif
  4694. #else
  4695. mng_get_chunkheader(MNG_UINT_JDAT, &sChunkheader);
  4696. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4697. #endif
  4698. if (iRetcode) /* on error bail out */
  4699. return iRetcode;
  4700. /* fill the chunk */
  4701. ((mng_jdatp)pChunk)->iDatasize = iRawlen;
  4702. if (iRawlen)
  4703. {
  4704. MNG_ALLOC (pData, ((mng_jdatp)pChunk)->pData, iRawlen);
  4705. MNG_COPY (((mng_jdatp)pChunk)->pData, pRawdata, iRawlen);
  4706. }
  4707. mng_add_chunk (pData, pChunk); /* add it to the list */
  4708. #ifdef MNG_SUPPORT_TRACE
  4709. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JDAT, MNG_LC_END);
  4710. #endif
  4711. return MNG_NOERROR;
  4712. }
  4713. #endif /* MNG_INCLUDE_JNG */
  4714. /* ************************************************************************** */
  4715. #ifdef MNG_INCLUDE_JNG
  4716. mng_retcode MNG_DECL mng_putchunk_jdaa (mng_handle hHandle,
  4717. mng_uint32 iRawlen,
  4718. mng_ptr pRawdata)
  4719. {
  4720. mng_datap pData;
  4721. mng_chunkp pChunk;
  4722. mng_retcode iRetcode;
  4723. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4724. mng_chunk_header sChunkheader =
  4725. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4726. {MNG_UINT_JDAA, mng_init_general, mng_free_jdaa, mng_read_jdaa, mng_write_jdaa, mng_assign_jdaa, 0, 0, sizeof(mng_jdaa)};
  4727. #else
  4728. {MNG_UINT_JDAA, mng_init_jdaa, mng_free_jdaa, mng_read_jdaa, mng_write_jdaa, mng_assign_jdaa, 0, 0};
  4729. #endif
  4730. #else
  4731. mng_chunk_header sChunkheader;
  4732. #endif
  4733. #ifdef MNG_SUPPORT_TRACE
  4734. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JDAA, MNG_LC_START);
  4735. #endif
  4736. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  4737. pData = (mng_datap)hHandle; /* and make it addressable */
  4738. if (!pData->bCreating) /* aren't we creating a new file ? */
  4739. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  4740. /* must have had a MHDR or JHDR first! */
  4741. if ((pData->iFirstchunkadded != MNG_UINT_MHDR) &&
  4742. (pData->iFirstchunkadded != MNG_UINT_JHDR) )
  4743. MNG_ERROR (pData, MNG_NOHEADER)
  4744. /* prevent misplaced TERM ! */
  4745. if (!check_term (pData, MNG_UINT_JDAA))
  4746. MNG_ERROR (pData, MNG_TERMSEQERROR)
  4747. /* create the chunk */
  4748. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4749. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4750. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4751. #else
  4752. iRetcode = mng_init_jdaa (pData, &sChunkheader, &pChunk);
  4753. #endif
  4754. #else
  4755. mng_get_chunkheader(MNG_UINT_JDAA, &sChunkheader);
  4756. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4757. #endif
  4758. if (iRetcode) /* on error bail out */
  4759. return iRetcode;
  4760. /* fill the chunk */
  4761. ((mng_jdaap)pChunk)->iDatasize = iRawlen;
  4762. if (iRawlen)
  4763. {
  4764. MNG_ALLOC (pData, ((mng_jdaap)pChunk)->pData, iRawlen);
  4765. MNG_COPY (((mng_jdaap)pChunk)->pData, pRawdata, iRawlen);
  4766. }
  4767. mng_add_chunk (pData, pChunk); /* add it to the list */
  4768. #ifdef MNG_SUPPORT_TRACE
  4769. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JDAA, MNG_LC_END);
  4770. #endif
  4771. return MNG_NOERROR;
  4772. }
  4773. #endif /* MNG_INCLUDE_JNG */
  4774. /* ************************************************************************** */
  4775. #ifdef MNG_INCLUDE_JNG
  4776. mng_retcode MNG_DECL mng_putchunk_jsep (mng_handle hHandle)
  4777. {
  4778. mng_datap pData;
  4779. mng_chunkp pChunk;
  4780. mng_retcode iRetcode;
  4781. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4782. mng_chunk_header sChunkheader =
  4783. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4784. {MNG_UINT_JSEP, mng_init_general, mng_free_general, mng_read_jsep, mng_write_jsep, mng_assign_general, 0, 0, sizeof(mng_jsep)};
  4785. #else
  4786. {MNG_UINT_JSEP, mng_init_jsep, mng_free_jsep, mng_read_jsep, mng_write_jsep, mng_assign_jsep, 0, 0};
  4787. #endif
  4788. #else
  4789. mng_chunk_header sChunkheader;
  4790. #endif
  4791. #ifdef MNG_SUPPORT_TRACE
  4792. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JSEP, MNG_LC_START);
  4793. #endif
  4794. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  4795. pData = (mng_datap)hHandle; /* and make it addressable */
  4796. if (!pData->bCreating) /* aren't we creating a new file ? */
  4797. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  4798. /* must have had a MHDR or JHDR first! */
  4799. if ((pData->iFirstchunkadded != MNG_UINT_MHDR) &&
  4800. (pData->iFirstchunkadded != MNG_UINT_JHDR) )
  4801. MNG_ERROR (pData, MNG_NOHEADER)
  4802. /* prevent misplaced TERM ! */
  4803. if (!check_term (pData, MNG_UINT_JSEP))
  4804. MNG_ERROR (pData, MNG_TERMSEQERROR)
  4805. /* create the chunk */
  4806. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4807. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4808. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4809. #else
  4810. iRetcode = mng_init_jsep (pData, &sChunkheader, &pChunk);
  4811. #endif
  4812. #else
  4813. mng_get_chunkheader(MNG_UINT_JSEP, &sChunkheader);
  4814. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4815. #endif
  4816. if (iRetcode) /* on error bail out */
  4817. return iRetcode;
  4818. mng_add_chunk (pData, pChunk); /* add it to the list */
  4819. #ifdef MNG_SUPPORT_TRACE
  4820. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JSEP, MNG_LC_END);
  4821. #endif
  4822. return MNG_NOERROR;
  4823. }
  4824. #endif /* MNG_INCLUDE_JNG */
  4825. /* ************************************************************************** */
  4826. #ifndef MNG_NO_DELTA_PNG
  4827. mng_retcode MNG_DECL mng_putchunk_dhdr (mng_handle hHandle,
  4828. mng_uint16 iObjectid,
  4829. mng_uint8 iImagetype,
  4830. mng_uint8 iDeltatype,
  4831. mng_uint32 iBlockwidth,
  4832. mng_uint32 iBlockheight,
  4833. mng_uint32 iBlockx,
  4834. mng_uint32 iBlocky)
  4835. {
  4836. mng_datap pData;
  4837. mng_chunkp pChunk;
  4838. mng_retcode iRetcode;
  4839. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4840. mng_chunk_header sChunkheader =
  4841. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4842. {MNG_UINT_DHDR, mng_init_general, mng_free_general, mng_read_dhdr, mng_write_dhdr, mng_assign_general, 0, 0, sizeof(mng_dhdr)};
  4843. #else
  4844. {MNG_UINT_DHDR, mng_init_dhdr, mng_free_dhdr, mng_read_dhdr, mng_write_dhdr, mng_assign_dhdr, 0, 0};
  4845. #endif
  4846. #else
  4847. mng_chunk_header sChunkheader;
  4848. #endif
  4849. #ifdef MNG_SUPPORT_TRACE
  4850. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DHDR, MNG_LC_START);
  4851. #endif
  4852. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  4853. pData = (mng_datap)hHandle; /* and make it addressable */
  4854. if (!pData->bCreating) /* aren't we creating a new file ? */
  4855. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  4856. /* must have had a MHDR first! */
  4857. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  4858. MNG_ERROR (pData, MNG_NOHEADER)
  4859. /* prevent misplaced TERM ! */
  4860. if (!check_term (pData, MNG_UINT_DHDR))
  4861. MNG_ERROR (pData, MNG_TERMSEQERROR)
  4862. /* create the chunk */
  4863. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4864. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4865. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4866. #else
  4867. iRetcode = mng_init_dhdr (pData, &sChunkheader, &pChunk);
  4868. #endif
  4869. #else
  4870. mng_get_chunkheader(MNG_UINT_DHDR, &sChunkheader);
  4871. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4872. #endif
  4873. if (iRetcode) /* on error bail out */
  4874. return iRetcode;
  4875. /* fill the chunk */
  4876. ((mng_dhdrp)pChunk)->iObjectid = iObjectid;
  4877. ((mng_dhdrp)pChunk)->iImagetype = iImagetype;
  4878. ((mng_dhdrp)pChunk)->iDeltatype = iDeltatype;
  4879. ((mng_dhdrp)pChunk)->iBlockwidth = iBlockwidth;
  4880. ((mng_dhdrp)pChunk)->iBlockheight = iBlockheight;
  4881. ((mng_dhdrp)pChunk)->iBlockx = iBlockx;
  4882. ((mng_dhdrp)pChunk)->iBlocky = iBlocky;
  4883. mng_add_chunk (pData, pChunk); /* add it to the list */
  4884. #ifdef MNG_SUPPORT_TRACE
  4885. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DHDR, MNG_LC_END);
  4886. #endif
  4887. return MNG_NOERROR;
  4888. }
  4889. #endif
  4890. /* ************************************************************************** */
  4891. #ifndef MNG_NO_DELTA_PNG
  4892. mng_retcode MNG_DECL mng_putchunk_prom (mng_handle hHandle,
  4893. mng_uint8 iColortype,
  4894. mng_uint8 iSampledepth,
  4895. mng_uint8 iFilltype)
  4896. {
  4897. mng_datap pData;
  4898. mng_chunkp pChunk;
  4899. mng_retcode iRetcode;
  4900. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4901. mng_chunk_header sChunkheader =
  4902. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4903. {MNG_UINT_PROM, mng_init_general, mng_free_general, mng_read_prom, mng_write_prom, mng_assign_general, 0, 0, sizeof(mng_prom)};
  4904. #else
  4905. {MNG_UINT_PROM, mng_init_prom, mng_free_prom, mng_read_prom, mng_write_prom, mng_assign_prom, 0, 0};
  4906. #endif
  4907. #else
  4908. mng_chunk_header sChunkheader;
  4909. #endif
  4910. #ifdef MNG_SUPPORT_TRACE
  4911. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PROM, MNG_LC_START);
  4912. #endif
  4913. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  4914. pData = (mng_datap)hHandle; /* and make it addressable */
  4915. if (!pData->bCreating) /* aren't we creating a new file ? */
  4916. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  4917. /* must have had a MHDR first! */
  4918. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  4919. MNG_ERROR (pData, MNG_NOHEADER)
  4920. /* prevent misplaced TERM ! */
  4921. if (!check_term (pData, MNG_UINT_PROM))
  4922. MNG_ERROR (pData, MNG_TERMSEQERROR)
  4923. /* create the chunk */
  4924. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4925. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4926. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4927. #else
  4928. iRetcode = mng_init_prom (pData, &sChunkheader, &pChunk);
  4929. #endif
  4930. #else
  4931. mng_get_chunkheader(MNG_UINT_PROM, &sChunkheader);
  4932. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4933. #endif
  4934. if (iRetcode) /* on error bail out */
  4935. return iRetcode;
  4936. /* fill the chunk */
  4937. ((mng_promp)pChunk)->iColortype = iColortype;
  4938. ((mng_promp)pChunk)->iSampledepth = iSampledepth;
  4939. ((mng_promp)pChunk)->iFilltype = iFilltype;
  4940. mng_add_chunk (pData, pChunk); /* add it to the list */
  4941. #ifdef MNG_SUPPORT_TRACE
  4942. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PROM, MNG_LC_END);
  4943. #endif
  4944. return MNG_NOERROR;
  4945. }
  4946. #endif
  4947. /* ************************************************************************** */
  4948. #ifndef MNG_NO_DELTA_PNG
  4949. mng_retcode MNG_DECL mng_putchunk_ipng (mng_handle hHandle)
  4950. {
  4951. mng_datap pData;
  4952. mng_chunkp pChunk;
  4953. mng_retcode iRetcode;
  4954. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4955. mng_chunk_header sChunkheader =
  4956. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4957. {MNG_UINT_IPNG, mng_init_general, mng_free_general, mng_read_ipng, mng_write_ipng, mng_assign_general, 0, 0, sizeof(mng_ipng)};
  4958. #else
  4959. {MNG_UINT_IPNG, mng_init_ipng, mng_free_ipng, mng_read_ipng, mng_write_ipng, mng_assign_ipng, 0, 0};
  4960. #endif
  4961. #else
  4962. mng_chunk_header sChunkheader;
  4963. #endif
  4964. #ifdef MNG_SUPPORT_TRACE
  4965. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IPNG, MNG_LC_START);
  4966. #endif
  4967. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  4968. pData = (mng_datap)hHandle; /* and make it addressable */
  4969. if (!pData->bCreating) /* aren't we creating a new file ? */
  4970. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  4971. /* must have had a MHDR first! */
  4972. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  4973. MNG_ERROR (pData, MNG_NOHEADER)
  4974. /* prevent misplaced TERM ! */
  4975. if (!check_term (pData, MNG_UINT_IPNG))
  4976. MNG_ERROR (pData, MNG_TERMSEQERROR)
  4977. /* create the chunk */
  4978. #ifndef MNG_OPTIMIZE_CHUNKREADER
  4979. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  4980. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4981. #else
  4982. iRetcode = mng_init_ipng (pData, &sChunkheader, &pChunk);
  4983. #endif
  4984. #else
  4985. mng_get_chunkheader(MNG_UINT_IPNG, &sChunkheader);
  4986. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  4987. #endif
  4988. if (iRetcode) /* on error bail out */
  4989. return iRetcode;
  4990. mng_add_chunk (pData, pChunk); /* add it to the list */
  4991. #ifdef MNG_SUPPORT_TRACE
  4992. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IPNG, MNG_LC_END);
  4993. #endif
  4994. return MNG_NOERROR;
  4995. }
  4996. #endif
  4997. /* ************************************************************************** */
  4998. #ifndef MNG_NO_DELTA_PNG
  4999. mng_retcode MNG_DECL mng_putchunk_pplt (mng_handle hHandle,
  5000. mng_uint8 iDeltatype,
  5001. mng_uint32 iCount)
  5002. {
  5003. mng_datap pData;
  5004. mng_chunkp pChunk;
  5005. mng_retcode iRetcode;
  5006. #ifndef MNG_OPTIMIZE_CHUNKREADER
  5007. mng_chunk_header sChunkheader =
  5008. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  5009. {MNG_UINT_PPLT, mng_init_general, mng_free_general, mng_read_pplt, mng_write_pplt, mng_assign_general, 0, 0, sizeof(mng_pplt)};
  5010. #else
  5011. {MNG_UINT_PPLT, mng_init_pplt, mng_free_pplt, mng_read_pplt, mng_write_pplt, mng_assign_pplt, 0, 0};
  5012. #endif
  5013. #else
  5014. mng_chunk_header sChunkheader;
  5015. #endif
  5016. #ifdef MNG_SUPPORT_TRACE
  5017. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PPLT, MNG_LC_START);
  5018. #endif
  5019. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  5020. pData = (mng_datap)hHandle; /* and make it addressable */
  5021. if (!pData->bCreating) /* aren't we creating a new file ? */
  5022. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  5023. /* must have had a MHDR first! */
  5024. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  5025. MNG_ERROR (pData, MNG_NOHEADER)
  5026. /* prevent misplaced TERM ! */
  5027. if (!check_term (pData, MNG_UINT_PPLT))
  5028. MNG_ERROR (pData, MNG_TERMSEQERROR)
  5029. /* create the chunk */
  5030. #ifndef MNG_OPTIMIZE_CHUNKREADER
  5031. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  5032. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  5033. #else
  5034. iRetcode = mng_init_pplt (pData, &sChunkheader, &pChunk);
  5035. #endif
  5036. #else
  5037. mng_get_chunkheader(MNG_UINT_PPLT, &sChunkheader);
  5038. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  5039. #endif
  5040. if (iRetcode) /* on error bail out */
  5041. return iRetcode;
  5042. /* fill the chunk */
  5043. ((mng_ppltp)pChunk)->iDeltatype = iDeltatype;
  5044. ((mng_ppltp)pChunk)->iCount = iCount;
  5045. mng_add_chunk (pData, pChunk); /* add it to the list */
  5046. #ifdef MNG_SUPPORT_TRACE
  5047. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PPLT, MNG_LC_END);
  5048. #endif
  5049. return MNG_NOERROR;
  5050. }
  5051. #endif
  5052. /* ************************************************************************** */
  5053. #ifndef MNG_NO_DELTA_PNG
  5054. mng_retcode MNG_DECL mng_putchunk_pplt_entry (mng_handle hHandle,
  5055. mng_uint32 iEntry,
  5056. mng_uint16 iRed,
  5057. mng_uint16 iGreen,
  5058. mng_uint16 iBlue,
  5059. mng_uint16 iAlpha)
  5060. {
  5061. mng_datap pData;
  5062. mng_chunkp pChunk;
  5063. mng_pplt_entryp pEntry;
  5064. #ifdef MNG_SUPPORT_TRACE
  5065. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PPLT_ENTRY, MNG_LC_START);
  5066. #endif
  5067. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  5068. pData = (mng_datap)hHandle; /* and make it addressable */
  5069. if (!pData->bCreating) /* aren't we creating a new file ? */
  5070. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  5071. /* must have had a MHDR first! */
  5072. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  5073. MNG_ERROR (pData, MNG_NOHEADER)
  5074. pChunk = pData->pLastchunk; /* last one must have been PPLT ! */
  5075. if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_PPLT)
  5076. MNG_ERROR (pData, MNG_NOCORRCHUNK)
  5077. /* index out of bounds ? */
  5078. if (iEntry >= ((mng_ppltp)pChunk)->iCount)
  5079. MNG_ERROR (pData, MNG_INVALIDENTRYIX)
  5080. /* address proper entry */
  5081. pEntry = (mng_pplt_entryp)(((mng_ppltp)pChunk)->aEntries) + iEntry;
  5082. pEntry->iRed = (mng_uint8)iRed; /* fill the entry */
  5083. pEntry->iGreen = (mng_uint8)iGreen;
  5084. pEntry->iBlue = (mng_uint8)iBlue;
  5085. pEntry->iAlpha = (mng_uint8)iAlpha;
  5086. pEntry->bUsed = MNG_TRUE;
  5087. #ifdef MNG_SUPPORT_TRACE
  5088. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PPLT_ENTRY, MNG_LC_END);
  5089. #endif
  5090. return MNG_NOERROR;
  5091. }
  5092. #endif
  5093. /* ************************************************************************** */
  5094. #ifndef MNG_NO_DELTA_PNG
  5095. #ifdef MNG_INCLUDE_JNG
  5096. mng_retcode MNG_DECL mng_putchunk_ijng (mng_handle hHandle)
  5097. {
  5098. mng_datap pData;
  5099. mng_chunkp pChunk;
  5100. mng_retcode iRetcode;
  5101. #ifndef MNG_OPTIMIZE_CHUNKREADER
  5102. mng_chunk_header sChunkheader =
  5103. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  5104. {MNG_UINT_IJNG, mng_init_general, mng_free_general, mng_read_ijng, mng_write_ijng, mng_assign_general, 0, 0, sizeof(mng_ijng)};
  5105. #else
  5106. {MNG_UINT_IJNG, mng_init_ijng, mng_free_ijng, mng_read_ijng, mng_write_ijng, mng_assign_ijng, 0, 0};
  5107. #endif
  5108. #else
  5109. mng_chunk_header sChunkheader;
  5110. #endif
  5111. #ifdef MNG_SUPPORT_TRACE
  5112. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IJNG, MNG_LC_START);
  5113. #endif
  5114. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  5115. pData = (mng_datap)hHandle; /* and make it addressable */
  5116. if (!pData->bCreating) /* aren't we creating a new file ? */
  5117. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  5118. /* must have had a MHDR first! */
  5119. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  5120. MNG_ERROR (pData, MNG_NOHEADER)
  5121. /* prevent misplaced TERM ! */
  5122. if (!check_term (pData, MNG_UINT_IJNG))
  5123. MNG_ERROR (pData, MNG_TERMSEQERROR)
  5124. /* create the chunk */
  5125. #ifndef MNG_OPTIMIZE_CHUNKREADER
  5126. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  5127. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  5128. #else
  5129. iRetcode = mng_init_ijng (pData, &sChunkheader, &pChunk);
  5130. #endif
  5131. #else
  5132. mng_get_chunkheader(MNG_UINT_IJNG, &sChunkheader);
  5133. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  5134. #endif
  5135. if (iRetcode) /* on error bail out */
  5136. return iRetcode;
  5137. mng_add_chunk (pData, pChunk); /* add it to the list */
  5138. #ifdef MNG_SUPPORT_TRACE
  5139. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IJNG, MNG_LC_END);
  5140. #endif
  5141. return MNG_NOERROR;
  5142. }
  5143. #endif
  5144. #endif
  5145. /* ************************************************************************** */
  5146. #ifndef MNG_NO_DELTA_PNG
  5147. mng_retcode MNG_DECL mng_putchunk_drop (mng_handle hHandle,
  5148. mng_uint32 iCount,
  5149. mng_chunkidp pChunknames)
  5150. {
  5151. mng_datap pData;
  5152. mng_chunkp pChunk;
  5153. mng_retcode iRetcode;
  5154. #ifndef MNG_OPTIMIZE_CHUNKREADER
  5155. mng_chunk_header sChunkheader =
  5156. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  5157. {MNG_UINT_DROP, mng_init_general, mng_free_drop, mng_read_drop, mng_write_drop, mng_assign_drop, 0, 0, sizeof(mng_drop)};
  5158. #else
  5159. {MNG_UINT_DROP, mng_init_drop, mng_free_drop, mng_read_drop, mng_write_drop, mng_assign_drop, 0, 0};
  5160. #endif
  5161. #else
  5162. mng_chunk_header sChunkheader;
  5163. #endif
  5164. #ifdef MNG_SUPPORT_TRACE
  5165. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DROP, MNG_LC_START);
  5166. #endif
  5167. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  5168. pData = (mng_datap)hHandle; /* and make it addressable */
  5169. if (!pData->bCreating) /* aren't we creating a new file ? */
  5170. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  5171. /* must have had a MHDR first! */
  5172. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  5173. MNG_ERROR (pData, MNG_NOHEADER)
  5174. /* prevent misplaced TERM ! */
  5175. if (!check_term (pData, MNG_UINT_DROP))
  5176. MNG_ERROR (pData, MNG_TERMSEQERROR)
  5177. /* create the chunk */
  5178. #ifndef MNG_OPTIMIZE_CHUNKREADER
  5179. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  5180. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  5181. #else
  5182. iRetcode = mng_init_drop (pData, &sChunkheader, &pChunk);
  5183. #endif
  5184. #else
  5185. mng_get_chunkheader(MNG_UINT_DROP, &sChunkheader);
  5186. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  5187. #endif
  5188. if (iRetcode) /* on error bail out */
  5189. return iRetcode;
  5190. /* fill the chunk */
  5191. ((mng_dropp)pChunk)->iCount = iCount;
  5192. if (iCount)
  5193. {
  5194. mng_uint32 iSize = iCount * sizeof (mng_chunkid);
  5195. MNG_ALLOC (pData, ((mng_dropp)pChunk)->pChunknames, iSize);
  5196. MNG_COPY (((mng_dropp)pChunk)->pChunknames, pChunknames, iSize);
  5197. }
  5198. mng_add_chunk (pData, pChunk); /* add it to the list */
  5199. #ifdef MNG_SUPPORT_TRACE
  5200. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DROP, MNG_LC_END);
  5201. #endif
  5202. return MNG_NOERROR;
  5203. }
  5204. #endif
  5205. /* ************************************************************************** */
  5206. #ifndef MNG_NO_DELTA_PNG
  5207. #ifndef MNG_SKIPCHUNK_DBYK
  5208. mng_retcode MNG_DECL mng_putchunk_dbyk (mng_handle hHandle,
  5209. mng_chunkid iChunkname,
  5210. mng_uint8 iPolarity,
  5211. mng_uint32 iKeywordssize,
  5212. mng_pchar zKeywords)
  5213. {
  5214. mng_datap pData;
  5215. mng_chunkp pChunk;
  5216. mng_retcode iRetcode;
  5217. #ifndef MNG_OPTIMIZE_CHUNKREADER
  5218. mng_chunk_header sChunkheader =
  5219. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  5220. {MNG_UINT_DBYK, mng_init_general, mng_free_dbyk, mng_read_dbyk, mng_write_dbyk, mng_assign_dbyk, 0, 0, sizeof(mng_dbyk)};
  5221. #else
  5222. {MNG_UINT_DBYK, mng_init_dbyk, mng_free_dbyk, mng_read_dbyk, mng_write_dbyk, mng_assign_dbyk, 0, 0};
  5223. #endif
  5224. #else
  5225. mng_chunk_header sChunkheader;
  5226. #endif
  5227. #ifdef MNG_SUPPORT_TRACE
  5228. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DBYK, MNG_LC_START);
  5229. #endif
  5230. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  5231. pData = (mng_datap)hHandle; /* and make it addressable */
  5232. if (!pData->bCreating) /* aren't we creating a new file ? */
  5233. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  5234. /* must have had a MHDR first! */
  5235. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  5236. MNG_ERROR (pData, MNG_NOHEADER)
  5237. /* prevent misplaced TERM ! */
  5238. if (!check_term (pData, MNG_UINT_DBYK))
  5239. MNG_ERROR (pData, MNG_TERMSEQERROR)
  5240. /* create the chunk */
  5241. #ifndef MNG_OPTIMIZE_CHUNKREADER
  5242. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  5243. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  5244. #else
  5245. iRetcode = mng_init_dbyk (pData, &sChunkheader, &pChunk);
  5246. #endif
  5247. #else
  5248. mng_get_chunkheader(MNG_UINT_DBYK, &sChunkheader);
  5249. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  5250. #endif
  5251. if (iRetcode) /* on error bail out */
  5252. return iRetcode;
  5253. /* fill the chunk */
  5254. ((mng_dbykp)pChunk)->iChunkname = iChunkname;
  5255. ((mng_dbykp)pChunk)->iPolarity = iPolarity;
  5256. ((mng_dbykp)pChunk)->iKeywordssize = iKeywordssize;
  5257. if (iKeywordssize)
  5258. {
  5259. MNG_ALLOC (pData, ((mng_dbykp)pChunk)->zKeywords, iKeywordssize + 1);
  5260. MNG_COPY (((mng_dbykp)pChunk)->zKeywords, zKeywords, iKeywordssize);
  5261. }
  5262. mng_add_chunk (pData, pChunk); /* add it to the list */
  5263. #ifdef MNG_SUPPORT_TRACE
  5264. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DBYK, MNG_LC_END);
  5265. #endif
  5266. return MNG_NOERROR;
  5267. }
  5268. #endif
  5269. #endif
  5270. /* ************************************************************************** */
  5271. #ifndef MNG_NO_DELTA_PNG
  5272. #ifndef MNG_SKIPCHUNK_ORDR
  5273. mng_retcode MNG_DECL mng_putchunk_ordr (mng_handle hHandle,
  5274. mng_uint32 iCount)
  5275. {
  5276. mng_datap pData;
  5277. mng_chunkp pChunk;
  5278. mng_retcode iRetcode;
  5279. #ifndef MNG_OPTIMIZE_CHUNKREADER
  5280. mng_chunk_header sChunkheader =
  5281. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  5282. {MNG_UINT_ORDR, mng_init_general, mng_free_ordr, mng_read_ordr, mng_write_ordr, mng_assign_ordr, 0, 0, sizeof(mng_ordr)};
  5283. #else
  5284. {MNG_UINT_ORDR, mng_init_ordr, mng_free_ordr, mng_read_ordr, mng_write_ordr, mng_assign_ordr, 0, 0};
  5285. #endif
  5286. #else
  5287. mng_chunk_header sChunkheader;
  5288. #endif
  5289. #ifdef MNG_SUPPORT_TRACE
  5290. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ORDR, MNG_LC_START);
  5291. #endif
  5292. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  5293. pData = (mng_datap)hHandle; /* and make it addressable */
  5294. if (!pData->bCreating) /* aren't we creating a new file ? */
  5295. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  5296. /* must have had a MHDR first! */
  5297. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  5298. MNG_ERROR (pData, MNG_NOHEADER)
  5299. /* prevent misplaced TERM ! */
  5300. if (!check_term (pData, MNG_UINT_ORDR))
  5301. MNG_ERROR (pData, MNG_TERMSEQERROR)
  5302. /* create the chunk */
  5303. #ifndef MNG_OPTIMIZE_CHUNKREADER
  5304. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  5305. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  5306. #else
  5307. iRetcode = mng_init_ordr (pData, &sChunkheader, &pChunk);
  5308. #endif
  5309. #else
  5310. mng_get_chunkheader(MNG_UINT_ORDR, &sChunkheader);
  5311. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  5312. #endif
  5313. if (iRetcode) /* on error bail out */
  5314. return iRetcode;
  5315. /* fill the chunk */
  5316. ((mng_ordrp)pChunk)->iCount = iCount;
  5317. if (iCount)
  5318. MNG_ALLOC (pData, ((mng_ordrp)pChunk)->pEntries, iCount * sizeof (mng_ordr_entry));
  5319. mng_add_chunk (pData, pChunk); /* add it to the list */
  5320. #ifdef MNG_SUPPORT_TRACE
  5321. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ORDR, MNG_LC_END);
  5322. #endif
  5323. return MNG_NOERROR;
  5324. }
  5325. #endif
  5326. #endif
  5327. /* ************************************************************************** */
  5328. #ifndef MNG_NO_DELTA_PNG
  5329. #ifndef MNG_SKIPCHUNK_ORDR
  5330. mng_retcode MNG_DECL mng_putchunk_ordr_entry (mng_handle hHandle,
  5331. mng_uint32 iEntry,
  5332. mng_chunkid iChunkname,
  5333. mng_uint8 iOrdertype)
  5334. {
  5335. mng_datap pData;
  5336. mng_chunkp pChunk;
  5337. mng_ordr_entryp pEntry;
  5338. #ifdef MNG_SUPPORT_TRACE
  5339. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ORDR_ENTRY, MNG_LC_START);
  5340. #endif
  5341. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  5342. pData = (mng_datap)hHandle; /* and make it addressable */
  5343. if (!pData->bCreating) /* aren't we creating a new file ? */
  5344. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  5345. /* must have had a MHDR first! */
  5346. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  5347. MNG_ERROR (pData, MNG_NOHEADER)
  5348. pChunk = pData->pLastchunk; /* last one must have been ORDR ! */
  5349. if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_ORDR)
  5350. MNG_ERROR (pData, MNG_NOCORRCHUNK)
  5351. /* index out of bounds ? */
  5352. if (iEntry >= ((mng_ordrp)pChunk)->iCount)
  5353. MNG_ERROR (pData, MNG_INVALIDENTRYIX)
  5354. /* address proper entry */
  5355. pEntry = ((mng_ordrp)pChunk)->pEntries + iEntry;
  5356. pEntry->iChunkname = iChunkname; /* fill the entry */
  5357. pEntry->iOrdertype = iOrdertype;
  5358. #ifdef MNG_SUPPORT_TRACE
  5359. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ORDR_ENTRY, MNG_LC_END);
  5360. #endif
  5361. return MNG_NOERROR;
  5362. }
  5363. #endif
  5364. #endif
  5365. /* ************************************************************************** */
  5366. #ifndef MNG_SKIPCHUNK_MAGN
  5367. mng_retcode MNG_DECL mng_putchunk_magn (mng_handle hHandle,
  5368. mng_uint16 iFirstid,
  5369. mng_uint16 iLastid,
  5370. mng_uint16 iMethodX,
  5371. mng_uint16 iMX,
  5372. mng_uint16 iMY,
  5373. mng_uint16 iML,
  5374. mng_uint16 iMR,
  5375. mng_uint16 iMT,
  5376. mng_uint16 iMB,
  5377. mng_uint16 iMethodY)
  5378. {
  5379. mng_datap pData;
  5380. mng_chunkp pChunk;
  5381. mng_retcode iRetcode;
  5382. #ifndef MNG_OPTIMIZE_CHUNKREADER
  5383. mng_chunk_header sChunkheader =
  5384. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  5385. {MNG_UINT_MAGN, mng_init_general, mng_free_general, mng_read_magn, mng_write_magn, mng_assign_general, 0, 0, sizeof(mng_magn)};
  5386. #else
  5387. {MNG_UINT_MAGN, mng_init_magn, mng_free_magn, mng_read_magn, mng_write_magn, mng_assign_magn, 0, 0};
  5388. #endif
  5389. #else
  5390. mng_chunk_header sChunkheader;
  5391. #endif
  5392. #ifdef MNG_SUPPORT_TRACE
  5393. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MAGN, MNG_LC_START);
  5394. #endif
  5395. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  5396. pData = (mng_datap)hHandle; /* and make it addressable */
  5397. if (!pData->bCreating) /* aren't we creating a new file ? */
  5398. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  5399. /* must have had a MHDR first! */
  5400. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  5401. MNG_ERROR (pData, MNG_NOHEADER)
  5402. /* prevent misplaced TERM ! */
  5403. if (!check_term (pData, MNG_UINT_MAGN))
  5404. MNG_ERROR (pData, MNG_TERMSEQERROR)
  5405. /* create the chunk */
  5406. #ifndef MNG_OPTIMIZE_CHUNKREADER
  5407. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  5408. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  5409. #else
  5410. iRetcode = mng_init_magn (pData, &sChunkheader, &pChunk);
  5411. #endif
  5412. #else
  5413. mng_get_chunkheader(MNG_UINT_MAGN, &sChunkheader);
  5414. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  5415. #endif
  5416. if (iRetcode) /* on error bail out */
  5417. return iRetcode;
  5418. /* fill the chunk */
  5419. ((mng_magnp)pChunk)->iFirstid = iFirstid;
  5420. ((mng_magnp)pChunk)->iLastid = iLastid;
  5421. ((mng_magnp)pChunk)->iMethodX = (mng_uint8)iMethodX;
  5422. ((mng_magnp)pChunk)->iMX = iMX;
  5423. ((mng_magnp)pChunk)->iMY = iMY;
  5424. ((mng_magnp)pChunk)->iML = iML;
  5425. ((mng_magnp)pChunk)->iMR = iMR;
  5426. ((mng_magnp)pChunk)->iMT = iMT;
  5427. ((mng_magnp)pChunk)->iMB = iMB;
  5428. ((mng_magnp)pChunk)->iMethodY = (mng_uint8)iMethodY;
  5429. mng_add_chunk (pData, pChunk); /* add it to the list */
  5430. #ifdef MNG_SUPPORT_TRACE
  5431. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MAGN, MNG_LC_END);
  5432. #endif
  5433. return MNG_NOERROR;
  5434. }
  5435. #endif
  5436. /* ************************************************************************** */
  5437. #ifdef MNG_INCLUDE_MPNG_PROPOSAL
  5438. MNG_EXT mng_retcode MNG_DECL mng_putchunk_mpng (mng_handle hHandle,
  5439. mng_uint32 iFramewidth,
  5440. mng_uint32 iFrameheight,
  5441. mng_uint16 iNumplays,
  5442. mng_uint16 iTickspersec,
  5443. mng_uint8 iCompressionmethod,
  5444. mng_uint32 iCount)
  5445. {
  5446. mng_datap pData;
  5447. mng_chunkp pChunk;
  5448. mng_retcode iRetcode;
  5449. #ifndef MNG_OPTIMIZE_CHUNKREADER
  5450. mng_chunk_header sChunkheader =
  5451. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  5452. {MNG_UINT_mpNG, mng_init_general, mng_free_mpng, mng_read_mpng, mng_write_mpng, mng_assign_mpng, 0, 0, sizeof(mng_mpng)};
  5453. #else
  5454. {MNG_UINT_mpNG, mng_init_mpng, mng_free_mpng, mng_read_mpng, mng_write_mpng, mng_assign_mpng, 0, 0};
  5455. #endif
  5456. #else
  5457. mng_chunk_header sChunkheader;
  5458. #endif
  5459. #ifdef MNG_SUPPORT_TRACE
  5460. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MPNG, MNG_LC_START);
  5461. #endif
  5462. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  5463. pData = (mng_datap)hHandle; /* and make it addressable */
  5464. if (!pData->bCreating) /* aren't we creating a new file ? */
  5465. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  5466. /* must have had a IHDR first! */
  5467. if (pData->iFirstchunkadded != MNG_UINT_IHDR)
  5468. MNG_ERROR (pData, MNG_NOHEADER)
  5469. /* create the chunk */
  5470. #ifndef MNG_OPTIMIZE_CHUNKREADER
  5471. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  5472. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  5473. #else
  5474. iRetcode = mng_init_mpng (pData, &sChunkheader, &pChunk);
  5475. #endif
  5476. #else
  5477. mng_get_chunkheader(MNG_UINT_mpNG, &sChunkheader);
  5478. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  5479. #endif
  5480. if (iRetcode) /* on error bail out */
  5481. return iRetcode;
  5482. /* fill the chunk */
  5483. ((mng_mpngp)pChunk)->iFramewidth = iFramewidth;
  5484. ((mng_mpngp)pChunk)->iFrameheight = iFrameheight;
  5485. ((mng_mpngp)pChunk)->iNumplays = iNumplays;
  5486. ((mng_mpngp)pChunk)->iTickspersec = iTickspersec;
  5487. ((mng_mpngp)pChunk)->iCompressionmethod = iCompressionmethod;
  5488. ((mng_mpngp)pChunk)->iFramessize = iCount * sizeof (mng_mpng_frame);
  5489. if (iCount)
  5490. MNG_ALLOC (pData, ((mng_mpngp)pChunk)->pFrames, ((mng_mpngp)pChunk)->iFramessize);
  5491. mng_add_chunk (pData, pChunk); /* add it to the list */
  5492. #ifdef MNG_SUPPORT_TRACE
  5493. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MPNG, MNG_LC_END);
  5494. #endif
  5495. return MNG_NOERROR;
  5496. }
  5497. #endif
  5498. /* ************************************************************************** */
  5499. #ifdef MNG_INCLUDE_MPNG_PROPOSAL
  5500. MNG_EXT mng_retcode MNG_DECL mng_putchunk_mpng_frame (mng_handle hHandle,
  5501. mng_uint32 iEntry,
  5502. mng_uint32 iX,
  5503. mng_uint32 iY,
  5504. mng_uint32 iWidth,
  5505. mng_uint32 iHeight,
  5506. mng_int32 iXoffset,
  5507. mng_int32 iYoffset,
  5508. mng_uint16 iTicks)
  5509. {
  5510. mng_datap pData;
  5511. mng_chunkp pChunk;
  5512. mng_mpng_framep pFrame;
  5513. #ifdef MNG_SUPPORT_TRACE
  5514. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MPNG_FRAME, MNG_LC_START);
  5515. #endif
  5516. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  5517. pData = (mng_datap)hHandle; /* and make it addressable */
  5518. if (!pData->bCreating) /* aren't we creating a new file ? */
  5519. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  5520. /* must have had a IHDR first! */
  5521. if (pData->iFirstchunkadded != MNG_UINT_IHDR)
  5522. MNG_ERROR (pData, MNG_NOHEADER)
  5523. pChunk = pData->pLastchunk; /* last one must have been mpNG ! */
  5524. if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_mpNG)
  5525. MNG_ERROR (pData, MNG_NOCORRCHUNK)
  5526. /* index out of bounds ? */
  5527. if (iEntry >= (((mng_mpngp)pChunk)->iFramessize / sizeof (mng_mpng_frame)))
  5528. MNG_ERROR (pData, MNG_INVALIDENTRYIX)
  5529. /* address proper entry */
  5530. pFrame = ((mng_mpngp)pChunk)->pFrames + iEntry;
  5531. /* fill entry */
  5532. pFrame->iX = iX;
  5533. pFrame->iY = iY;
  5534. pFrame->iWidth = iWidth;
  5535. pFrame->iHeight = iHeight;
  5536. pFrame->iXoffset = iXoffset;
  5537. pFrame->iYoffset = iYoffset;
  5538. pFrame->iTicks = iTicks;
  5539. #ifdef MNG_SUPPORT_TRACE
  5540. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MPNG_FRAME, MNG_LC_END);
  5541. #endif
  5542. return MNG_NOERROR;
  5543. }
  5544. #endif
  5545. /* ************************************************************************** */
  5546. #ifndef MNG_SKIPCHUNK_evNT
  5547. mng_retcode MNG_DECL mng_putchunk_evnt (mng_handle hHandle,
  5548. mng_uint32 iCount)
  5549. {
  5550. mng_datap pData;
  5551. mng_chunkp pChunk;
  5552. mng_retcode iRetcode;
  5553. #ifndef MNG_OPTIMIZE_CHUNKREADER
  5554. mng_chunk_header sChunkheader =
  5555. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  5556. {MNG_UINT_evNT, mng_init_general, mng_free_evnt, mng_read_evnt, mng_write_evnt, mng_assign_evnt, 0, 0, sizeof(mng_evnt)};
  5557. #else
  5558. {MNG_UINT_evNT, mng_init_evnt, mng_free_evnt, mng_read_evnt, mng_write_evnt, mng_assign_evnt, 0, 0};
  5559. #endif
  5560. #else
  5561. mng_chunk_header sChunkheader;
  5562. #endif
  5563. #ifdef MNG_SUPPORT_TRACE
  5564. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_EVNT, MNG_LC_START);
  5565. #endif
  5566. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  5567. pData = (mng_datap)hHandle; /* and make it addressable */
  5568. if (!pData->bCreating) /* aren't we creating a new file ? */
  5569. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  5570. /* must have had a MHDR first! */
  5571. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  5572. MNG_ERROR (pData, MNG_NOHEADER)
  5573. /* prevent misplaced TERM ! */
  5574. if (!check_term (pData, MNG_UINT_evNT))
  5575. MNG_ERROR (pData, MNG_TERMSEQERROR)
  5576. /* create the chunk */
  5577. #ifndef MNG_OPTIMIZE_CHUNKREADER
  5578. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  5579. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  5580. #else
  5581. iRetcode = mng_init_evnt (pData, &sChunkheader, &pChunk);
  5582. #endif
  5583. #else
  5584. mng_get_chunkheader(MNG_UINT_evNT, &sChunkheader);
  5585. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  5586. #endif
  5587. if (iRetcode) /* on error bail out */
  5588. return iRetcode;
  5589. /* fill the chunk */
  5590. ((mng_evntp)pChunk)->iCount = iCount;
  5591. if (iCount)
  5592. MNG_ALLOC (pData, ((mng_evntp)pChunk)->pEntries, iCount * sizeof (mng_evnt_entry));
  5593. mng_add_chunk (pData, pChunk); /* add it to the list */
  5594. #ifdef MNG_SUPPORT_TRACE
  5595. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_EVNT, MNG_LC_END);
  5596. #endif
  5597. return MNG_NOERROR;
  5598. }
  5599. /* ************************************************************************** */
  5600. mng_retcode MNG_DECL mng_putchunk_evnt_entry (mng_handle hHandle,
  5601. mng_uint32 iEntry,
  5602. mng_uint8 iEventtype,
  5603. mng_uint8 iMasktype,
  5604. mng_int32 iLeft,
  5605. mng_int32 iRight,
  5606. mng_int32 iTop,
  5607. mng_int32 iBottom,
  5608. mng_uint16 iObjectid,
  5609. mng_uint8 iIndex,
  5610. mng_uint32 iSegmentnamesize,
  5611. mng_pchar zSegmentname)
  5612. {
  5613. mng_datap pData;
  5614. mng_chunkp pChunk;
  5615. mng_evnt_entryp pEntry;
  5616. #ifdef MNG_SUPPORT_TRACE
  5617. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_EVNT_ENTRY, MNG_LC_START);
  5618. #endif
  5619. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  5620. pData = (mng_datap)hHandle; /* and make it addressable */
  5621. if (!pData->bCreating) /* aren't we creating a new file ? */
  5622. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  5623. /* must have had a MHDR first! */
  5624. if (pData->iFirstchunkadded != MNG_UINT_MHDR)
  5625. MNG_ERROR (pData, MNG_NOHEADER)
  5626. pChunk = pData->pLastchunk; /* last one must have been evNT ! */
  5627. if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_evNT)
  5628. MNG_ERROR (pData, MNG_NOCORRCHUNK)
  5629. /* index out of bounds ? */
  5630. if (iEntry >= ((mng_evntp)pChunk)->iCount)
  5631. MNG_ERROR (pData, MNG_INVALIDENTRYIX)
  5632. /* address proper entry */
  5633. pEntry = ((mng_evntp)pChunk)->pEntries + iEntry;
  5634. /* fill entry */
  5635. pEntry->iEventtype = iEventtype;
  5636. pEntry->iMasktype = iMasktype;
  5637. pEntry->iLeft = iLeft;
  5638. pEntry->iRight = iRight;
  5639. pEntry->iTop = iTop;
  5640. pEntry->iBottom = iBottom;
  5641. pEntry->iObjectid = iObjectid;
  5642. pEntry->iIndex = iIndex;
  5643. pEntry->iSegmentnamesize = iSegmentnamesize;
  5644. if (iSegmentnamesize)
  5645. {
  5646. MNG_ALLOC (pData, pEntry->zSegmentname, iSegmentnamesize + 1);
  5647. MNG_COPY (pEntry->zSegmentname, zSegmentname, iSegmentnamesize);
  5648. }
  5649. #ifdef MNG_SUPPORT_TRACE
  5650. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_EVNT_ENTRY, MNG_LC_END);
  5651. #endif
  5652. return MNG_NOERROR;
  5653. }
  5654. #endif
  5655. /* ************************************************************************** */
  5656. mng_retcode MNG_DECL mng_putchunk_unknown (mng_handle hHandle,
  5657. mng_chunkid iChunkname,
  5658. mng_uint32 iRawlen,
  5659. mng_ptr pRawdata)
  5660. {
  5661. mng_datap pData;
  5662. mng_chunkp pChunk;
  5663. mng_retcode iRetcode;
  5664. #ifndef MNG_OPTIMIZE_CHUNKREADER
  5665. mng_chunk_header sChunkheader =
  5666. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  5667. {MNG_UINT_HUH, mng_init_general, mng_free_unknown, mng_read_unknown, mng_write_unknown, mng_assign_unknown, 0, 0, sizeof(mng_unknown_chunk)};
  5668. #else
  5669. {MNG_UINT_HUH, mng_init_unknown, mng_free_unknown, mng_read_unknown, mng_write_unknown, mng_assign_unknown, 0, 0};
  5670. #endif
  5671. #else
  5672. mng_chunk_header sChunkheader;
  5673. #endif
  5674. #ifdef MNG_SUPPORT_TRACE
  5675. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_UNKNOWN, MNG_LC_START);
  5676. #endif
  5677. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  5678. pData = (mng_datap)hHandle; /* and make it addressable */
  5679. if (!pData->bCreating) /* aren't we creating a new file ? */
  5680. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  5681. /* must have had a header first! */
  5682. if (pData->iFirstchunkadded == 0)
  5683. MNG_ERROR (pData, MNG_NOHEADER)
  5684. /* prevent misplaced TERM ! */
  5685. if (!check_term (pData, iChunkname))
  5686. MNG_ERROR (pData, MNG_TERMSEQERROR)
  5687. /* create the chunk */
  5688. #ifndef MNG_OPTIMIZE_CHUNKREADER
  5689. #ifdef MNG_OPTIMIZE_CHUNKINITFREE
  5690. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  5691. #else
  5692. iRetcode = mng_init_unknown (pData, &sChunkheader, &pChunk);
  5693. #endif
  5694. #else
  5695. mng_get_chunkheader(MNG_UINT_HUH, &sChunkheader);
  5696. iRetcode = mng_init_general (pData, &sChunkheader, &pChunk);
  5697. #endif
  5698. if (iRetcode) /* on error bail out */
  5699. return iRetcode;
  5700. /* fill the chunk */
  5701. ((mng_unknown_chunkp)pChunk)->sHeader.iChunkname = iChunkname;
  5702. ((mng_unknown_chunkp)pChunk)->iDatasize = iRawlen;
  5703. if (iRawlen)
  5704. {
  5705. MNG_ALLOC (pData, ((mng_unknown_chunkp)pChunk)->pData, iRawlen);
  5706. MNG_COPY (((mng_unknown_chunkp)pChunk)->pData, pRawdata, iRawlen);
  5707. }
  5708. mng_add_chunk (pData, pChunk); /* add it to the list */
  5709. #ifdef MNG_SUPPORT_TRACE
  5710. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_UNKNOWN, MNG_LC_END);
  5711. #endif
  5712. return MNG_NOERROR;
  5713. }
  5714. /* ************************************************************************** */
  5715. #endif /* MNG_INCLUDE_WRITE_PROCS */
  5716. /* ************************************************************************** */
  5717. /* ************************************************************************** */
  5718. mng_retcode MNG_DECL mng_getimgdata_seq (mng_handle hHandle,
  5719. mng_uint32 iSeqnr,
  5720. mng_uint32 iCanvasstyle,
  5721. mng_getcanvasline fGetcanvasline)
  5722. {
  5723. #ifdef MNG_SUPPORT_TRACE
  5724. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_SEQ, MNG_LC_START);
  5725. #endif
  5726. #ifdef MNG_SUPPORT_TRACE
  5727. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_SEQ, MNG_LC_END);
  5728. #endif
  5729. return MNG_FNNOTIMPLEMENTED;
  5730. }
  5731. /* ************************************************************************** */
  5732. mng_retcode MNG_DECL mng_getimgdata_chunkseq (mng_handle hHandle,
  5733. mng_uint32 iSeqnr,
  5734. mng_uint32 iCanvasstyle,
  5735. mng_getcanvasline fGetcanvasline)
  5736. {
  5737. #ifdef MNG_SUPPORT_TRACE
  5738. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_CHUNKSEQ, MNG_LC_START);
  5739. #endif
  5740. #ifdef MNG_SUPPORT_TRACE
  5741. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_CHUNKSEQ, MNG_LC_END);
  5742. #endif
  5743. return MNG_FNNOTIMPLEMENTED;
  5744. }
  5745. /* ************************************************************************** */
  5746. mng_retcode MNG_DECL mng_getimgdata_chunk (mng_handle hHandle,
  5747. mng_handle hChunk,
  5748. mng_uint32 iCanvasstyle,
  5749. mng_getcanvasline fGetcanvasline)
  5750. {
  5751. #ifdef MNG_SUPPORT_TRACE
  5752. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_CHUNK, MNG_LC_START);
  5753. #endif
  5754. #ifdef MNG_SUPPORT_TRACE
  5755. MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_CHUNK, MNG_LC_END);
  5756. #endif
  5757. return MNG_FNNOTIMPLEMENTED;
  5758. }
  5759. /* ************************************************************************** */
  5760. /* ************************************************************************** */
  5761. #ifdef MNG_INCLUDE_WRITE_PROCS
  5762. /* ************************************************************************** */
  5763. mng_retcode MNG_DECL mng_putimgdata_ihdr (mng_handle hHandle,
  5764. mng_uint32 iWidth,
  5765. mng_uint32 iHeight,
  5766. mng_uint8 iColortype,
  5767. mng_uint8 iBitdepth,
  5768. mng_uint8 iCompression,
  5769. mng_uint8 iFilter,
  5770. mng_uint8 iInterlace,
  5771. mng_uint32 iCanvasstyle,
  5772. mng_getcanvasline fGetcanvasline)
  5773. {
  5774. #ifdef MNG_SUPPORT_TRACE
  5775. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTIMGDATA_IHDR, MNG_LC_START);
  5776. #endif
  5777. #ifdef MNG_SUPPORT_TRACE
  5778. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTIMGDATA_IHDR, MNG_LC_END);
  5779. #endif
  5780. return MNG_FNNOTIMPLEMENTED;
  5781. }
  5782. /* ************************************************************************** */
  5783. #ifdef MNG_INCLUDE_JNG
  5784. mng_retcode MNG_DECL mng_putimgdata_jhdr (mng_handle hHandle,
  5785. mng_uint32 iWidth,
  5786. mng_uint32 iHeight,
  5787. mng_uint8 iColortype,
  5788. mng_uint8 iBitdepth,
  5789. mng_uint8 iCompression,
  5790. mng_uint8 iInterlace,
  5791. mng_uint8 iAlphaBitdepth,
  5792. mng_uint8 iAlphaCompression,
  5793. mng_uint8 iAlphaFilter,
  5794. mng_uint8 iAlphaInterlace,
  5795. mng_uint32 iCanvasstyle,
  5796. mng_getcanvasline fGetcanvasline)
  5797. {
  5798. #ifdef MNG_SUPPORT_TRACE
  5799. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTIMGDATA_JHDR, MNG_LC_START);
  5800. #endif
  5801. #ifdef MNG_SUPPORT_TRACE
  5802. MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTIMGDATA_JHDR, MNG_LC_END);
  5803. #endif
  5804. return MNG_FNNOTIMPLEMENTED;
  5805. }
  5806. #endif
  5807. /* ************************************************************************** */
  5808. mng_retcode MNG_DECL mng_updatemngheader (mng_handle hHandle,
  5809. mng_uint32 iFramecount,
  5810. mng_uint32 iLayercount,
  5811. mng_uint32 iPlaytime)
  5812. {
  5813. mng_datap pData;
  5814. mng_chunkp pChunk;
  5815. #ifdef MNG_SUPPORT_TRACE
  5816. MNG_TRACE (((mng_datap)hHandle), MNG_FN_UPDATEMNGHEADER, MNG_LC_START);
  5817. #endif
  5818. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  5819. pData = (mng_datap)hHandle; /* and make it addressable */
  5820. if (!pData->bCreating) /* aren't we creating a new file ? */
  5821. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  5822. /* must be a MNG animation! */
  5823. if ((pData->eImagetype != mng_it_mng) || (pData->iFirstchunkadded != MNG_UINT_MHDR))
  5824. MNG_ERROR (pData, MNG_NOMHDR)
  5825. pChunk = pData->pFirstchunk; /* get the first chunk */
  5826. /* and update the variables */
  5827. ((mng_mhdrp)pChunk)->iFramecount = iFramecount;
  5828. ((mng_mhdrp)pChunk)->iLayercount = iLayercount;
  5829. ((mng_mhdrp)pChunk)->iPlaytime = iPlaytime;
  5830. #ifdef MNG_SUPPORT_TRACE
  5831. MNG_TRACE (((mng_datap)hHandle), MNG_FN_UPDATEMNGHEADER, MNG_LC_END);
  5832. #endif
  5833. return MNG_NOERROR;
  5834. }
  5835. /* ************************************************************************** */
  5836. mng_retcode MNG_DECL mng_updatemngsimplicity (mng_handle hHandle,
  5837. mng_uint32 iSimplicity)
  5838. {
  5839. mng_datap pData;
  5840. mng_chunkp pChunk;
  5841. #ifdef MNG_SUPPORT_TRACE
  5842. MNG_TRACE (((mng_datap)hHandle), MNG_FN_UPDATEMNGSIMPLICITY, MNG_LC_START);
  5843. #endif
  5844. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  5845. pData = (mng_datap)hHandle; /* and make it addressable */
  5846. if (!pData->bCreating) /* aren't we creating a new file ? */
  5847. MNG_ERROR (pData, MNG_FUNCTIONINVALID)
  5848. /* must be a MNG animation! */
  5849. if ((pData->eImagetype != mng_it_mng) || (pData->iFirstchunkadded != MNG_UINT_MHDR))
  5850. MNG_ERROR (pData, MNG_NOMHDR)
  5851. pChunk = pData->pFirstchunk; /* get the first chunk */
  5852. /* and update the variable */
  5853. ((mng_mhdrp)pChunk)->iSimplicity = iSimplicity;
  5854. #ifdef MNG_SUPPORT_TRACE
  5855. MNG_TRACE (((mng_datap)hHandle), MNG_FN_UPDATEMNGSIMPLICITY, MNG_LC_END);
  5856. #endif
  5857. return MNG_NOERROR;
  5858. }
  5859. /* ************************************************************************** */
  5860. #endif /* MNG_INCLUDE_WRITE_PROCS */
  5861. /* ************************************************************************** */
  5862. #endif /* MNG_ACCESS_CHUNKS */
  5863. /* ************************************************************************** */
  5864. /* * end of file * */
  5865. /* ************************************************************************** */