/src/3rdparty/libmng/libmng_hlapi.c

https://bitbucket.org/ultra_iter/qt-vtl · C · 3001 lines · 2259 code · 420 blank · 322 comment · 207 complexity · 9a8a578c20fc316cbfe619debea91761 MD5 · raw file

Large files are truncated click here to view the full file

  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. pData->bForcedelay = MNG_FALSE;
  409. pData->iAccumdelay = 0;
  410. #endif
  411. #ifndef MNG_SKIPCHUNK_SHOW
  412. pData->iSHOWmode = 0; /* reset SHOW data */
  413. pData->iSHOWfromid = 0;
  414. pData->iSHOWtoid = 0;
  415. pData->iSHOWnextid = 0;
  416. pData->iSHOWskip = 0;
  417. #endif
  418. pData->iGlobalPLTEcount = 0; /* reset global PLTE data */
  419. pData->iGlobalTRNSrawlen = 0; /* reset global tRNS data */
  420. pData->iGlobalGamma = 0; /* reset global gAMA data */
  421. #ifndef MNG_SKIPCHUNK_cHRM
  422. pData->iGlobalWhitepointx = 0; /* reset global cHRM data */
  423. pData->iGlobalWhitepointy = 0;
  424. pData->iGlobalPrimaryredx = 0;
  425. pData->iGlobalPrimaryredy = 0;
  426. pData->iGlobalPrimarygreenx = 0;
  427. pData->iGlobalPrimarygreeny = 0;
  428. pData->iGlobalPrimarybluex = 0;
  429. pData->iGlobalPrimarybluey = 0;
  430. #endif
  431. #ifndef MNG_SKIPCHUNK_sRGB
  432. pData->iGlobalRendintent = 0; /* reset global sRGB data */
  433. #endif
  434. #ifndef MNG_SKIPCHUNK_iCCP
  435. if (pData->iGlobalProfilesize) /* drop global profile (if any) */
  436. MNG_FREE (pData, pData->pGlobalProfile, pData->iGlobalProfilesize);
  437. pData->iGlobalProfilesize = 0;
  438. #endif
  439. #ifndef MNG_SKIPCHUNK_bKGD
  440. pData->iGlobalBKGDred = 0; /* reset global bKGD data */
  441. pData->iGlobalBKGDgreen = 0;
  442. pData->iGlobalBKGDblue = 0;
  443. #endif
  444. #ifndef MNG_NO_DELTA_PNG
  445. /* reset delta-image */
  446. pData->pDeltaImage = MNG_NULL;
  447. pData->iDeltaImagetype = 0;
  448. pData->iDeltatype = 0;
  449. pData->iDeltaBlockwidth = 0;
  450. pData->iDeltaBlockheight = 0;
  451. pData->iDeltaBlockx = 0;
  452. pData->iDeltaBlocky = 0;
  453. pData->bDeltaimmediate = MNG_FALSE;
  454. pData->fDeltagetrow = MNG_NULL;
  455. pData->fDeltaaddrow = MNG_NULL;
  456. pData->fDeltareplacerow = MNG_NULL;
  457. pData->fDeltaputrow = MNG_NULL;
  458. pData->fPromoterow = MNG_NULL;
  459. pData->fPromBitdepth = MNG_NULL;
  460. pData->pPromBuf = MNG_NULL;
  461. pData->iPromColortype = 0;
  462. pData->iPromBitdepth = 0;
  463. pData->iPromFilltype = 0;
  464. pData->iPromWidth = 0;
  465. pData->pPromSrc = MNG_NULL;
  466. pData->pPromDst = MNG_NULL;
  467. #endif
  468. #ifndef MNG_SKIPCHUNK_MAGN
  469. pData->iMAGNfromid = 0;
  470. pData->iMAGNtoid = 0;
  471. #endif
  472. #ifndef MNG_SKIPCHUNK_PAST
  473. pData->iPastx = 0;
  474. pData->iPasty = 0;
  475. #endif
  476. pData->pLastseek = MNG_NULL;
  477. return MNG_NOERROR;
  478. }
  479. #endif /* MNG_SUPPORT_DISPLAY */
  480. /* ************************************************************************** */
  481. MNG_LOCAL void cleanup_errors (mng_datap pData)
  482. {
  483. pData->iErrorcode = MNG_NOERROR;
  484. pData->iSeverity = 0;
  485. pData->iErrorx1 = 0;
  486. pData->iErrorx2 = 0;
  487. pData->zErrortext = MNG_NULL;
  488. return;
  489. }
  490. /* ************************************************************************** */
  491. #ifdef MNG_SUPPORT_READ
  492. MNG_LOCAL mng_retcode make_pushbuffer (mng_datap pData,
  493. mng_ptr pPushdata,
  494. mng_size_t iLength,
  495. mng_bool bTakeownership,
  496. mng_pushdatap * pPush)
  497. {
  498. mng_pushdatap pTemp;
  499. MNG_ALLOC (pData, pTemp, sizeof(mng_pushdata));
  500. pTemp->pNext = MNG_NULL;
  501. if (bTakeownership) /* are we going to own the buffer? */
  502. { /* then just copy the pointer */
  503. pTemp->pData = (mng_uint8p)pPushdata;
  504. }
  505. else
  506. { /* otherwise create new buffer */
  507. MNG_ALLOCX (pData, pTemp->pData, iLength);
  508. if (!pTemp->pData) /* succeeded? */
  509. {
  510. MNG_FREEX (pData, pTemp, sizeof(mng_pushdata));
  511. MNG_ERROR (pData, MNG_OUTOFMEMORY);
  512. }
  513. /* and copy the bytes across */
  514. MNG_COPY (pTemp->pData, pPushdata, iLength);
  515. }
  516. pTemp->iLength = iLength;
  517. pTemp->bOwned = bTakeownership;
  518. pTemp->pDatanext = pTemp->pData;
  519. pTemp->iRemaining = iLength;
  520. *pPush = pTemp; /* return it */
  521. return MNG_NOERROR; /* and all's well */
  522. }
  523. #endif
  524. #ifdef MNG_VERSION_QUERY_SUPPORT
  525. /* ************************************************************************** */
  526. /* * * */
  527. /* * Versioning control * */
  528. /* * * */
  529. /* ************************************************************************** */
  530. mng_pchar MNG_DECL mng_version_text (void)
  531. {
  532. return MNG_VERSION_TEXT;
  533. }
  534. /* ************************************************************************** */
  535. mng_uint8 MNG_DECL mng_version_so (void)
  536. {
  537. return MNG_VERSION_SO;
  538. }
  539. /* ************************************************************************** */
  540. mng_uint8 MNG_DECL mng_version_dll (void)
  541. {
  542. return MNG_VERSION_DLL;
  543. }
  544. /* ************************************************************************** */
  545. mng_uint8 MNG_DECL mng_version_major (void)
  546. {
  547. return MNG_VERSION_MAJOR;
  548. }
  549. /* ************************************************************************** */
  550. mng_uint8 MNG_DECL mng_version_minor (void)
  551. {
  552. return MNG_VERSION_MINOR;
  553. }
  554. /* ************************************************************************** */
  555. mng_uint8 MNG_DECL mng_version_release (void)
  556. {
  557. return MNG_VERSION_RELEASE;
  558. }
  559. /* ************************************************************************** */
  560. mng_bool MNG_DECL mng_version_beta (void)
  561. {
  562. return MNG_VERSION_BETA;
  563. }
  564. #endif
  565. /* ************************************************************************** */
  566. /* * * */
  567. /* * 'supports' function * */
  568. /* * * */
  569. /* ************************************************************************** */
  570. #ifdef MNG_SUPPORT_FUNCQUERY
  571. typedef struct {
  572. mng_pchar zFunction;
  573. mng_uint8 iMajor; /* Major == 0 means not implemented ! */
  574. mng_uint8 iMinor;
  575. mng_uint8 iRelease;
  576. } mng_func_entry;
  577. typedef mng_func_entry const * mng_func_entryp;
  578. MNG_LOCAL mng_func_entry const func_table [] =
  579. { /* keep it alphabetically sorted !!!!! */
  580. {"mng_cleanup", 1, 0, 0},
  581. {"mng_copy_chunk", 1, 0, 5},
  582. {"mng_create", 1, 0, 0},
  583. {"mng_display", 1, 0, 0},
  584. {"mng_display_freeze", 1, 0, 0},
  585. #ifndef MNG_NO_DISPLAY_GO_SUPPORTED
  586. {"mng_display_goframe", 1, 0, 0},
  587. {"mng_display_golayer", 1, 0, 0},
  588. {"mng_display_gotime", 1, 0, 0},
  589. #endif
  590. {"mng_display_reset", 1, 0, 0},
  591. {"mng_display_resume", 1, 0, 0},
  592. {"mng_get_alphabitdepth", 1, 0, 0},
  593. {"mng_get_alphacompression", 1, 0, 0},
  594. {"mng_get_alphadepth", 1, 0, 0},
  595. {"mng_get_alphafilter", 1, 0, 0},
  596. {"mng_get_alphainterlace", 1, 0, 0},
  597. {"mng_get_bgcolor", 1, 0, 0},
  598. {"mng_get_bitdepth", 1, 0, 0},
  599. {"mng_get_bkgdstyle", 1, 0, 0},
  600. {"mng_get_cacheplayback", 1, 0, 2},
  601. {"mng_get_canvasstyle", 1, 0, 0},
  602. {"mng_get_colortype", 1, 0, 0},
  603. {"mng_get_compression", 1, 0, 0},
  604. #ifndef MNG_NO_CURRENT_INFO
  605. {"mng_get_currentframe", 1, 0, 0},
  606. {"mng_get_currentlayer", 1, 0, 0},
  607. {"mng_get_currentplaytime", 1, 0, 0},
  608. #endif
  609. {"mng_get_currframdelay", 1, 0, 9},
  610. #ifndef MNG_NO_DFLT_INFO
  611. {"mng_get_dfltimggamma", 1, 0, 0},
  612. {"mng_get_dfltimggammaint", 1, 0, 0},
  613. #endif
  614. {"mng_get_displaygamma", 1, 0, 0},
  615. {"mng_get_displaygammaint", 1, 0, 0},
  616. {"mng_get_doprogressive", 1, 0, 2},
  617. {"mng_get_filter", 1, 0, 0},
  618. {"mng_get_framecount", 1, 0, 0},
  619. {"mng_get_imageheight", 1, 0, 0},
  620. {"mng_get_imagelevel", 1, 0, 0},
  621. {"mng_get_imagetype", 1, 0, 0},
  622. {"mng_get_imagewidth", 1, 0, 0},
  623. {"mng_get_interlace", 1, 0, 0},
  624. #ifdef MNG_ACCESS_JPEG
  625. {"mng_get_jpeg_dctmethod", 1, 0, 0},
  626. {"mng_get_jpeg_maxjdat", 1, 0, 0},
  627. {"mng_get_jpeg_optimized", 1, 0, 0},
  628. {"mng_get_jpeg_progressive", 1, 0, 0},
  629. {"mng_get_jpeg_quality", 1, 0, 0},
  630. {"mng_get_jpeg_smoothing", 1, 0, 0},
  631. #endif
  632. {"mng_get_lastbackchunk", 1, 0, 3},
  633. {"mng_get_lastseekname", 1, 0, 5},
  634. {"mng_get_layercount", 1, 0, 0},
  635. #ifndef MNG_SKIP_MAXCANVAS
  636. {"mng_get_maxcanvasheight", 1, 0, 0},
  637. {"mng_get_maxcanvaswidth", 1, 0, 0},
  638. #endif
  639. {"mng_get_playtime", 1, 0, 0},
  640. {"mng_get_refreshpass", 1, 0, 0},
  641. {"mng_get_runtime", 1, 0, 0},
  642. {"mng_get_sectionbreaks", 1, 0, 0},
  643. {"mng_get_sigtype", 1, 0, 0},
  644. {"mng_get_simplicity", 1, 0, 0},
  645. {"mng_get_speed", 1, 0, 0},
  646. {"mng_get_srgb", 1, 0, 0},
  647. {"mng_get_starttime", 1, 0, 0},
  648. {"mng_get_storechunks", 1, 0, 0},
  649. {"mng_get_suspensionmode", 1, 0, 0},
  650. {"mng_get_ticks", 1, 0, 0},
  651. #ifndef MNG_NO_CURRENT_INFO
  652. {"mng_get_totalframes", 1, 0, 5},
  653. {"mng_get_totallayers", 1, 0, 5},
  654. {"mng_get_totalplaytime", 1, 0, 5},
  655. #endif
  656. {"mng_get_usebkgd", 1, 0, 0},
  657. {"mng_get_userdata", 1, 0, 0},
  658. #if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS)
  659. {"mng_get_viewgamma", 1, 0, 0},
  660. {"mng_get_viewgammaint", 1, 0, 0},
  661. #endif
  662. #ifdef MNG_ACCESS_ZLIB
  663. {"mng_get_zlib_level", 1, 0, 0},
  664. {"mng_get_zlib_maxidat", 1, 0, 0},
  665. {"mng_get_zlib_memlevel", 1, 0, 0},
  666. {"mng_get_zlib_method", 1, 0, 0},
  667. {"mng_get_zlib_strategy", 1, 0, 0},
  668. {"mng_get_zlib_windowbits", 1, 0, 0},
  669. #endif
  670. #ifndef MNG_NO_OPEN_CLOSE_STREAM
  671. {"mng_getcb_closestream", 1, 0, 0},
  672. #endif
  673. {"mng_getcb_errorproc", 1, 0, 0},
  674. {"mng_getcb_getalphaline", 1, 0, 0},
  675. {"mng_getcb_getbkgdline", 1, 0, 0},
  676. {"mng_getcb_getcanvasline", 1, 0, 0},
  677. {"mng_getcb_gettickcount", 1, 0, 0},
  678. {"mng_getcb_memalloc", 1, 0, 0},
  679. {"mng_getcb_memfree", 1, 0, 0},
  680. #ifndef MNG_NO_OPEN_CLOSE_STREAM
  681. {"mng_getcb_openstream", 1, 0, 0},
  682. #endif
  683. {"mng_getcb_processarow", 1, 0, 0},
  684. {"mng_getcb_processchroma", 1, 0, 0},
  685. {"mng_getcb_processgamma", 1, 0, 0},
  686. {"mng_getcb_processheader", 1, 0, 0},
  687. {"mng_getcb_processiccp", 1, 0, 0},
  688. {"mng_getcb_processmend", 1, 0, 1},
  689. {"mng_getcb_processneed", 1, 0, 0},
  690. {"mng_getcb_processsave", 1, 0, 0},
  691. {"mng_getcb_processseek", 1, 0, 0},
  692. {"mng_getcb_processsrgb", 1, 0, 0},
  693. {"mng_getcb_processterm", 1, 0, 2},
  694. {"mng_getcb_processtext", 1, 0, 0},
  695. {"mng_getcb_processunknown", 1, 0, 0},
  696. {"mng_getcb_readdata", 1, 0, 0},
  697. {"mng_getcb_refresh", 1, 0, 0},
  698. {"mng_getcb_releasedata", 1, 0, 8},
  699. {"mng_getcb_settimer", 1, 0, 0},
  700. {"mng_getcb_traceproc", 1, 0, 0},
  701. {"mng_getcb_writedata", 1, 0, 0},
  702. {"mng_getchunk_back", 1, 0, 0},
  703. {"mng_getchunk_basi", 1, 0, 0},
  704. #ifndef MNG_SKIPCHUNK_bKGD
  705. {"mng_getchunk_bkgd", 1, 0, 0},
  706. #endif
  707. #ifndef MNG_SKIPCHUNK_cHRM
  708. {"mng_getchunk_chrm", 1, 0, 0},
  709. #endif
  710. {"mng_getchunk_clip", 1, 0, 0},
  711. {"mng_getchunk_clon", 1, 0, 0},
  712. #ifndef MNG_NO_DELTA_PNG
  713. #ifndef MNG_SKIPCHUNK_dBYK
  714. {"mng_getchunk_dbyk", 1, 0, 0},
  715. #endif
  716. #endif
  717. {"mng_getchunk_defi", 1, 0, 0},
  718. #ifndef MNG_NO_DELTA_PNG
  719. {"mng_getchunk_dhdr", 1, 0, 0},
  720. #endif
  721. {"mng_getchunk_disc", 1, 0, 0},
  722. #ifndef MNG_NO_DELTA_PNG
  723. {"mng_getchunk_drop", 1, 0, 0},
  724. #endif
  725. {"mng_getchunk_endl", 1, 0, 0},
  726. #ifdef MNG_INCLUDE_MPNG_PROPOSAL
  727. {"mng_getchunk_mpng", 1, 0, 10},
  728. {"mng_getchunk_mpng_frame", 1, 0, 10},
  729. #endif
  730. #ifndef MNG_SKIPCHUNK_evNT
  731. {"mng_getchunk_evnt", 1, 0, 5},
  732. {"mng_getchunk_evnt_entry", 1, 0, 5},
  733. #endif
  734. #ifndef MNG_SKIPCHUNK_eXPI
  735. {"mng_getchunk_expi", 1, 0, 0},
  736. #endif
  737. #ifndef MNG_SKIPCHUNK_fPRI
  738. {"mng_getchunk_fpri", 1, 0, 0},
  739. #endif
  740. {"mng_getchunk_fram", 1, 0, 0},
  741. {"mng_getchunk_gama", 1, 0, 0},
  742. #ifndef MNG_SKIPCHUNK_hIST
  743. {"mng_getchunk_hist", 1, 0, 0},
  744. #endif
  745. #ifndef MNG_SKIPCHUNK_iCCP
  746. {"mng_getchunk_iccp", 1, 0, 0},
  747. #endif
  748. {"mng_getchunk_idat", 1, 0, 0},
  749. {"mng_getchunk_iend", 1, 0, 0},
  750. {"mng_getchunk_ihdr", 1, 0, 0},
  751. #ifndef MNG_NO_DELTA_PNG
  752. #ifdef MNG_INCLUDE_JNG
  753. {"mng_getchunk_ijng", 1, 0, 0},
  754. #endif
  755. {"mng_getchunk_ipng", 1, 0, 0},
  756. #endif
  757. #ifndef MNG_SKIPCHUNK_iTXt
  758. {"mng_getchunk_itxt", 1, 0, 0},
  759. #endif
  760. #ifdef MNG_INCLUDE_JNG
  761. {"mng_getchunk_jdaa", 1, 0, 0},
  762. {"mng_getchunk_jdat", 1, 0, 0},
  763. {"mng_getchunk_jhdr", 1, 0, 0},
  764. {"mng_getchunk_jsep", 1, 0, 0},
  765. #endif
  766. {"mng_getchunk_loop", 1, 0, 0},
  767. #ifndef MNG_SKIPCHUNK_MAGN
  768. {"mng_getchunk_magn", 1, 0, 0},
  769. #endif
  770. {"mng_getchunk_mend", 1, 0, 0},
  771. {"mng_getchunk_mhdr", 1, 0, 0},
  772. {"mng_getchunk_move", 1, 0, 0},
  773. #ifndef MNG_SKIPCHUNK_nEED
  774. {"mng_getchunk_need", 1, 0, 0},
  775. #endif
  776. #ifndef MNG_SKIPCHUNK_ORDR
  777. #ifndef MNG_NO_DELTA_PNG
  778. {"mng_getchunk_ordr", 1, 0, 0},
  779. {"mng_getchunk_ordr_entry", 1, 0, 0},
  780. #endif
  781. #endif
  782. #ifndef MNG_SKIPCHUNK_PAST
  783. {"mng_getchunk_past", 1, 0, 0},
  784. {"mng_getchunk_past_src", 1, 0, 0},
  785. #endif
  786. #ifndef MNG_SKIPCHUNK_pHYg
  787. {"mng_getchunk_phyg", 1, 0, 0},
  788. #endif
  789. #ifndef MNG_SKIPCHUNK_pHYs
  790. {"mng_getchunk_phys", 1, 0, 0},
  791. #endif
  792. #ifndef MNG_NO_DELTA_PNG
  793. {"mng_getchunk_plte", 1, 0, 0},
  794. {"mng_getchunk_pplt", 1, 0, 0},
  795. {"mng_getchunk_pplt_entry", 1, 0, 0},
  796. {"mng_getchunk_prom", 1, 0, 0},
  797. #endif
  798. #ifndef MNG_SKIPCHUNK_SAVE
  799. {"mng_getchunk_save", 1, 0, 0},
  800. {"mng_getchunk_save_entry", 1, 0, 0},
  801. #endif
  802. #ifndef MNG_SKIPCHUNK_sBIT
  803. {"mng_getchunk_sbit", 1, 0, 0},
  804. #endif
  805. #ifndef MNG_SKIPCHUNK_SEEK
  806. {"mng_getchunk_seek", 1, 0, 0},
  807. #endif
  808. {"mng_getchunk_show", 1, 0, 0},
  809. #ifndef MNG_SKIPCHUNK_sPLT
  810. {"mng_getchunk_splt", 1, 0, 0},
  811. #endif
  812. #ifndef MNG_SKIPCHUNK_sRGB
  813. {"mng_getchunk_srgb", 1, 0, 0},
  814. #endif
  815. {"mng_getchunk_term", 1, 0, 0},
  816. #ifndef MNG_SKIPCHUNK_tEXt
  817. {"mng_getchunk_text", 1, 0, 0},
  818. #endif
  819. #ifndef MNG_SKIPCHUNK_tIME
  820. {"mng_getchunk_time", 1, 0, 0},
  821. #endif
  822. {"mng_getchunk_trns", 1, 0, 0},
  823. {"mng_getchunk_unkown", 1, 0, 0},
  824. #ifndef MNG_SKIPCHUNK_zTXt
  825. {"mng_getchunk_ztxt", 1, 0, 0},
  826. #endif
  827. {"mng_getimgdata_chunk", 0, 0, 0},
  828. {"mng_getimgdata_chunkseq", 0, 0, 0},
  829. {"mng_getimgdata_seq", 0, 0, 0},
  830. {"mng_getlasterror", 1, 0, 0},
  831. {"mng_initialize", 1, 0, 0},
  832. {"mng_iterate_chunks", 1, 0, 0},
  833. {"mng_putchunk_back", 1, 0, 0},
  834. #ifndef MNG_SKIPCHUNK_BASI
  835. {"mng_putchunk_basi", 1, 0, 0},
  836. #endif
  837. #ifndef MNG_SKIPCHUNK_bKGD
  838. {"mng_putchunk_bkgd", 1, 0, 0},
  839. #endif
  840. #ifndef MNG_SKIPCHUNK_cHRM
  841. {"mng_putchunk_chrm", 1, 0, 0},
  842. #endif
  843. {"mng_putchunk_clip", 1, 0, 0},
  844. {"mng_putchunk_clon", 1, 0, 0},
  845. #ifndef MNG_NO_DELTA_PNG
  846. #ifndef MNG_SKIPCHUNK_DBYK
  847. {"mng_putchunk_dbyk", 1, 0, 0},
  848. #endif
  849. #endif
  850. {"mng_putchunk_defi", 1, 0, 0},
  851. #ifndef MNG_NO_DELTA_PNG
  852. {"mng_putchunk_dhdr", 1, 0, 0},
  853. #endif
  854. {"mng_putchunk_disc", 1, 0, 0},
  855. #ifndef MNG_NO_DELTA_PNG
  856. {"mng_putchunk_drop", 1, 0, 0},
  857. #endif
  858. {"mng_putchunk_endl", 1, 0, 0},
  859. #ifdef MNG_INCLUDE_MPNG_PROPOSAL
  860. {"mng_putchunk_mpng", 1, 0, 10},
  861. {"mng_putchunk_mpng_frame", 1, 0, 10},
  862. #endif
  863. #ifndef MNG_SKIPCHUNK_evNT
  864. {"mng_putchunk_evnt", 1, 0, 5},
  865. {"mng_putchunk_evnt_entry", 1, 0, 5},
  866. #endif
  867. #ifndef MNG_SKIPCHUNK_eXPI
  868. {"mng_putchunk_expi", 1, 0, 0},
  869. #endif
  870. #ifndef MNG_SKIPCHUNK_fPRI
  871. {"mng_putchunk_fpri", 1, 0, 0},
  872. #endif
  873. #ifndef MNG_SKIPCHUNK_FRAM
  874. {"mng_putchunk_fram", 1, 0, 0},
  875. #endif
  876. {"mng_putchunk_gama", 1, 0, 0},
  877. #ifndef MNG_SKIPCHUNK_hIST
  878. {"mng_putchunk_hist", 1, 0, 0},
  879. #endif
  880. #ifndef MNG_SKIPCHUNK_iCCP
  881. {"mng_putchunk_iccp", 1, 0, 0},
  882. #endif
  883. {"mng_putchunk_idat", 1, 0, 0},
  884. {"mng_putchunk_iend", 1, 0, 0},
  885. {"mng_putchunk_ihdr", 1, 0, 0},
  886. #ifndef MNG_NO_DELTA_PNG
  887. #ifdef MNG_INCLUDE_JNG
  888. {"mng_putchunk_ijng", 1, 0, 0},
  889. #endif
  890. {"mng_putchunk_ipng", 1, 0, 0},
  891. #endif
  892. #ifndef MNG_SKIPCHUNK_iTXt
  893. {"mng_putchunk_itxt", 1, 0, 0},
  894. #endif
  895. #ifdef MNG_INCLUDE_JNG
  896. {"mng_putchunk_jdaa", 1, 0, 0},
  897. {"mng_putchunk_jdat", 1, 0, 0},
  898. {"mng_putchunk_jhdr", 1, 0, 0},
  899. {"mng_putchunk_jsep", 1, 0, 0},
  900. #endif
  901. {"mng_putchunk_loop", 1, 0, 0},
  902. #ifndef MNG_SKIPCHUNK_MAGN
  903. {"mng_putchunk_magn", 1, 0, 0},
  904. #endif
  905. {"mng_putchunk_mend", 1, 0, 0},
  906. {"mng_putchunk_mhdr", 1, 0, 0},
  907. {"mng_putchunk_move", 1, 0, 0},
  908. #ifndef MNG_SKIPCHUNK_nEED
  909. {"mng_putchunk_need", 1, 0, 0},
  910. #endif
  911. #ifndef MNG_NO_DELTA_PNG
  912. #ifndef MNG_SKIPCHUNK_ORDR
  913. {"mng_putchunk_ordr", 1, 0, 0},
  914. {"mng_putchunk_ordr_entry", 1, 0, 0},
  915. #endif
  916. #endif
  917. #ifndef MNG_SKIPCHUNK_PAST
  918. {"mng_putchunk_past", 1, 0, 0},
  919. {"mng_putchunk_past_src", 1, 0, 0},
  920. #endif
  921. #ifndef MNG_SKIPCHUNK_pHYg
  922. {"mng_putchunk_phyg", 1, 0, 0},
  923. #endif
  924. #ifndef MNG_SKIPCHUNK_pHYs
  925. {"mng_putchunk_phys", 1, 0, 0},
  926. #endif
  927. #ifndef MNG_NO_DELTA_PNG
  928. {"mng_putchunk_plte", 1, 0, 0},
  929. {"mng_putchunk_pplt", 1, 0, 0},
  930. {"mng_putchunk_pplt_entry", 1, 0, 0},
  931. {"mng_putchunk_prom", 1, 0, 0},
  932. #endif
  933. #ifndef MNG_SKIPCHUNK_SAVE
  934. {"mng_putchunk_save", 1, 0, 0},
  935. {"mng_putchunk_save_entry", 1, 0, 0},
  936. #endif
  937. #ifndef MNG_SKIPCHUNK_sBIT
  938. {"mng_putchunk_sbit", 1, 0, 0},
  939. #endif
  940. #ifndef MNG_SKIPCHUNK_SEEK
  941. {"mng_putchunk_seek", 1, 0, 0},
  942. #endif
  943. {"mng_putchunk_show", 1, 0, 0},
  944. #ifndef MNG_SKIPCHUNK_sPLT
  945. {"mng_putchunk_splt", 1, 0, 0},
  946. #endif
  947. #ifndef MNG_SKIPCHUNK_sRGB
  948. {"mng_putchunk_srgb", 1, 0, 0},
  949. #endif
  950. {"mng_putchunk_term", 1, 0, 0},
  951. #ifndef MNG_SKIPCHUNK_tEXt
  952. {"mng_putchunk_text", 1, 0, 0},
  953. #endif
  954. #ifndef MNG_SKIPCHUNK_tIME
  955. {"mng_putchunk_time", 1, 0, 0},
  956. #endif
  957. {"mng_putchunk_trns", 1, 0, 0},
  958. {"mng_putchunk_unkown", 1, 0, 0},
  959. #ifndef MNG_SKIPCHUNK_zTXt
  960. {"mng_putchunk_ztxt", 1, 0, 0},
  961. #endif
  962. {"mng_putimgdata_ihdr", 0, 0, 0},
  963. {"mng_putimgdata_jhdr", 0, 0, 0},
  964. {"mng_reset", 1, 0, 0},
  965. {"mng_read", 1, 0, 0},
  966. {"mng_read_pushchunk", 1, 0, 8},
  967. {"mng_read_pushdata", 1, 0, 8},
  968. {"mng_read_pushsig", 1, 0, 8},
  969. {"mng_read_resume", 1, 0, 0},
  970. {"mng_readdisplay", 1, 0, 0},
  971. {"mng_set_bgcolor", 1, 0, 0},
  972. {"mng_set_bkgdstyle", 1, 0, 0},
  973. {"mng_set_cacheplayback", 1, 0, 2},
  974. {"mng_set_canvasstyle", 1, 0, 0},
  975. {"mng_set_dfltimggamma", 1, 0, 0},
  976. #ifndef MNG_NO_DFLT_INFO
  977. {"mng_set_dfltimggammaint", 1, 0, 0},
  978. #endif
  979. {"mng_set_displaygamma", 1, 0, 0},
  980. {"mng_set_displaygammaint", 1, 0, 0},
  981. {"mng_set_doprogressive", 1, 0, 2},
  982. #ifdef MNG_ACCESS_JPEG
  983. {"mng_set_jpeg_dctmethod", 1, 0, 0},
  984. {"mng_set_jpeg_maxjdat", 1, 0, 0},
  985. {"mng_set_jpeg_optimized", 1, 0, 0},
  986. {"mng_set_jpeg_progressive", 1, 0, 0},
  987. {"mng_set_jpeg_quality", 1, 0, 0},
  988. {"mng_set_jpeg_smoothing", 1, 0, 0},
  989. #endif
  990. #ifndef MNG_SKIP_MAXCANVAS
  991. {"mng_set_maxcanvasheight", 1, 0, 0},
  992. {"mng_set_maxcanvassize", 1, 0, 0},
  993. {"mng_set_maxcanvaswidth", 1, 0, 0},
  994. #endif
  995. {"mng_set_outputprofile", 1, 0, 0},
  996. {"mng_set_outputprofile2", 1, 0, 0},
  997. {"mng_set_outputsrgb", 1, 0, 1},
  998. {"mng_set_sectionbreaks", 1, 0, 0},
  999. {"mng_set_speed", 1, 0, 0},
  1000. {"mng_set_srgb", 1, 0, 0},
  1001. {"mng_set_srgbimplicit", 1, 0, 1},
  1002. {"mng_set_srgbprofile", 1, 0, 0},
  1003. {"mng_set_srgbprofile2", 1, 0, 0},
  1004. {"mng_set_storechunks", 1, 0, 0},
  1005. {"mng_set_suspensionmode", 1, 0, 0},
  1006. {"mng_set_usebkgd", 1, 0, 0},
  1007. {"mng_set_userdata", 1, 0, 0},
  1008. #if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS)
  1009. {"mng_set_viewgamma", 1, 0, 0},
  1010. {"mng_set_viewgammaint", 1, 0, 0},
  1011. #endif
  1012. #ifdef MNG_ACCESS_ZLIB
  1013. {"mng_set_zlib_level", 1, 0, 0},
  1014. {"mng_set_zlib_maxidat", 1, 0, 0},
  1015. {"mng_set_zlib_memlevel", 1, 0, 0},
  1016. {"mng_set_zlib_method", 1, 0, 0},
  1017. {"mng_set_zlib_strategy", 1, 0, 0},
  1018. {"mng_set_zlib_windowbits", 1, 0, 0},
  1019. #endif
  1020. #ifndef MNG_NO_OPEN_CLOSE_STREAM
  1021. {"mng_setcb_closestream", 1, 0, 0},
  1022. #endif
  1023. {"mng_setcb_errorproc", 1, 0, 0},
  1024. {"mng_setcb_getalphaline", 1, 0, 0},
  1025. {"mng_setcb_getbkgdline", 1, 0, 0},
  1026. {"mng_setcb_getcanvasline", 1, 0, 0},
  1027. {"mng_setcb_gettickcount", 1, 0, 0},
  1028. {"mng_setcb_memalloc", 1, 0, 0},
  1029. {"mng_setcb_memfree", 1, 0, 0},
  1030. #ifndef MNG_NO_OPEN_CLOSE_STREAM
  1031. {"mng_setcb_openstream", 1, 0, 0},
  1032. #endif
  1033. {"mng_setcb_processarow", 1, 0, 0},
  1034. {"mng_setcb_processchroma", 1, 0, 0},
  1035. {"mng_setcb_processgamma", 1, 0, 0},
  1036. {"mng_setcb_processheader", 1, 0, 0},
  1037. {"mng_setcb_processiccp", 1, 0, 0},
  1038. {"mng_setcb_processmend", 1, 0, 1},
  1039. {"mng_setcb_processneed", 1, 0, 0},
  1040. {"mng_setcb_processsave", 1, 0, 0},
  1041. {"mng_setcb_processseek", 1, 0, 0},
  1042. {"mng_setcb_processsrgb", 1, 0, 0},
  1043. {"mng_setcb_processterm", 1, 0, 2},
  1044. {"mng_setcb_processtext", 1, 0, 0},
  1045. {"mng_setcb_processunknown", 1, 0, 0},
  1046. {"mng_setcb_readdata", 1, 0, 0},
  1047. {"mng_setcb_refresh", 1, 0, 0},
  1048. {"mng_setcb_releasedata", 1, 0, 8},
  1049. {"mng_setcb_settimer", 1, 0, 0},
  1050. {"mng_setcb_traceproc", 1, 0, 0},
  1051. {"mng_setcb_writedata", 1, 0, 0},
  1052. {"mng_status_creating", 1, 0, 0},
  1053. {"mng_status_displaying", 1, 0, 0},
  1054. {"mng_status_dynamic", 1, 0, 5},
  1055. {"mng_status_error", 1, 0, 0},
  1056. {"mng_status_reading", 1, 0, 0},
  1057. {"mng_status_running", 1, 0, 0},
  1058. {"mng_status_runningevent", 1, 0, 5},
  1059. {"mng_status_suspendbreak", 1, 0, 0},
  1060. {"mng_status_timerbreak", 1, 0, 0},
  1061. {"mng_status_writing", 1, 0, 0},
  1062. {"mng_supports_func", 1, 0, 5},
  1063. {"mng_trapevent", 1, 0, 5},
  1064. {"mng_updatemngheader", 1, 0, 0},
  1065. {"mng_updatemngsimplicity", 1, 0, 0},
  1066. {"mng_version_beta", 1, 0, 5},
  1067. {"mng_version_dll", 1, 0, 0},
  1068. {"mng_version_major", 1, 0, 0},
  1069. {"mng_version_minor", 1, 0, 0},
  1070. {"mng_version_release", 1, 0, 0},
  1071. {"mng_version_so", 1, 0, 0},
  1072. {"mng_version_text", 1, 0, 0},
  1073. {"mng_write", 1, 0, 0},
  1074. };
  1075. mng_bool MNG_DECL mng_supports_func (mng_pchar zFunction,
  1076. mng_uint8* iMajor,
  1077. mng_uint8* iMinor,
  1078. mng_uint8* iRelease)
  1079. {
  1080. mng_int32 iTop, iLower, iUpper, iMiddle;
  1081. mng_func_entryp pEntry; /* pointer to found entry */
  1082. /* determine max index of table */
  1083. iTop = (sizeof (func_table) / sizeof (func_table [0])) - 1;
  1084. iLower = 0; /* initialize binary search */
  1085. iMiddle = iTop >> 1; /* start in the middle */
  1086. iUpper = iTop;
  1087. pEntry = 0; /* no goods yet! */
  1088. do /* the binary search itself */
  1089. {
  1090. mng_int32 iRslt = strcmp(func_table [iMiddle].zFunction, zFunction);
  1091. if (iRslt < 0)
  1092. iLower = iMiddle + 1;
  1093. else if (iRslt > 0)
  1094. iUpper = iMiddle - 1;
  1095. else
  1096. {
  1097. pEntry = &func_table [iMiddle];
  1098. break;
  1099. };
  1100. iMiddle = (iLower + iUpper) >> 1;
  1101. }
  1102. while (iLower <= iUpper);
  1103. if (pEntry) /* found it ? */
  1104. {
  1105. *iMajor = pEntry->iMajor;
  1106. *iMinor = pEntry->iMinor;
  1107. *iRelease = pEntry->iRelease;
  1108. return MNG_TRUE;
  1109. }
  1110. else
  1111. {
  1112. *iMajor = 0;
  1113. *iMinor = 0;
  1114. *iRelease = 0;
  1115. return MNG_FALSE;