PageRenderTime 29ms CodeModel.GetById 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/FreeImage/Source/LibMNG/libmng_hlapi.c

https://bitbucket.org/cabalistic/ogredeps/
C | 1620 lines | 1212 code | 145 blank | 263 comment | 38 complexity | aa7cea956d6561f46aaae96c747b1d41 MD5 | raw file
Possible License(s): LGPL-3.0, BSD-3-Clause, CPL-1.0, Unlicense, GPL-2.0, GPL-3.0, LGPL-2.0, MPL-2.0-no-copyleft-exception, BSD-2-Clause, LGPL-2.1
  1. /* ************************************************************************** */
  2. /* * For conditions of distribution and use, * */
  3. /* * see copyright notice in libmng.h * */
  4. /* ************************************************************************** */
  5. /* * * */
  6. /* * project : libmng * */
  7. /* * file : libmng_hlapi.c copyright (c) 2000-2007 G.Juyn * */
  8. /* * version : 1.0.10 * */
  9. /* * * */
  10. /* * purpose : high-level application API (implementation) * */
  11. /* * * */
  12. /* * author : G.Juyn * */
  13. /* * * */
  14. /* * comment : implementation of the high-level function interface * */
  15. /* * for applications. * */
  16. /* * * */
  17. /* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */
  18. /* * - added init of iPLTEcount * */
  19. /* * 0.5.1 - 05/08/2000 - G.Juyn * */
  20. /* * - changed calling-convention definition * */
  21. /* * - changed status-handling of display-routines * */
  22. /* * - added versioning-control routines * */
  23. /* * - filled the write routine * */
  24. /* * - changed strict-ANSI stuff * */
  25. /* * 0.5.1 - 05/11/2000 - G.Juyn * */
  26. /* * - added callback error-reporting support * */
  27. /* * 0.5.1 - 05/12/2000 - G.Juyn * */
  28. /* * - changed trace to macro for callback error-reporting * */
  29. /* * 0.5.1 - 05/13/2000 - G.Juyn * */
  30. /* * - added eMNGma hack (will be removed in 1.0.0 !!!) * */
  31. /* * - added TERM animation object pointer (easier reference) * */
  32. /* * 0.5.1 - 05/14/2000 - G.Juyn * */
  33. /* * - added cleanup of saved-data (SAVE/SEEK processing) * */
  34. /* * 0.5.1 - 05/16/2000 - G.Juyn * */
  35. /* * - moved the actual write_graphic functionality from here * */
  36. /* * to its appropriate function in the mng_write module * */
  37. /* * * */
  38. /* * 0.5.2 - 05/19/2000 - G.Juyn * */
  39. /* * - cleaned up some code regarding mixed support * */
  40. /* * - added JNG support * */
  41. /* * 0.5.2 - 05/24/2000 - G.Juyn * */
  42. /* * - moved init of default zlib parms here from "mng_zlib.c" * */
  43. /* * - added init of default IJG parms * */
  44. /* * 0.5.2 - 05/29/2000 - G.Juyn * */
  45. /* * - fixed inconsistancy with freeing global iCCP profile * */
  46. /* * 0.5.2 - 05/30/2000 - G.Juyn * */
  47. /* * - added delta-image field initialization * */
  48. /* * 0.5.2 - 06/06/2000 - G.Juyn * */
  49. /* * - added initialization of the buffer-suspend parameter * */
  50. /* * * */
  51. /* * 0.5.3 - 06/16/2000 - G.Juyn * */
  52. /* * - added initialization of update-region for refresh * */
  53. /* * - added initialization of Needrefresh parameter * */
  54. /* * 0.5.3 - 06/17/2000 - G.Juyn * */
  55. /* * - added initialization of Deltaimmediate * */
  56. /* * 0.5.3 - 06/21/2000 - G.Juyn * */
  57. /* * - added initialization of Speed * */
  58. /* * - added initialization of Imagelevel * */
  59. /* * 0.5.3 - 06/26/2000 - G.Juyn * */
  60. /* * - changed userdata variable to mng_ptr * */
  61. /* * 0.5.3 - 06/29/2000 - G.Juyn * */
  62. /* * - fixed initialization routine for new mng_handle type * */
  63. /* * * */
  64. /* * 0.9.1 - 07/06/2000 - G.Juyn * */
  65. /* * - changed mng_display_resume to allow to be called after * */
  66. /* * a suspension return with MNG_NEEDMOREDATA * */
  67. /* * - added returncode MNG_NEEDTIMERWAIT for timer breaks * */
  68. /* * 0.9.1 - 07/07/2000 - G.Juyn * */
  69. /* * - implemented support for freeze/reset/resume & go_xxxx * */
  70. /* * 0.9.1 - 07/08/2000 - G.Juyn * */
  71. /* * - added support for improved timing * */
  72. /* * - added support for improved I/O-suspension * */
  73. /* * 0.9.1 - 07/14/2000 - G.Juyn * */
  74. /* * - changed EOF processing behavior * */
  75. /* * 0.9.1 - 07/15/2000 - G.Juyn * */
  76. /* * - added callbacks for SAVE/SEEK processing * */
  77. /* * - added variable for NEEDSECTIONWAIT breaks * */
  78. /* * - added variable for freeze & reset processing * */
  79. /* * 0.9.1 - 07/17/2000 - G.Juyn * */
  80. /* * - added error cleanup processing * */
  81. /* * - fixed support for mng_display_reset() * */
  82. /* * - fixed suspension-buffering for 32K+ chunks * */
  83. /* * * */
  84. /* * 0.9.2 - 07/29/2000 - G.Juyn * */
  85. /* * - fixed small bugs in display processing * */
  86. /* * 0.9.2 - 07/31/2000 - G.Juyn * */
  87. /* * - fixed wrapping of suspension parameters * */
  88. /* * 0.9.2 - 08/04/2000 - G.Juyn * */
  89. /* * - B111096 - fixed large-buffer read-suspension * */
  90. /* * 0.9.2 - 08/05/2000 - G.Juyn * */
  91. /* * - changed file-prefixes * */
  92. /* * * */
  93. /* * 0.9.3 - 09/07/2000 - G.Juyn * */
  94. /* * - added support for new filter_types * */
  95. /* * 0.9.3 - 09/10/2000 - G.Juyn * */
  96. /* * - fixed DEFI behavior * */
  97. /* * 0.9.3 - 10/11/2000 - G.Juyn * */
  98. /* * - added support for nEED * */
  99. /* * 0.9.3 - 10/16/2000 - G.Juyn * */
  100. /* * - added optional support for bKGD for PNG images * */
  101. /* * - raised initial maximum canvas size * */
  102. /* * - added support for JDAA * */
  103. /* * 0.9.3 - 10/17/2000 - G.Juyn * */
  104. /* * - added callback to process non-critical unknown chunks * */
  105. /* * - fixed support for delta-images during read() / display() * */
  106. /* * 0.9.3 - 10/18/2000 - G.Juyn * */
  107. /* * - added closestream() processing for mng_cleanup() * */
  108. /* * 0.9.3 - 10/27/2000 - G.Juyn * */
  109. /* * - fixed separate read() & display() processing * */
  110. /* * * */
  111. /* * 0.9.4 - 11/20/2000 - G.Juyn * */
  112. /* * - fixed unwanted repetition in mng_readdisplay() * */
  113. /* * 0.9.4 - 11/24/2000 - G.Juyn * */
  114. /* * - moved restore of object 0 to libmng_display * */
  115. /* * * */
  116. /* * 1.0.1 - 02/08/2001 - G.Juyn * */
  117. /* * - added MEND processing callback * */
  118. /* * 1.0.1 - 02/13/2001 - G.Juyn * */
  119. /* * - fixed first FRAM_MODE=4 timing problem * */
  120. /* * 1.0.1 - 04/21/2001 - G.Juyn * */
  121. /* * - fixed bug with display_reset/display_resume (Thanks G!) * */
  122. /* * 1.0.1 - 04/22/2001 - G.Juyn * */
  123. /* * - fixed memory-leak (Thanks Gregg!) * */
  124. /* * 1.0.1 - 04/23/2001 - G.Juyn * */
  125. /* * - fixed reset_rundata to drop all objects * */
  126. /* * 1.0.1 - 04/25/2001 - G.Juyn * */
  127. /* * - moved mng_clear_cms to libmng_cms * */
  128. /* * * */
  129. /* * 1.0.2 - 06/23/2001 - G.Juyn * */
  130. /* * - added optimization option for MNG-video playback * */
  131. /* * - added processterm callback * */
  132. /* * 1.0.2 - 06/25/2001 - G.Juyn * */
  133. /* * - added option to turn off progressive refresh * */
  134. /* * * */
  135. /* * 1.0.5 - 07/08/2002 - G.Juyn * */
  136. /* * - B578572 - removed eMNGma hack (thanks Dimitri!) * */
  137. /* * 1.0.5 - 07/16/2002 - G.Juyn * */
  138. /* * - B581625 - large chunks fail with suspension reads * */
  139. /* * 1.0.5 - 08/19/2002 - G.Juyn * */
  140. /* * - B597134 - libmng pollutes the linker namespace * */
  141. /* * 1.0.5 - 09/15/2002 - G.Juyn * */
  142. /* * - fixed LOOP iteration=0 special case * */
  143. /* * 1.0.5 - 10/07/2002 - G.Juyn * */
  144. /* * - added another fix for misplaced TERM chunk * */
  145. /* * - completed support for condition=2 in TERM chunk * */
  146. /* * - added beta version function & constant * */
  147. /* * 1.0.5 - 10/11/2002 - G.Juyn * */
  148. /* * - added mng_status_dynamic to supports function * */
  149. /* * 1.0.5 - 11/04/2002 - G.Juyn * */
  150. /* * - changed FRAMECOUNT/LAYERCOUNT/PLAYTIME error to warning * */
  151. /* * 1.0.5 - 11/07/2002 - G.Juyn * */
  152. /* * - added support to get totals after mng_read() * */
  153. /* * 1.0.5 - 11/29/2002 - G.Juyn * */
  154. /* * - fixed goxxxxx() support for zero values * */
  155. /* * * */
  156. /* * 1.0.6 - 05/25/2003 - G.R-P * */
  157. /* * - added MNG_SKIPCHUNK_cHNK footprint optimizations * */
  158. /* * 1.0.6 - 07/11/2003 - G.R-P * */
  159. /* * - added conditionals zlib and jpeg property accessors * */
  160. /* * 1.0.6 - 07/14/2003 - G.R-P * */
  161. /* * - added conditionals around "mng_display_go*" and other * */
  162. /* * unused functions * */
  163. /* * 1.0.6 - 07/29/2003 - G.R-P * */
  164. /* * - added conditionals around PAST chunk support * */
  165. /* * * */
  166. /* * 1.0.7 - 03/07/2004 - G. Randers-Pehrson * */
  167. /* * - put gamma, cms-related declarations inside #ifdef * */
  168. /* * 1.0.7 - 03/10/2004 - G.R-P * */
  169. /* * - added conditionals around openstream/closestream * */
  170. /* * 1.0.7 - 03/24/2004 - G.R-P * */
  171. /* * - fixed zTXT -> zTXt typo * */
  172. /* * * */
  173. /* * 1.0.8 - 04/02/2004 - G.Juyn * */
  174. /* * - added CRC existence & checking flags * */
  175. /* * 1.0.8 - 04/10/2004 - G.Juyn * */
  176. /* * - added data-push mechanisms for specialized decoders * */
  177. /* * 1.0.8 - 07/06/2004 - G.R-P * */
  178. /* * - defend against using undefined openstream function * */
  179. /* * 1.0.8 - 08/02/2004 - G.Juyn * */
  180. /* * - added conditional to allow easier writing of large MNG's * */
  181. /* * * */
  182. /* * 1.0.9 - 08/17/2004 - G.R-P * */
  183. /* * - added more SKIPCHUNK conditionals * */
  184. /* * 1.0.9 - 09/25/2004 - G.Juyn * */
  185. /* * - replaced MNG_TWEAK_LARGE_FILES with permanent solution * */
  186. /* * 1.0.9 - 10/03/2004 - G.Juyn * */
  187. /* * - added function to retrieve current FRAM delay * */
  188. /* * 1.0.9 - 12/20/2004 - G.Juyn * */
  189. /* * - cleaned up macro-invocations (thanks to D. Airlie) * */
  190. /* * * */
  191. /* * 1.0.10 - 07/06/2005 - G.R-P * */
  192. /* * - added more SKIPCHUNK conditionals * */
  193. /* * 1.0.10 - 04/08/2007 - G.Juyn * */
  194. /* * - added support for mPNG proposal * */
  195. /* * 1.0.10 - 04/12/2007 - G.Juyn * */
  196. /* * - added support for ANG proposal * */
  197. /* * 1.0.10 - 07/06/2007 - G.R-P bugfix by Lucas Quintana * */
  198. /* * * */
  199. /* ************************************************************************** */
  200. #include "libmng.h"
  201. #include "libmng_data.h"
  202. #include "libmng_error.h"
  203. #include "libmng_trace.h"
  204. #ifdef __BORLANDC__
  205. #pragma hdrstop
  206. #endif
  207. #include "libmng_objects.h"
  208. #include "libmng_object_prc.h"
  209. #include "libmng_chunks.h"
  210. #include "libmng_memory.h"
  211. #include "libmng_read.h"
  212. #include "libmng_write.h"
  213. #include "libmng_display.h"
  214. #include "libmng_zlib.h"
  215. #include "libmng_jpeg.h"
  216. #include "libmng_cms.h"
  217. #include "libmng_pixels.h"
  218. #if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
  219. #pragma option -A /* force ANSI-C */
  220. #endif
  221. /* ************************************************************************** */
  222. /* * * */
  223. /* * local routines * */
  224. /* * * */
  225. /* ************************************************************************** */
  226. #ifdef MNG_SUPPORT_DISPLAY
  227. MNG_LOCAL mng_retcode mng_drop_objects (mng_datap pData,
  228. mng_bool bDropaniobj)
  229. {
  230. mng_objectp pObject;
  231. mng_objectp pNext;
  232. mng_cleanupobject fCleanup;
  233. #ifdef MNG_SUPPORT_TRACE
  234. MNG_TRACE (pData, MNG_FN_DROP_OBJECTS, MNG_LC_START);
  235. #endif
  236. pObject = pData->pFirstimgobj; /* get first stored image-object (if any) */
  237. while (pObject) /* more objects to discard ? */
  238. {
  239. pNext = ((mng_object_headerp)pObject)->pNext;
  240. /* call appropriate cleanup */
  241. fCleanup = ((mng_object_headerp)pObject)->fCleanup;
  242. fCleanup (pData, pObject);
  243. pObject = pNext; /* neeeext */
  244. }
  245. pData->pFirstimgobj = MNG_NULL; /* clean this up!!! */
  246. pData->pLastimgobj = MNG_NULL;
  247. if (bDropaniobj) /* drop animation objects ? */
  248. {
  249. pObject = pData->pFirstaniobj; /* get first stored animation-object (if any) */
  250. while (pObject) /* more objects to discard ? */
  251. {
  252. pNext = ((mng_object_headerp)pObject)->pNext;
  253. /* call appropriate cleanup */
  254. fCleanup = ((mng_object_headerp)pObject)->fCleanup;
  255. fCleanup (pData, pObject);
  256. pObject = pNext; /* neeeext */
  257. }
  258. pData->pFirstaniobj = MNG_NULL; /* clean this up!!! */
  259. pData->pLastaniobj = MNG_NULL;
  260. #ifdef MNG_SUPPORT_DYNAMICMNG
  261. pObject = pData->pFirstevent; /* get first event-object (if any) */
  262. while (pObject) /* more objects to discard ? */
  263. {
  264. pNext = ((mng_object_headerp)pObject)->pNext;
  265. /* call appropriate cleanup */
  266. fCleanup = ((mng_object_headerp)pObject)->fCleanup;
  267. fCleanup (pData, pObject);
  268. pObject = pNext; /* neeeext */
  269. }
  270. pData->pFirstevent = MNG_NULL; /* clean this up!!! */
  271. pData->pLastevent = MNG_NULL;
  272. #endif
  273. }
  274. #ifdef MNG_INCLUDE_MPNG_PROPOSAL
  275. if (pData->pMPNG) /* drop MPNG data (if any) */
  276. {
  277. fCleanup = ((mng_object_headerp)pData->pMPNG)->fCleanup;
  278. fCleanup (pData, pData->pMPNG);
  279. pData->pMPNG = MNG_NULL;
  280. }
  281. #endif
  282. #ifdef MNG_INCLUDE_ANG_PROPOSAL
  283. if (pData->pANG) /* drop ANG data (if any) */
  284. {
  285. fCleanup = ((mng_object_headerp)pData->pANG)->fCleanup;
  286. fCleanup (pData, pData->pANG);
  287. pData->pANG = MNG_NULL;
  288. }
  289. #endif
  290. #ifdef MNG_SUPPORT_TRACE
  291. MNG_TRACE (pData, MNG_FN_DROP_OBJECTS, MNG_LC_END);
  292. #endif
  293. return MNG_NOERROR;
  294. }
  295. #endif /* MNG_SUPPORT_DISPLAY */
  296. /* ************************************************************************** */
  297. #ifdef MNG_SUPPORT_DISPLAY
  298. #ifndef MNG_SKIPCHUNK_SAVE
  299. MNG_LOCAL mng_retcode mng_drop_savedata (mng_datap pData)
  300. {
  301. #ifdef MNG_SUPPORT_TRACE
  302. MNG_TRACE (pData, MNG_FN_DROP_SAVEDATA, MNG_LC_START);
  303. #endif
  304. if (pData->pSavedata) /* sanity check */
  305. { /* address it more directly */
  306. mng_savedatap pSave = pData->pSavedata;
  307. if (pSave->iGlobalProfilesize) /* cleanup the profile ? */
  308. MNG_FREEX (pData, pSave->pGlobalProfile, pSave->iGlobalProfilesize);
  309. /* cleanup the save structure */
  310. MNG_FREE (pData, pData->pSavedata, sizeof (mng_savedata));
  311. }
  312. #ifdef MNG_SUPPORT_TRACE
  313. MNG_TRACE (pData, MNG_FN_DROP_SAVEDATA, MNG_LC_END);
  314. #endif
  315. return MNG_NOERROR;
  316. }
  317. #endif
  318. #endif /* MNG_SUPPORT_DISPLAY */
  319. /* ************************************************************************** */
  320. #ifdef MNG_SUPPORT_DISPLAY
  321. MNG_LOCAL mng_retcode mng_reset_rundata (mng_datap pData)
  322. {
  323. mng_drop_invalid_objects (pData); /* drop invalidly stored objects */
  324. #ifndef MNG_SKIPCHUNK_SAVE
  325. mng_drop_savedata (pData); /* drop stored savedata */
  326. #endif
  327. mng_reset_objzero (pData); /* reset object 0 */
  328. /* drop stored objects (if any) */
  329. mng_drop_objects (pData, MNG_FALSE);
  330. pData->bFramedone = MNG_FALSE;
  331. pData->iFrameseq = 0; /* reset counters & stuff */
  332. pData->iLayerseq = 0;
  333. pData->iFrametime = 0;
  334. pData->bSkipping = MNG_FALSE;
  335. #ifdef MNG_SUPPORT_DYNAMICMNG
  336. pData->bRunningevent = MNG_FALSE;
  337. pData->bStopafterseek = MNG_FALSE;
  338. pData->iEventx = 0;
  339. pData->iEventy = 0;
  340. pData->pLastmousemove = MNG_NULL;
  341. #endif
  342. pData->iRequestframe = 0;
  343. pData->iRequestlayer = 0;
  344. pData->iRequesttime = 0;
  345. pData->bSearching = MNG_FALSE;
  346. pData->iRuntime = 0;
  347. pData->iSynctime = 0;
  348. pData->iStarttime = 0;
  349. pData->iEndtime = 0;
  350. pData->bRunning = MNG_FALSE;
  351. pData->bTimerset = MNG_FALSE;
  352. pData->iBreakpoint = 0;
  353. pData->bSectionwait = MNG_FALSE;
  354. pData->bFreezing = MNG_FALSE;
  355. pData->bResetting = MNG_FALSE;
  356. pData->bNeedrefresh = MNG_FALSE;
  357. pData->bOnlyfirstframe = MNG_FALSE;
  358. pData->iFramesafterTERM = 0;
  359. pData->iIterations = 0;
  360. /* start of animation objects! */
  361. pData->pCurraniobj = MNG_NULL;
  362. pData->iUpdateleft = 0; /* reset region */
  363. pData->iUpdateright = 0;
  364. pData->iUpdatetop = 0;
  365. pData->iUpdatebottom = 0;
  366. pData->iPLTEcount = 0; /* reset PLTE data */
  367. #ifndef MNG_SKIPCHUNK_DEFI
  368. pData->iDEFIobjectid = 0; /* reset DEFI data */
  369. pData->bDEFIhasdonotshow = MNG_FALSE;
  370. pData->iDEFIdonotshow = 0;
  371. pData->bDEFIhasconcrete = MNG_FALSE;
  372. pData->iDEFIconcrete = 0;
  373. pData->bDEFIhasloca = MNG_FALSE;
  374. pData->iDEFIlocax = 0;
  375. pData->iDEFIlocay = 0;
  376. pData->bDEFIhasclip = MNG_FALSE;
  377. pData->iDEFIclipl = 0;
  378. pData->iDEFIclipr = 0;
  379. pData->iDEFIclipt = 0;
  380. pData->iDEFIclipb = 0;
  381. #endif
  382. #ifndef MNG_SKIPCHUNK_BACK
  383. pData->iBACKred = 0; /* reset BACK data */
  384. pData->iBACKgreen = 0;
  385. pData->iBACKblue = 0;
  386. pData->iBACKmandatory = 0;
  387. pData->iBACKimageid = 0;
  388. pData->iBACKtile = 0;
  389. #endif
  390. #ifndef MNG_SKIPCHUNK_FRAM
  391. pData->iFRAMmode = 1; /* default global FRAM variables */
  392. pData->iFRAMdelay = 1;
  393. pData->iFRAMtimeout = 0x7fffffffl;
  394. pData->bFRAMclipping = MNG_FALSE;
  395. pData->iFRAMclipl = 0;
  396. pData->iFRAMclipr = 0;
  397. pData->iFRAMclipt = 0;
  398. pData->iFRAMclipb = 0;
  399. pData->iFramemode = 1; /* again for the current frame */
  400. pData->iFramedelay = 1;
  401. pData->iFrametimeout = 0x7fffffffl;
  402. pData->bFrameclipping = MNG_FALSE;
  403. pData->iFrameclipl = 0;
  404. pData->iFrameclipr = 0;
  405. pData->iFrameclipt = 0;
  406. pData->iFrameclipb = 0;
  407. pData->iNextdelay = 1;
  408. #endif
  409. #ifndef MNG_SKIPCHUNK_SHOW
  410. pData->iSHOWmode = 0; /* reset SHOW data */
  411. pData->iSHOWfromid = 0;
  412. pData->iSHOWtoid = 0;
  413. pData->iSHOWnextid = 0;
  414. pData->iSHOWskip = 0;
  415. #endif
  416. pData->iGlobalPLTEcount = 0; /* reset global PLTE data */
  417. pData->iGlobalTRNSrawlen = 0; /* reset global tRNS data */
  418. pData->iGlobalGamma = 0; /* reset global gAMA data */
  419. #ifndef MNG_SKIPCHUNK_cHRM
  420. pData->iGlobalWhitepointx = 0; /* reset global cHRM data */
  421. pData->iGlobalWhitepointy = 0;
  422. pData->iGlobalPrimaryredx = 0;
  423. pData->iGlobalPrimaryredy = 0;
  424. pData->iGlobalPrimarygreenx = 0;
  425. pData->iGlobalPrimarygreeny = 0;
  426. pData->iGlobalPrimarybluex = 0;
  427. pData->iGlobalPrimarybluey = 0;
  428. #endif
  429. #ifndef MNG_SKIPCHUNK_sRGB
  430. pData->iGlobalRendintent = 0; /* reset global sRGB data */
  431. #endif
  432. #ifndef MNG_SKIPCHUNK_iCCP
  433. if (pData->iGlobalProfilesize) /* drop global profile (if any) */
  434. MNG_FREE (pData, pData->pGlobalProfile, pData->iGlobalProfilesize);
  435. pData->iGlobalProfilesize = 0;
  436. #endif
  437. #ifndef MNG_SKIPCHUNK_bKGD
  438. pData->iGlobalBKGDred = 0; /* reset global bKGD data */
  439. pData->iGlobalBKGDgreen = 0;
  440. pData->iGlobalBKGDblue = 0;
  441. #endif
  442. #ifndef MNG_NO_DELTA_PNG
  443. /* reset delta-image */
  444. pData->pDeltaImage = MNG_NULL;
  445. pData->iDeltaImagetype = 0;
  446. pData->iDeltatype = 0;
  447. pData->iDeltaBlockwidth = 0;
  448. pData->iDeltaBlockheight = 0;
  449. pData->iDeltaBlockx = 0;
  450. pData->iDeltaBlocky = 0;
  451. pData->bDeltaimmediate = MNG_FALSE;
  452. pData->fDeltagetrow = MNG_NULL;
  453. pData->fDeltaaddrow = MNG_NULL;
  454. pData->fDeltareplacerow = MNG_NULL;
  455. pData->fDeltaputrow = MNG_NULL;
  456. pData->fPromoterow = MNG_NULL;
  457. pData->fPromBitdepth = MNG_NULL;
  458. pData->pPromBuf = MNG_NULL;
  459. pData->iPromColortype = 0;
  460. pData->iPromBitdepth = 0;
  461. pData->iPromFilltype = 0;
  462. pData->iPromWidth = 0;
  463. pData->pPromSrc = MNG_NULL;
  464. pData->pPromDst = MNG_NULL;
  465. #endif
  466. #ifndef MNG_SKIPCHUNK_MAGN
  467. pData->iMAGNfromid = 0;
  468. pData->iMAGNtoid = 0;
  469. #endif
  470. #ifndef MNG_SKIPCHUNK_PAST
  471. pData->iPastx = 0;
  472. pData->iPasty = 0;
  473. #endif
  474. pData->pLastseek = MNG_NULL;
  475. return MNG_NOERROR;
  476. }
  477. #endif /* MNG_SUPPORT_DISPLAY */
  478. /* ************************************************************************** */
  479. MNG_LOCAL void cleanup_errors (mng_datap pData)
  480. {
  481. pData->iErrorcode = MNG_NOERROR;
  482. pData->iSeverity = 0;
  483. pData->iErrorx1 = 0;
  484. pData->iErrorx2 = 0;
  485. pData->zErrortext = MNG_NULL;
  486. return;
  487. }
  488. /* ************************************************************************** */
  489. #ifdef MNG_SUPPORT_READ
  490. MNG_LOCAL mng_retcode make_pushbuffer (mng_datap pData,
  491. mng_ptr pPushdata,
  492. mng_size_t iLength,
  493. mng_bool bTakeownership,
  494. mng_pushdatap * pPush)
  495. {
  496. mng_pushdatap pTemp;
  497. MNG_ALLOC (pData, pTemp, sizeof(mng_pushdata));
  498. pTemp->pNext = MNG_NULL;
  499. if (bTakeownership) /* are we going to own the buffer? */
  500. { /* then just copy the pointer */
  501. pTemp->pData = (mng_uint8p)pPushdata;
  502. }
  503. else
  504. { /* otherwise create new buffer */
  505. MNG_ALLOCX (pData, pTemp->pData, iLength);
  506. if (!pTemp->pData) /* succeeded? */
  507. {
  508. MNG_FREEX (pData, pTemp, sizeof(mng_pushdata));
  509. MNG_ERROR (pData, MNG_OUTOFMEMORY);
  510. }
  511. /* and copy the bytes across */
  512. MNG_COPY (pTemp->pData, pPushdata, iLength);
  513. }
  514. pTemp->iLength = iLength;
  515. pTemp->bOwned = bTakeownership;
  516. pTemp->pDatanext = pTemp->pData;
  517. pTemp->iRemaining = iLength;
  518. *pPush = pTemp; /* return it */
  519. return MNG_NOERROR; /* and all's well */
  520. }
  521. #endif
  522. #ifdef MNG_VERSION_QUERY_SUPPORT
  523. /* ************************************************************************** */
  524. /* * * */
  525. /* * Versioning control * */
  526. /* * * */
  527. /* ************************************************************************** */
  528. mng_pchar MNG_DECL mng_version_text (void)
  529. {
  530. return MNG_VERSION_TEXT;
  531. }
  532. /* ************************************************************************** */
  533. mng_uint8 MNG_DECL mng_version_so (void)
  534. {
  535. return MNG_VERSION_SO;
  536. }
  537. /* ************************************************************************** */
  538. mng_uint8 MNG_DECL mng_version_dll (void)
  539. {
  540. return MNG_VERSION_DLL;
  541. }
  542. /* ************************************************************************** */
  543. mng_uint8 MNG_DECL mng_version_major (void)
  544. {
  545. return MNG_VERSION_MAJOR;
  546. }
  547. /* ************************************************************************** */
  548. mng_uint8 MNG_DECL mng_version_minor (void)
  549. {
  550. return MNG_VERSION_MINOR;
  551. }
  552. /* ************************************************************************** */
  553. mng_uint8 MNG_DECL mng_version_release (void)
  554. {
  555. return MNG_VERSION_RELEASE;
  556. }
  557. /* ************************************************************************** */
  558. mng_bool MNG_DECL mng_version_beta (void)
  559. {
  560. return MNG_VERSION_BETA;
  561. }
  562. #endif
  563. /* ************************************************************************** */
  564. /* * * */
  565. /* * 'supports' function * */
  566. /* * * */
  567. /* ************************************************************************** */
  568. #ifdef MNG_SUPPORT_FUNCQUERY
  569. typedef struct {
  570. mng_pchar zFunction;
  571. mng_uint8 iMajor; /* Major == 0 means not implemented ! */
  572. mng_uint8 iMinor;
  573. mng_uint8 iRelease;
  574. } mng_func_entry;
  575. typedef mng_func_entry const * mng_func_entryp;
  576. MNG_LOCAL mng_func_entry const func_table [] =
  577. { /* keep it alphabetically sorted !!!!! */
  578. {"mng_cleanup", 1, 0, 0},
  579. {"mng_copy_chunk", 1, 0, 5},
  580. {"mng_create", 1, 0, 0},
  581. {"mng_display", 1, 0, 0},
  582. {"mng_display_freeze", 1, 0, 0},
  583. #ifndef MNG_NO_DISPLAY_GO_SUPPORTED
  584. {"mng_display_goframe", 1, 0, 0},
  585. {"mng_display_golayer", 1, 0, 0},
  586. {"mng_display_gotime", 1, 0, 0},
  587. #endif
  588. {"mng_display_reset", 1, 0, 0},
  589. {"mng_display_resume", 1, 0, 0},
  590. {"mng_get_alphabitdepth", 1, 0, 0},
  591. {"mng_get_alphacompression", 1, 0, 0},
  592. {"mng_get_alphadepth", 1, 0, 0},
  593. {"mng_get_alphafilter", 1, 0, 0},
  594. {"mng_get_alphainterlace", 1, 0, 0},
  595. {"mng_get_bgcolor", 1, 0, 0},
  596. {"mng_get_bitdepth", 1, 0, 0},
  597. {"mng_get_bkgdstyle", 1, 0, 0},
  598. {"mng_get_cacheplayback", 1, 0, 2},
  599. {"mng_get_canvasstyle", 1, 0, 0},
  600. {"mng_get_colortype", 1, 0, 0},
  601. {"mng_get_compression", 1, 0, 0},
  602. #ifndef MNG_NO_CURRENT_INFO
  603. {"mng_get_currentframe", 1, 0, 0},
  604. {"mng_get_currentlayer", 1, 0, 0},
  605. {"mng_get_currentplaytime", 1, 0, 0},
  606. #endif
  607. {"mng_get_currframdelay", 1, 0, 9},
  608. #ifndef MNG_NO_DFLT_INFO
  609. {"mng_get_dfltimggamma", 1, 0, 0},
  610. {"mng_get_dfltimggammaint", 1, 0, 0},
  611. #endif
  612. {"mng_get_displaygamma", 1, 0, 0},
  613. {"mng_get_displaygammaint", 1, 0, 0},
  614. {"mng_get_doprogressive", 1, 0, 2},
  615. {"mng_get_filter", 1, 0, 0},
  616. {"mng_get_framecount", 1, 0, 0},
  617. {"mng_get_imageheight", 1, 0, 0},
  618. {"mng_get_imagelevel", 1, 0, 0},
  619. {"mng_get_imagetype", 1, 0, 0},
  620. {"mng_get_imagewidth", 1, 0, 0},
  621. {"mng_get_interlace", 1, 0, 0},
  622. #ifdef MNG_ACCESS_JPEG
  623. {"mng_get_jpeg_dctmethod", 1, 0, 0},
  624. {"mng_get_jpeg_maxjdat", 1, 0, 0},
  625. {"mng_get_jpeg_optimized", 1, 0, 0},
  626. {"mng_get_jpeg_progressive", 1, 0, 0},
  627. {"mng_get_jpeg_quality", 1, 0, 0},
  628. {"mng_get_jpeg_smoothing", 1, 0, 0},
  629. #endif
  630. {"mng_get_lastbackchunk", 1, 0, 3},
  631. {"mng_get_lastseekname", 1, 0, 5},
  632. {"mng_get_layercount", 1, 0, 0},
  633. #ifndef MNG_SKIP_MAXCANVAS
  634. {"mng_get_maxcanvasheight", 1, 0, 0},
  635. {"mng_get_maxcanvaswidth", 1, 0, 0},
  636. #endif
  637. {"mng_get_playtime", 1, 0, 0},
  638. {"mng_get_refreshpass", 1, 0, 0},
  639. {"mng_get_runtime", 1, 0, 0},
  640. {"mng_get_sectionbreaks", 1, 0, 0},
  641. {"mng_get_sigtype", 1, 0, 0},
  642. {"mng_get_simplicity", 1, 0, 0},
  643. {"mng_get_speed", 1, 0, 0},
  644. {"mng_get_srgb", 1, 0, 0},
  645. {"mng_get_starttime", 1, 0, 0},
  646. {"mng_get_storechunks", 1, 0, 0},
  647. {"mng_get_suspensionmode", 1, 0, 0},
  648. {"mng_get_ticks", 1, 0, 0},
  649. #ifndef MNG_NO_CURRENT_INFO
  650. {"mng_get_totalframes", 1, 0, 5},
  651. {"mng_get_totallayers", 1, 0, 5},
  652. {"mng_get_totalplaytime", 1, 0, 5},
  653. #endif
  654. {"mng_get_usebkgd", 1, 0, 0},
  655. {"mng_get_userdata", 1, 0, 0},
  656. #if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS)
  657. {"mng_get_viewgamma", 1, 0, 0},
  658. {"mng_get_viewgammaint", 1, 0, 0},
  659. #endif
  660. #ifdef MNG_ACCESS_ZLIB
  661. {"mng_get_zlib_level", 1, 0, 0},
  662. {"mng_get_zlib_maxidat", 1, 0, 0},
  663. {"mng_get_zlib_memlevel", 1, 0, 0},
  664. {"mng_get_zlib_method", 1, 0, 0},
  665. {"mng_get_zlib_strategy", 1, 0, 0},
  666. {"mng_get_zlib_windowbits", 1, 0, 0},
  667. #endif
  668. #ifndef MNG_NO_OPEN_CLOSE_STREAM
  669. {"mng_getcb_closestream", 1, 0, 0},
  670. #endif
  671. {"mng_getcb_errorproc", 1, 0, 0},
  672. {"mng_getcb_getalphaline", 1, 0, 0},
  673. {"mng_getcb_getbkgdline", 1, 0, 0},
  674. {"mng_getcb_getcanvasline", 1, 0, 0},
  675. {"mng_getcb_gettickcount", 1, 0, 0},
  676. {"mng_getcb_memalloc", 1, 0, 0},
  677. {"mng_getcb_memfree", 1, 0, 0},
  678. #ifndef MNG_NO_OPEN_CLOSE_STREAM
  679. {"mng_getcb_openstream", 1, 0, 0},
  680. #endif
  681. {"mng_getcb_processarow", 1, 0, 0},
  682. {"mng_getcb_processchroma", 1, 0, 0},
  683. {"mng_getcb_processgamma", 1, 0, 0},
  684. {"mng_getcb_processheader", 1, 0, 0},
  685. {"mng_getcb_processiccp", 1, 0, 0},
  686. {"mng_getcb_processmend", 1, 0, 1},
  687. {"mng_getcb_processneed", 1, 0, 0},
  688. {"mng_getcb_processsave", 1, 0, 0},
  689. {"mng_getcb_processseek", 1, 0, 0},
  690. {"mng_getcb_processsrgb", 1, 0, 0},
  691. {"mng_getcb_processterm", 1, 0, 2},
  692. {"mng_getcb_processtext", 1, 0, 0},
  693. {"mng_getcb_processunknown", 1, 0, 0},
  694. {"mng_getcb_readdata", 1, 0, 0},
  695. {"mng_getcb_refresh", 1, 0, 0},
  696. {"mng_getcb_releasedata", 1, 0, 8},
  697. {"mng_getcb_settimer", 1, 0, 0},
  698. {"mng_getcb_traceproc", 1, 0, 0},
  699. {"mng_getcb_writedata", 1, 0, 0},
  700. {"mng_getchunk_back", 1, 0, 0},
  701. {"mng_getchunk_basi", 1, 0, 0},
  702. #ifndef MNG_SKIPCHUNK_bKGD
  703. {"mng_getchunk_bkgd", 1, 0, 0},
  704. #endif
  705. #ifndef MNG_SKIPCHUNK_cHRM
  706. {"mng_getchunk_chrm", 1, 0, 0},
  707. #endif
  708. {"mng_getchunk_clip", 1, 0, 0},
  709. {"mng_getchunk_clon", 1, 0, 0},
  710. #ifndef MNG_NO_DELTA_PNG
  711. #ifndef MNG_SKIPCHUNK_dBYK
  712. {"mng_getchunk_dbyk", 1, 0, 0},
  713. #endif
  714. #endif
  715. {"mng_getchunk_defi", 1, 0, 0},
  716. #ifndef MNG_NO_DELTA_PNG
  717. {"mng_getchunk_dhdr", 1, 0, 0},
  718. #endif
  719. {"mng_getchunk_disc", 1, 0, 0},
  720. #ifndef MNG_NO_DELTA_PNG
  721. {"mng_getchunk_drop", 1, 0, 0},
  722. #endif
  723. {"mng_getchunk_endl", 1, 0, 0},
  724. #ifdef MNG_INCLUDE_MPNG_PROPOSAL
  725. {"mng_getchunk_mpng", 1, 0, 10},
  726. {"mng_getchunk_mpng_frame", 1, 0, 10},
  727. #endif
  728. #ifndef MNG_SKIPCHUNK_evNT
  729. {"mng_getchunk_evnt", 1, 0, 5},
  730. {"mng_getchunk_evnt_entry", 1, 0, 5},
  731. #endif
  732. #ifndef MNG_SKIPCHUNK_eXPI
  733. {"mng_getchunk_expi", 1, 0, 0},
  734. #endif
  735. #ifndef MNG_SKIPCHUNK_fPRI
  736. {"mng_getchunk_fpri", 1, 0, 0},
  737. #endif
  738. {"mng_getchunk_fram", 1, 0, 0},
  739. {"mng_getchunk_gama", 1, 0, 0},
  740. #ifndef MNG_SKIPCHUNK_hIST
  741. {"mng_getchunk_hist", 1, 0, 0},
  742. #endif
  743. #ifndef MNG_SKIPCHUNK_iCCP
  744. {"mng_getchunk_iccp", 1, 0, 0},
  745. #endif
  746. {"mng_getchunk_idat", 1, 0, 0},
  747. {"mng_getchunk_iend", 1, 0, 0},
  748. {"mng_getchunk_ihdr", 1, 0, 0},
  749. #ifndef MNG_NO_DELTA_PNG
  750. #ifdef MNG_INCLUDE_JNG
  751. {"mng_getchunk_ijng", 1, 0, 0},
  752. #endif
  753. {"mng_getchunk_ipng", 1, 0, 0},
  754. #endif
  755. #ifndef MNG_SKIPCHUNK_iTXt
  756. {"mng_getchunk_itxt", 1, 0, 0},
  757. #endif
  758. #ifdef MNG_INCLUDE_JNG
  759. {"mng_getchunk_jdaa", 1, 0, 0},
  760. {"mng_getchunk_jdat", 1, 0, 0},
  761. {"mng_getchunk_jhdr", 1, 0, 0},
  762. {"mng_getchunk_jsep", 1, 0, 0},
  763. #endif
  764. {"mng_getchunk_loop", 1, 0, 0},
  765. #ifndef MNG_SKIPCHUNK_MAGN
  766. {"mng_getchunk_magn", 1, 0, 0},
  767. #endif
  768. {"mng_getchunk_mend", 1, 0, 0},
  769. {"mng_getchunk_mhdr", 1, 0, 0},
  770. {"mng_getchunk_move", 1, 0, 0},
  771. #ifndef MNG_SKIPCHUNK_nEED
  772. {"mng_getchunk_need", 1, 0, 0},
  773. #endif
  774. #ifndef MNG_SKIPCHUNK_ORDR
  775. #ifndef MNG_NO_DELTA_PNG
  776. {"mng_getchunk_ordr", 1, 0, 0},
  777. {"mng_getchunk_ordr_entry", 1, 0, 0},
  778. #endif
  779. #endif
  780. #ifndef MNG_SKIPCHUNK_PAST
  781. {"mng_getchunk_past", 1, 0, 0},
  782. {"mng_getchunk_past_src", 1, 0, 0},
  783. #endif
  784. #ifndef MNG_SKIPCHUNK_pHYg
  785. {"mng_getchunk_phyg", 1, 0, 0},
  786. #endif
  787. #ifndef MNG_SKIPCHUNK_pHYs
  788. {"mng_getchunk_phys", 1, 0, 0},
  789. #endif
  790. #ifndef MNG_NO_DELTA_PNG
  791. {"mng_getchunk_plte", 1, 0, 0},
  792. {"mng_getchunk_pplt", 1, 0, 0},
  793. {"mng_getchunk_pplt_entry", 1, 0, 0},
  794. {"mng_getchunk_prom", 1, 0, 0},
  795. #endif
  796. #ifndef MNG_SKIPCHUNK_SAVE
  797. {"mng_getchunk_save", 1, 0, 0},
  798. {"mng_getchunk_save_entry", 1, 0, 0},
  799. #endif
  800. #ifndef MNG_SKIPCHUNK_sBIT
  801. {"mng_getchunk_sbit", 1, 0, 0},
  802. #endif
  803. #ifndef MNG_SKIPCHUNK_SEEK
  804. {"mng_getchunk_seek", 1, 0, 0},
  805. #endif
  806. {"mng_getchunk_show", 1, 0, 0},
  807. #ifndef MNG_SKIPCHUNK_sPLT
  808. {"mng_getchunk_splt", 1, 0, 0},
  809. #endif
  810. #ifndef MNG_SKIPCHUNK_sRGB
  811. {"mng_getchunk_srgb", 1, 0, 0},
  812. #endif
  813. {"mng_getchunk_term", 1, 0, 0},
  814. #ifndef MNG_SKIPCHUNK_tEXt
  815. {"mng_getchunk_text", 1, 0, 0},
  816. #endif
  817. #ifndef MNG_SKIPCHUNK_tIME
  818. {"mng_getchunk_time", 1, 0, 0},
  819. #endif
  820. {"mng_getchunk_trns", 1, 0, 0},
  821. {"mng_getchunk_unkown", 1, 0, 0},
  822. #ifndef MNG_SKIPCHUNK_zTXt
  823. {"mng_getchunk_ztxt", 1, 0, 0},
  824. #endif
  825. {"mng_getimgdata_chunk", 0, 0, 0},
  826. {"mng_getimgdata_chunkseq", 0, 0, 0},
  827. {"mng_getimgdata_seq", 0, 0, 0},
  828. {"mng_getlasterror", 1, 0, 0},
  829. {"mng_initialize", 1, 0, 0},
  830. {"mng_iterate_chunks", 1, 0, 0},
  831. {"mng_putchunk_back", 1, 0, 0},
  832. #ifndef MNG_SKIPCHUNK_BASI
  833. {"mng_putchunk_basi", 1, 0, 0},
  834. #endif
  835. #ifndef MNG_SKIPCHUNK_bKGD
  836. {"mng_putchunk_bkgd", 1, 0, 0},
  837. #endif
  838. #ifndef MNG_SKIPCHUNK_cHRM
  839. {"mng_putchunk_chrm", 1, 0, 0},
  840. #endif
  841. {"mng_putchunk_clip", 1, 0, 0},
  842. {"mng_putchunk_clon", 1, 0, 0},
  843. #ifndef MNG_NO_DELTA_PNG
  844. #ifndef MNG_SKIPCHUNK_DBYK
  845. {"mng_putchunk_dbyk", 1, 0, 0},
  846. #endif
  847. #endif
  848. {"mng_putchunk_defi", 1, 0, 0},
  849. #ifndef MNG_NO_DELTA_PNG
  850. {"mng_putchunk_dhdr", 1, 0, 0},
  851. #endif
  852. {"mng_putchunk_disc", 1, 0, 0},
  853. #ifndef MNG_NO_DELTA_PNG
  854. {"mng_putchunk_drop", 1, 0, 0},
  855. #endif
  856. {"mng_putchunk_endl", 1, 0, 0},
  857. #ifdef MNG_INCLUDE_MPNG_PROPOSAL
  858. {"mng_putchunk_mpng", 1, 0, 10},
  859. {"mng_putchunk_mpng_frame", 1, 0, 10},
  860. #endif
  861. #ifndef MNG_SKIPCHUNK_evNT
  862. {"mng_putchunk_evnt", 1, 0, 5},
  863. {"mng_putchunk_evnt_entry", 1, 0, 5},
  864. #endif
  865. #ifndef MNG_SKIPCHUNK_eXPI
  866. {"mng_putchunk_expi", 1, 0, 0},
  867. #endif
  868. #ifndef MNG_SKIPCHUNK_fPRI
  869. {"mng_putchunk_fpri", 1, 0, 0},
  870. #endif
  871. #ifndef MNG_SKIPCHUNK_FRAM
  872. {"mng_putchunk_fram", 1, 0, 0},
  873. #endif
  874. {"mng_putchunk_gama", 1, 0, 0},
  875. #ifndef MNG_SKIPCHUNK_hIST
  876. {"mng_putchunk_hist", 1, 0, 0},
  877. #endif
  878. #ifndef MNG_SKIPCHUNK_iCCP
  879. {"mng_putchunk_iccp", 1, 0, 0},
  880. #endif
  881. {"mng_putchunk_idat", 1, 0, 0},
  882. {"mng_putchunk_iend", 1, 0, 0},
  883. {"mng_putchunk_ihdr", 1, 0, 0},
  884. #ifndef MNG_NO_DELTA_PNG
  885. #ifdef MNG_INCLUDE_JNG
  886. {"mng_putchunk_ijng", 1, 0, 0},
  887. #endif
  888. {"mng_putchunk_ipng", 1, 0, 0},
  889. #endif
  890. #ifndef MNG_SKIPCHUNK_iTXt
  891. {"mng_putchunk_itxt", 1, 0, 0},
  892. #endif
  893. #ifdef MNG_INCLUDE_JNG
  894. {"mng_putchunk_jdaa", 1, 0, 0},
  895. {"mng_putchunk_jdat", 1, 0, 0},
  896. {"mng_putchunk_jhdr", 1, 0, 0},
  897. {"mng_putchunk_jsep", 1, 0, 0},
  898. #endif
  899. {"mng_putchunk_loop", 1, 0, 0},
  900. #ifndef MNG_SKIPCHUNK_MAGN
  901. {"mng_putchunk_magn", 1, 0, 0},
  902. #endif
  903. {"mng_putchunk_mend", 1, 0, 0},
  904. {"mng_putchunk_mhdr", 1, 0, 0},
  905. {"mng_putchunk_move", 1, 0, 0},
  906. #ifndef MNG_SKIPCHUNK_nEED
  907. {"mng_putchunk_need", 1, 0, 0},
  908. #endif
  909. #ifndef MNG_NO_DELTA_PNG
  910. #ifndef MNG_SKIPCHUNK_ORDR
  911. {"mng_putchunk_ordr", 1, 0, 0},
  912. {"mng_putchunk_ordr_entry", 1, 0, 0},
  913. #endif
  914. #endif
  915. #ifndef MNG_SKIPCHUNK_PAST
  916. {"mng_putchunk_past", 1, 0, 0},
  917. {"mng_putchunk_past_src", 1, 0, 0},
  918. #endif
  919. #ifndef MNG_SKIPCHUNK_pHYg
  920. {"mng_putchunk_phyg", 1, 0, 0},
  921. #endif
  922. #ifndef MNG_SKIPCHUNK_pHYs
  923. {"mng_putchunk_phys", 1, 0, 0},
  924. #endif
  925. #ifndef MNG_NO_DELTA_PNG
  926. {"mng_putchunk_plte", 1, 0, 0},
  927. {"mng_putchunk_pplt", 1, 0, 0},
  928. {"mng_putchunk_pplt_entry", 1, 0, 0},
  929. {"mng_putchunk_prom", 1, 0, 0},
  930. #endif
  931. #ifndef MNG_SKIPCHUNK_SAVE
  932. {"mng_putchunk_save", 1, 0, 0},
  933. {"mng_putchunk_save_entry", 1, 0, 0},
  934. #endif
  935. #ifndef MNG_SKIPCHUNK_sBIT
  936. {"mng_putchunk_sbit", 1, 0, 0},
  937. #endif
  938. #ifndef MNG_SKIPCHUNK_SEEK
  939. {"mng_putchunk_seek", 1, 0, 0},
  940. #endif
  941. {"mng_putchunk_show", 1, 0, 0},
  942. #ifndef MNG_SKIPCHUNK_sPLT
  943. {"mng_putchunk_splt", 1, 0, 0},
  944. #endif
  945. #ifndef MNG_SKIPCHUNK_sRGB
  946. {"mng_putchunk_srgb", 1, 0, 0},
  947. #endif
  948. {"mng_putchunk_term", 1, 0, 0},
  949. #ifndef MNG_SKIPCHUNK_tEXt
  950. {"mng_putchunk_text", 1, 0, 0},
  951. #endif
  952. #ifndef MNG_SKIPCHUNK_tIME
  953. {"mng_putchunk_time", 1, 0, 0},
  954. #endif
  955. {"mng_putchunk_trns", 1, 0, 0},
  956. {"mng_putchunk_unkown", 1, 0, 0},
  957. #ifndef MNG_SKIPCHUNK_zTXt
  958. {"mng_putchunk_ztxt", 1, 0, 0},
  959. #endif
  960. {"mng_putimgdata_ihdr", 0, 0, 0},
  961. {"mng_putimgdata_jhdr", 0, 0, 0},
  962. {"mng_reset", 1, 0, 0},
  963. {"mng_read", 1, 0, 0},
  964. {"mng_read_pushchunk", 1, 0, 8},
  965. {"mng_read_pushdata", 1, 0, 8},
  966. {"mng_read_pushsig", 1, 0, 8},
  967. {"mng_read_resume", 1, 0, 0},
  968. {"mng_readdisplay", 1, 0, 0},
  969. {"mng_set_bgcolor", 1, 0, 0},
  970. {"mng_set_bkgdstyle", 1, 0, 0},
  971. {"mng_set_cacheplayback", 1, 0, 2},
  972. {"mng_set_canvasstyle", 1, 0, 0},
  973. {"mng_set_dfltimggamma", 1, 0, 0},
  974. #ifndef MNG_NO_DFLT_INFO
  975. {"mng_set_dfltimggammaint", 1, 0, 0},
  976. #endif
  977. {"mng_set_displaygamma", 1, 0, 0},
  978. {"mng_set_displaygammaint", 1, 0, 0},
  979. {"mng_set_doprogressive", 1, 0, 2},
  980. #ifdef MNG_ACCESS_JPEG
  981. {"mng_set_jpeg_dctmethod", 1, 0, 0},
  982. {"mng_set_jpeg_maxjdat", 1, 0, 0},
  983. {"mng_set_jpeg_optimized", 1, 0, 0},
  984. {"mng_set_jpeg_progressive", 1, 0, 0},
  985. {"mng_set_jpeg_quality", 1, 0, 0},
  986. {"mng_set_jpeg_smoothing", 1, 0, 0},
  987. #endif
  988. #ifndef MNG_SKIP_MAXCANVAS
  989. {"mng_set_maxcanvasheight", 1, 0, 0},
  990. {"mng_set_maxcanvassize", 1, 0, 0},
  991. {"mng_set_maxcanvaswidth", 1, 0, 0},
  992. #endif
  993. {"mng_set_outputprofile", 1, 0, 0},
  994. {"mng_set_outputprofile2", 1, 0, 0},
  995. {"mng_set_outputsrgb", 1, 0, 1},
  996. {"mng_set_sectionbreaks", 1, 0, 0},
  997. {"mng_set_speed", 1, 0, 0},
  998. {"mng_set_srgb", 1, 0, 0},
  999. {"mng_set_srgbimplicit", 1, 0, 1},
  1000. {"mng_set_srgbprofile", 1, 0, 0},
  1001. {"mng_set_srgbprofile2", 1, 0, 0},
  1002. {"mng_set_storechunks", 1, 0, 0},
  1003. {"mng_set_suspensionmode", 1, 0, 0},
  1004. {"mng_set_usebkgd", 1, 0, 0},
  1005. {"mng_set_userdata", 1, 0, 0},
  1006. #if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS)
  1007. {"mng_set_viewgamma", 1, 0, 0},
  1008. {"mng_set_viewgammaint", 1, 0, 0},
  1009. #endif
  1010. #ifdef MNG_ACCESS_ZLIB
  1011. {"mng_set_zlib_level", 1, 0, 0},
  1012. {"mng_set_zlib_maxidat", 1, 0, 0},
  1013. {"mng_set_zlib_memlevel", 1, 0, 0},
  1014. {"mng_set_zlib_method", 1, 0, 0},
  1015. {"mng_set_zlib_strategy", 1, 0, 0},
  1016. {"mng_set_zlib_windowbits", 1, 0, 0},
  1017. #endif
  1018. #ifndef MNG_NO_OPEN_CLOSE_STREAM
  1019. {"mng_setcb_closestream", 1, 0, 0},
  1020. #endif
  1021. {"mng_setcb_errorproc", 1, 0, 0},
  1022. {"mng_setcb_getalphaline", 1, 0, 0},
  1023. {"mng_setcb_getbkgdline", 1, 0, 0},
  1024. {"mng_setcb_getcanvasline", 1, 0, 0},
  1025. {"mng_setcb_gettickcount", 1, 0, 0},
  1026. {"mng_setcb_memalloc", 1, 0, 0},
  1027. {"mng_setcb_memfree", 1, 0, 0},
  1028. #ifndef MNG_NO_OPEN_CLOSE_STREAM
  1029. {"mng_setcb_openstream", 1, 0, 0},
  1030. #endif
  1031. {"mng_setcb_processarow", 1, 0, 0},
  1032. {"mng_setcb_processchroma", 1, 0, 0},
  1033. {"mng_setcb_processgamma", 1, 0, 0},
  1034. {"mng_setcb_processheader", 1, 0, 0},
  1035. {"mng_setcb_processiccp", 1, 0, 0},
  1036. {"mng_setcb_processmend", 1, 0, 1},
  1037. {"mng_setcb_processneed", 1, 0, 0},
  1038. {"mng_setcb_processsave", 1, 0, 0},
  1039. {"mng_setcb_processseek", 1, 0, 0},
  1040. {"mng_setcb_processsrgb", 1, 0, 0},
  1041. {"mng_setcb_processterm", 1, 0, 2},
  1042. {"mng_setcb_processtext", 1, 0, 0},
  1043. {"mng_setcb_processunknown", 1, 0, 0},
  1044. {"mng_setcb_readdata", 1, 0, 0},
  1045. {"mng_setcb_refresh", 1, 0, 0},
  1046. {"mng_setcb_releasedata", 1, 0, 8},
  1047. {"mng_setcb_settimer", 1, 0, 0},
  1048. {"mng_setcb_traceproc", 1, 0, 0},
  1049. {"mng_setcb_writedata", 1, 0, 0},
  1050. {"mng_status_creating", 1, 0, 0},
  1051. {"mng_status_displaying", 1, 0, 0},
  1052. {"mng_status_dynamic", 1, 0, 5},
  1053. {"mng_status_error", 1, 0, 0},
  1054. {"mng_status_reading", 1, 0, 0},
  1055. {"mng_status_running", 1, 0, 0},
  1056. {"mng_status_runningevent", 1, 0, 5},
  1057. {"mng_status_suspendbreak", 1, 0, 0},
  1058. {"mng_status_timerbreak", 1, 0, 0},
  1059. {"mng_status_writing", 1, 0, 0},
  1060. {"mng_supports_func", 1, 0, 5},
  1061. {"mng_trapevent", 1, 0, 5},
  1062. {"mng_updatemngheader", 1, 0, 0},
  1063. {"mng_updatemngsimplicity", 1, 0, 0},
  1064. {"mng_version_beta", 1, 0, 5},
  1065. {"mng_version_dll", 1, 0, 0},
  1066. {"mng_version_major", 1, 0, 0},
  1067. {"mng_version_minor", 1, 0, 0},
  1068. {"mng_version_release", 1, 0, 0},
  1069. {"mng_version_so", 1, 0, 0},
  1070. {"mng_version_text", 1, 0, 0},
  1071. {"mng_write", 1, 0, 0},
  1072. };
  1073. mng_bool MNG_DECL mng_supports_func (mng_pchar zFunction,
  1074. mng_uint8* iMajor,
  1075. mng_uint8* iMinor,
  1076. mng_uint8* iRelease)
  1077. {
  1078. mng_int32 iTop, iLower, iUpper, iMiddle;
  1079. mng_func_entryp pEntry; /* pointer to found entry */
  1080. /* determine max index of table */
  1081. iTop = (sizeof (func_table) / sizeof (func_table [0])) - 1;
  1082. iLower = 0; /* initialize binary search */
  1083. iMiddle = iTop >> 1; /* start in the middle */
  1084. iUpper = iTop;
  1085. pEntry = 0; /* no goods yet! */
  1086. do /* the binary search itself */
  1087. {
  1088. mng_int32 iRslt = strcmp(func_table [iMiddle].zFunction, zFunction);
  1089. if (iRslt < 0)
  1090. iLower = iMiddle + 1;
  1091. else if (iRslt > 0)
  1092. iUpper = iMiddle - 1;
  1093. else
  1094. {
  1095. pEntry = &func_table [iMiddle];
  1096. break;
  1097. };
  1098. iMiddle = (iLower + iUpper) >> 1;
  1099. }
  1100. while (iLower <= iUpper);
  1101. if (pEntry) /* found it ? */
  1102. {
  1103. *iMajor = pEntry->iMajor;
  1104. *iMinor = pEntry->iMinor;
  1105. *iRelease = pEntry->iRelease;
  1106. return MNG_TRUE;
  1107. }
  1108. else
  1109. {
  1110. *iMajor = 0;
  1111. *iMinor = 0;
  1112. *iRelease = 0;
  1113. return MNG_FALSE;
  1114. }
  1115. }
  1116. #endif
  1117. /* ************************************************************************** */
  1118. /* * * */
  1119. /* * HLAPI routines * */
  1120. /* * * */
  1121. /* ************************************************************************** */
  1122. mng_handle MNG_DECL mng_initialize (mng_ptr pUserdata,
  1123. mng_memalloc fMemalloc,
  1124. mng_memfree fMemfree,
  1125. mng_traceproc fTraceproc)
  1126. {
  1127. mng_datap pData;
  1128. #ifdef MNG_SUPPORT_DISPLAY
  1129. mng_retcode iRetcode;
  1130. mng_imagep pImage;
  1131. #endif
  1132. #ifdef MNG_INTERNAL_MEMMNGMT /* allocate the main datastruc */
  1133. pData = (mng_datap)calloc (1, sizeof (mng_data));
  1134. #else
  1135. pData = (mng_datap)fMemalloc (sizeof (mng_data));
  1136. #endif
  1137. if (!pData)
  1138. return MNG_NULL; /* error: out of memory?? */
  1139. /* validate the structure */
  1140. pData->iMagic = MNG_MAGIC;
  1141. /* save userdata field */
  1142. pData->pUserdata = pUserdata;
  1143. /* remember trace callback */
  1144. pData->fTraceproc = fTraceproc;
  1145. #ifdef MNG_SUPPORT_TRACE
  1146. if (mng_trace (pData, MNG_FN_INITIALIZE, MNG_LC_INITIALIZE))
  1147. {
  1148. MNG_FREEX (pData, pData, sizeof (mng_data));
  1149. return MNG_NULL;
  1150. }
  1151. #endif
  1152. /* default canvas styles are 8-bit RGB */
  1153. pData->iCanvasstyle = MNG_CANVAS_RGB8;
  1154. pData->iBkgdstyle = MNG_CANVAS_RGB8;
  1155. pData->iBGred = 0; /* black */
  1156. pData->iBGgreen = 0;
  1157. pData->iBGblue = 0;
  1158. pData->bUseBKGD = MNG_TRUE;
  1159. #ifdef MNG_FULL_CMS
  1160. pData->bIssRGB = MNG_TRUE;
  1161. pData->hProf1 = 0; /* no profiles yet */
  1162. pData->hProf2 = 0;
  1163. pData->hProf3 = 0;
  1164. pData->hTrans = 0;
  1165. #endif
  1166. pData->dViewgamma = 1.0;
  1167. pData->dDisplaygamma = 2.2;
  1168. pData->dDfltimggamma = 0.45455;
  1169. /* initially remember chunks */
  1170. pData->bStorechunks = MNG_TRUE;
  1171. /* no breaks at section-borders */
  1172. pData->bSectionbreaks = MNG_FALSE;
  1173. /* initially cache playback info */
  1174. pData->bCacheplayback = MNG_TRUE;
  1175. /* progressive refresh for large images */
  1176. pData->bDoProgressive = MNG_TRUE;
  1177. /* crc exists; should check; error for
  1178. critical chunks; warning for ancillery;
  1179. generate crc for output */
  1180. pData->iCrcmode = MNG_CRC_DEFAULT;
  1181. /* normal animation-speed ! */
  1182. pData->iSpeed = mng_st_normal;
  1183. /* initial image limits */
  1184. pData->iMaxwidth = 10000;
  1185. pData->iMaxheight = 10000;
  1186. #ifdef MNG_INTERNAL_MEMMNGMT /* internal management */
  1187. pData->fMemalloc = MNG_NULL;
  1188. pData->fMemfree = MNG_NULL;
  1189. #else /* keep callbacks */
  1190. pData->fMemalloc = fMemalloc;
  1191. pData->fMemfree = fMemfree;
  1192. #endif
  1193. /* no value (yet) */
  1194. pData->fReleasedata = MNG_NULL;
  1195. #ifndef MNG_NO_OPEN_CLOSE_STREAM
  1196. pData->fOpenstream = MNG_NULL;
  1197. pData->fClosestream = MNG_NULL;
  1198. #endif
  1199. pData->fReaddata = MNG_NULL;
  1200. pData->fWritedata = MNG_NULL;
  1201. pData->fErrorproc = MNG_NULL;
  1202. pData->fProcessheader = MNG_NULL;
  1203. pData->fProcesstext = MNG_NULL;
  1204. pData->fProcesssave = MNG_NULL;
  1205. pData->fProcessseek = MNG_NULL;
  1206. pData->fProcessneed = MNG_NULL;
  1207. pData->fProcessmend = MNG_NULL;
  1208. pData->fProcessunknown = MNG_NULL;
  1209. pData->fProcessterm = MNG_NULL;
  1210. pData->fGetcanvasline = MNG_NULL;
  1211. pData->fGetbkgdline = MNG_NULL;
  1212. pData->fGetalphaline = MNG_NULL;
  1213. pData->fRefresh = MNG_NULL;
  1214. pData->fGettickcount = MNG_NULL;
  1215. pData->fSettimer = MNG_NULL;
  1216. pData->fProcessgamma = MNG_NULL;
  1217. pData->fProcesschroma = MNG_NULL;
  1218. pData->fProcesssrgb = MNG_NULL;
  1219. pData->fProcessiccp = MNG_NULL;
  1220. pData->fProcessarow = MNG_NULL;
  1221. #if defined(MNG_SUPPORT_DISPLAY) && (defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS))
  1222. pData->dLastgamma = 0; /* lookup table needs first-time calc */
  1223. #endif
  1224. #ifdef MNG_SUPPORT_DISPLAY /* create object 0 */
  1225. iRetcode = mng_create_imageobject (pData, 0, MNG_TRUE, MNG_TRUE, MNG_TRUE,
  1226. 0, 0, 0, 0, 0, 0, 0, 0, 0, MNG_FALSE,
  1227. 0, 0, 0, 0, &pImage);
  1228. if (iRetcode) /* on error drop out */
  1229. {
  1230. MNG_FREEX (pData, pData, sizeof (mng_data));
  1231. return MNG_NULL;
  1232. }
  1233. pData->pObjzero = pImage;
  1234. #endif
  1235. #if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_INCLUDE_LCMS)
  1236. mnglcms_initlibrary (); /* init lcms particulars */
  1237. #endif
  1238. #ifdef MNG_SUPPORT_READ
  1239. pData->bSuspensionmode = MNG_FALSE;
  1240. pData->iSuspendbufsize = 0;
  1241. pData->pSuspendbuf = MNG_NULL;
  1242. pData->pSuspendbufnext = MNG_NULL;
  1243. pData->iSuspendbufleft = 0;
  1244. pData->iChunklen = 0;
  1245. pData->pReadbufnext = MNG_NULL;
  1246. pData->pLargebufnext = MNG_NULL;
  1247. pData->pFirstpushchunk = MNG_NULL;
  1248. pData->pLastpushchunk = MNG_NULL;
  1249. pData->pFirstpushdata = MNG_NULL;
  1250. pData->pLastpushdata = MNG_NULL;
  1251. #endif
  1252. #ifdef MNG_INCLUDE_ZLIB
  1253. mngzlib_initialize (pData); /* initialize zlib structures and such */
  1254. /* default zlib compression parameters */
  1255. pData->iZlevel = MNG_ZLIB_LEVEL;
  1256. pData->iZmethod = MNG_ZLIB_METHOD;
  1257. pData->iZwindowbits = MNG_ZLIB_WINDOWBITS;
  1258. pData->iZmemlevel = MNG_ZLIB_MEMLEVEL;
  1259. pData->iZstrategy = MNG_ZLIB_STRATEGY;
  1260. /* default maximum IDAT data size */
  1261. pData->iMaxIDAT = MNG_MAX_IDAT_SIZE;
  1262. #endif
  1263. #ifdef MNG_INCLUDE_JNG /* default IJG compression parameters */
  1264. pData->eJPEGdctmethod = MNG_JPEG_DCT;
  1265. pData->iJPEGquality = MNG_JPEG_QUALITY;
  1266. pData->iJPEGsmoothing = MNG_JPEG_SMOOTHING;
  1267. pData->bJPEGcompressprogr = MNG_JPEG_PROGRESSIVE;
  1268. pData->bJPEGcompressopt = MNG_JPEG_OPTIMIZED;
  1269. /* default maximum JDAT data size */
  1270. pData->iMaxJDAT = MNG_MAX_JDAT_SIZE;
  1271. #endif
  1272. mng_reset ((mng_handle)pData);
  1273. #ifdef MNG_SUPPORT_TRACE
  1274. if (mng_trace (pData, MNG_FN_INITIALIZE, MNG_LC_END))
  1275. {
  1276. MNG_FREEX (pData, pData, sizeof (mng_data));
  1277. return MNG_NULL;
  1278. }
  1279. #endif
  1280. return (mng_handle)pData; /* if we get here, we're in business */
  1281. }
  1282. /* ************************************************************************** */
  1283. mng_retcode MNG_DECL mng_reset (mng_handle hHandle)
  1284. {
  1285. mng_datap pData;
  1286. #ifdef MNG_SUPPORT_TRACE
  1287. MNG_TRACE (((mng_datap)hHandle), MNG_FN_RESET, MNG_LC_START);
  1288. #endif
  1289. MNG_VALIDHANDLE (hHandle) /* check validity handle */
  1290. pData = ((mng_datap)(hHandle)); /* address main structure */
  1291. #ifdef MNG_SUPPORT_DISPLAY
  1292. #ifndef MNG_SKIPCHUNK_SAVE
  1293. mng_drop_savedata (pData); /* cleanup saved-data from SAVE/SEEK */
  1294. #endif
  1295. #endif
  1296. #if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_FULL_CMS)
  1297. mng_clear_cms (pData); /* cleanup left-over cms stuff if any */
  1298. #endif
  1299. #if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_INCLUDE_JNG)
  1300. mngjpeg_cleanup (pData); /* cleanup jpeg stuff */
  1301. #endif
  1302. #ifdef MNG_INCLUDE_ZLIB
  1303. if (pData->bInflating) /* if we've been inflating */
  1304. {
  1305. #ifdef MNG_INCLUDE_DISPLAY_PROCS
  1306. mng_cleanup_rowproc (pData); /* cleanup row-processing, */
  1307. #endif
  1308. mngzlib_inflatefree (pData); /* cleanup inflate! */
  1309. }
  1310. #endif /* MNG_INCLUDE_ZLIB */
  1311. #ifdef MNG_SUPPORT_READ
  1312. if ((pData->bReading) && (!pData->bEOF))
  1313. mng_process_eof (pData); /* cleanup app streaming */
  1314. /* cleanup default read buffers */
  1315. MNG_FREE (pData, pData->pReadbuf, pData->iReadbufsize);
  1316. MNG_FREE (pData, pData->pLargebuf, pData->iLargebufsize);
  1317. MNG_FREE (pData, pData->pSuspendbuf, pData->iSuspendbufsize);
  1318. while (pData->pFirstpushdata) /* release any pushed data & chunks */
  1319. mng_release_pushdata (pData);
  1320. while (pData->pFirstpushchunk)
  1321. mng_release_pushchunk (pData);
  1322. #endif
  1323. #ifdef MNG_SUPPORT_WRITE /* cleanup default write buffer */
  1324. MNG_FREE (pData, pData->pWritebuf, pData->iWritebufsize);
  1325. #endif
  1326. #if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE)
  1327. mng_drop_chunks (pData); /* drop stored chunks (if any) */
  1328. #endif
  1329. #ifdef MNG_SUPPORT_DISPLAY
  1330. mng_drop_objects (pData, MNG_TRUE); /* drop stored objects (if any) */
  1331. #ifndef MNG_SKIPCHUNK_iCCP
  1332. if (pData->iGlobalProfilesize) /* drop global profile (if any) */
  1333. MNG_FREEX (pData, pData->pGlobalProfile, pData->iGlobalProfilesize);
  1334. #endif
  1335. #endif
  1336. pData->eSigtype = mng_it_unknown;
  1337. pData->eImagetype = mng_it_unknown;
  1338. pData->iWidth = 0; /* these are unknown yet */
  1339. pData->iHeight = 0;
  1340. pData->iTicks = 0;
  1341. pData->iLayercount = 0;
  1342. pData->iFramecount = 0;
  1343. pData->iPlaytime = 0;
  1344. pData->iSimplicity = 0;
  1345. pData->iAlphadepth = 16; /* assume the worst! */
  1346. pData->iImagelevel = 0; /* no image encountered */
  1347. pData->iMagnify = 0; /* 1-to-1 display */
  1348. pData->iOffsetx = 0; /* no offsets */
  1349. pData->iOffsety = 0;
  1350. pData->iCanvaswidth = 0; /* let the app decide during processheader */
  1351. pData->iCanvasheight = 0;
  1352. /* so far, so good */
  1353. pData->iErrorcode = MNG_NOERROR;
  1354. pData->iSeverity = 0;
  1355. pData->iErrorx1 = 0;
  1356. pData->iErrorx2 = 0;
  1357. pData->zErrortext = MNG_NULL;
  1358. #if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE)
  1359. /* let's assume the best scenario */
  1360. #ifndef MNG_NO_OLD_VERSIONS
  1361. pData->bPreDraft48 = MNG_FALSE;
  1362. #endif
  1363. /* the unknown chunk */
  1364. pData->iChunkname = MNG_UINT_HUH;
  1365. pData->iChunkseq = 0;
  1366. pData->pFirstchunk = MNG_NULL;
  1367. pData->pLastchunk = MNG_NULL;
  1368. /* nothing processed yet */
  1369. pData->bHasheader = MNG_FALSE;
  1370. pData->bHasMHDR = MNG_FALSE;
  1371. pData->bHasIHDR = MNG_FALSE;
  1372. pData->bHasBASI = MNG_FALSE;
  1373. pData->bHasDHDR = MNG_FALSE;
  1374. #ifdef MNG_INCLUDE_JNG
  1375. pData->bHasJHDR = MNG_FALSE;
  1376. pData->bHasJSEP = MNG_FALSE;
  1377. pData->bHasJDAA = MNG_FALSE;
  1378. pData->bHasJDAT = MNG_FALSE;
  1379. #endif
  1380. pData->bHasPLTE = MNG_FALSE;
  1381. pData->bHasTRNS = MNG_FALSE;
  1382. pData->bHasGAMA = MNG_FALSE;
  1383. pData->bHasCHRM = MNG_FALSE;
  1384. pData->bHasSRGB = MNG_FALSE;
  1385. pData->bHasICCP = MNG_FALSE;
  1386. pData->bHasBKGD = MNG_FALSE;
  1387. pData->bHasIDAT = MNG_FALSE;
  1388. pData->bHasSAVE = MNG_FALSE;
  1389. pData->bHasBACK = MNG_FALSE;
  1390. pData->bHasFRAM = MNG_FALSE;
  1391. pData->bHasTERM = MNG_FALSE;
  1392. pData->bHasLOOP = MNG_FALSE;
  1393. /* there's no global stuff yet either */
  1394. pData->bHasglobalPLTE = MNG_FALSE;
  1395. pData->bHasglobalTRNS = MNG_FALSE;
  1396. pData->bHasglobalGAMA = MNG_FALSE;
  1397. pData->bHasglobalCHRM = MNG_FALSE;
  1398. pData->bHasglobalSRGB = MNG_FALSE;
  1399. pData->bHasglobalICCP = MNG_FALSE;
  1400. pData->iDatawidth = 0; /* no IHDR/BASI/DHDR done yet */
  1401. pData->iDataheight = 0;
  1402. pData->iBitdepth = 0;
  1403. pData->iColortype = 0;
  1404. pData->iCompression = 0;
  1405. pData->iFilter = 0;
  1406. pData->iInterlace = 0;
  1407. #ifdef MNG_INCLUDE_JNG
  1408. pData->iJHDRcolortype = 0; /* no JHDR data */
  1409. pData->iJHDRimgbitdepth = 0;
  1410. pData->iJHDRimgcompression = 0;
  1411. pData->iJHDRimginterlace = 0;
  1412. pData->iJHDRalphabitdepth = 0;
  1413. pData->iJHDRalphacompression = 0;
  1414. pData->iJHDRalphafilter = 0;
  1415. pData->iJHDRalphainterlace = 0;
  1416. #endif
  1417. #endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */
  1418. #ifdef MNG_SUPPORT_READ /* no reading done */
  1419. pData->bReading = MNG_FALSE;
  1420. pData->bHavesig = MNG_FALSE;
  1421. pData->bEOF = MNG_FALSE;
  1422. pData->iReadbufsize = 0;
  1423. pData->pReadbuf = MNG_NULL;
  1424. pData->iLargebufsize = 0;
  1425. pData->pLargebuf = MNG_NULL;
  1426. pData->iSuspendtime = 0;
  1427. pData->bSuspended = MNG_FALSE;
  1428. pData->iSuspendpoint = 0;
  1429. pData->pSuspendbufnext = pData->pSuspendbuf;
  1430. pData->iSuspendbufleft = 0;
  1431. #endif /* MNG_SUPPORT_READ */
  1432. #ifdef MNG_SUPPORT_WRITE /* no creating/writing done */
  1433. pData->bCreating = MNG_FALSE;
  1434. pData->bWriting = MNG_FALSE;
  1435. pData->iFirstchunkadded = 0;
  1436. pData->iWritebufsize = 0;
  1437. pData->pWritebuf = MNG_NULL;
  1438. #endif /* MNG_SUPPORT_WRITE */
  1439. #ifdef MNG_SUPPORT_DISPLAY /* done nuttin' yet */
  1440. pData->bDisplaying = MNG_FALSE;
  1441. pData->iFrameseq = 0;
  1442. pData->iLayerseq = 0;
  1443. pData->iFrametime = 0;
  1444. pData->iTotallayers = 0;
  1445. pData->iTotalframes = 0;
  1446. pData->iTotalplaytime = 0;
  1447. pData->bSkipping = MNG_FALSE;
  1448. #ifdef MNG_SUPPORT_DYNAMICMNG
  1449. pData->bDynamic = MNG_FALSE;
  1450. pData->bRunningevent = MNG_FALSE;
  1451. pData->bStopafterseek = MNG_FALSE;
  1452. pData->iEventx = 0;
  1453. pData->iEventy = 0;
  1454. pData->pLastmousemove = MNG_NULL;
  1455. #endif
  1456. pData->iRequestframe = 0;
  1457. pData->iRequestlayer = 0;
  1458. pData->iRequesttime = 0;
  1459. pData->bSearching = MNG_FALSE;
  1460. pData->bRestorebkgd = MNG_FALSE;
  1461. pData->iRuntime = 0;
  1462. pData->iSynctime = 0;
  1463. pData->iStarttime = 0;
  1464. pData->iEndtime = 0;
  1465. pData->bRunning = MNG_FALSE;
  1466. pData->bTimerset = MNG_FALSE;
  1467. pData->iBreakpoint = 0;
  1468. pData->bSectionwait = MNG_FALSE;
  1469. pData->bFreezing = MNG_FALSE;
  1470. pData->bResetting = MNG_FALSE;
  1471. pData->bNeedrefresh = MNG_FALSE;
  1472. pData->bMisplacedTERM = MNG_FALSE;
  1473. pData->bOnlyfirstframe = MNG_FALSE;
  1474. pData->iFramesafterTERM = 0;
  1475. /* these don'