CHUNKS.CPP 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689
  1. //
  2. // Chunks.cpp
  3. //
  4. // The following functions are to assemble a string for each chunk
  5. // The function name "Info_????" denote which chunk it handles
  6. //
  7. // Comments marked @todo@ may, or maynot, be filled in at a later date !
  8. //
  9. //---------------------------------------------------------------------------
  10. #include <vcl.h>
  11. #pragma hdrstop
  12. #include "Main.h"
  13. # define xUSE_UNKNOWN // remove "x" to report of "UNKNOWN" - else ""
  14. # define FFACTOR ((float)100000.0)
  15. // NB We must use Octal for RichEdit's newlines - MicroSoft love Octal !
  16. # define nl "\015\012"
  17. # define TAB asTab
  18. // Ps : If anyone reading this knows how to do this using token
  19. // pasting please let me know ! (AP)
  20. // ConCat newline to string
  21. # define NL as = as + nl
  22. // Integer ARGuement
  23. # define IARG( _str_, _int_ )\
  24. as = as + TAB + (_str_) + " " + String( _int_ )
  25. // Bool ARGuement
  26. # define BARG( _str_, _bool_ )\
  27. if( WantsBool() )\
  28. as = as + TAB + (_str_) + " " + ((_bool_) ? "true" : "false");\
  29. else\
  30. as = as + TAB + (_str_) + " " + IntToStr( _bool_ );
  31. // Float ARGuement
  32. # define FARG( _str_, _float_ )\
  33. as = as + TAB + (_str_) + " " + String( _float_ )
  34. // szText ARGuement
  35. # define ZARG( _str_, _sz_ )\
  36. as = as + TAB + (_str_) + " \"" + String( _sz_ ) + "\""
  37. // Concat general strings
  38. # define STR( _str_ ) as = as + _str_
  39. // Concat Hex string
  40. # define HEXSTR( _str_ ) as = as + IntToHex(_str_,2)
  41. // Concat Macro Identifier to ARG
  42. #define MI( _str_ ) as = as + TAB + _str_;
  43. // Concat "(" Comment ")" to ARG
  44. #define PCOM( _str_ )\
  45. if( WantsComments() ) as = as + TAB + "(" + _str_ + ")";
  46. // Concat "float(" Comment ")" to ARG
  47. #define FPCOM( _str_ )\
  48. if( WantsComments() ) as = as + TAB + "float(" + _str_ + ")";
  49. //---------------------------------------------------------------------------
  50. // Macro Identifiers - these, below, are used several times
  51. // NB those used once have local #define's and #undef's
  52. //---------------------------------------------------------------------------
  53. # ifdef USE_UNKNOWN
  54. # define UNKNOWN "UNKNOWN"
  55. # else
  56. # define UNKNOWN ""
  57. # endif
  58. // Does this need two to be more visible ?
  59. # define ILLEGAL_VALUE ">> ILLEGAL VALUE << "
  60. // IHDR, BASI, JHDR, PROM, sPLT
  61. # define MI_BITDEPTH( _i_ )\
  62. if( WantsMacroIds() )\
  63. switch( (_i_) ) {\
  64. case MNG_BITDEPTH_1 : MI( "MNG_BITDEPTH_1" ); break;\
  65. case MNG_BITDEPTH_2 : MI( "MNG_BITDEPTH_2" ); break;\
  66. case MNG_BITDEPTH_4 : MI( "MNG_BITDEPTH_4" ); break;\
  67. case MNG_BITDEPTH_8 : MI( "MNG_BITDEPTH_8" ); break;\
  68. case MNG_BITDEPTH_16 : MI( "MNG_BITDEPTH_16" ); break;\
  69. default : MI(ILLEGAL_VALUE);\
  70. }
  71. // IHDR, BASI, PROM
  72. # define MI_COLORTYPE( _i_ )\
  73. if( WantsMacroIds() )\
  74. switch( (_i_) ) {\
  75. case MNG_COLORTYPE_GRAY : MI( "MNG_COLORTYPE_GRAY" ); break;\
  76. case MNG_COLORTYPE_RGB : MI( "MNG_COLORTYPE_RGB" ); break;\
  77. case MNG_COLORTYPE_INDEXED : MI( "MNG_COLORTYPE_INDEXED" ); break;\
  78. case MNG_COLORTYPE_GRAYA : MI( "MNG_COLORTYPE_GRAYA" ); break;\
  79. case MNG_COLORTYPE_RGBA : MI( "MNG_COLORTYPE_RGBA" ); break;\
  80. default : MI(ILLEGAL_VALUE);\
  81. }
  82. // IHDR, zTXt, iTXt, iCCP, BASI, JHDR
  83. # define MI_COMPRESSION_DEFLATE( _i_ )\
  84. if( WantsMacroIds() ) {\
  85. if( (_i_) == MNG_COMPRESSION_DEFLATE ) {\
  86. MI( "MNG_COMPRESSION_DEFLATE" );\
  87. } else {\
  88. MI( ILLEGAL_VALUE );\
  89. }\
  90. }
  91. // IHDR, BASI, JHDR
  92. # define MI_FILTER( _i_ )\
  93. if( WantsMacroIds() )\
  94. switch( _i_ ) {\
  95. case MNG_FILTER_ADAPTIVE : MI( "MNG_FILTER_ADAPTIVE" ); break;\
  96. case MNG_FILTER_NO_ADAPTIVE : MI( "MNG_FILTER_NO_ADAPTIVE" ); break;\
  97. case MNG_FILTER_DIFFERING : MI( "MNG_FILTER_DIFFERING" ); break;\
  98. case MNG_FILTER_MASK : MI( "MNG_FILTER_MASK" ); break;\
  99. default : MI(UNKNOWN);\
  100. }
  101. //NB MNG_FILTER_NO_DIFFERING == MNG_FILTER_ADAPTIVE
  102. // IHDR, BASI, JHDR
  103. #define MI_INTERLACE( _i_ )\
  104. if( WantsMacroIds() ) {\
  105. if( (_i_) == MNG_INTERLACE_NONE ) {\
  106. MI( "MNG_INTERLACE_NONE" )\
  107. } else if( (_i_) == MNG_INTERLACE_ADAM7 ) {\
  108. MI( "MNG_INTERLACE_ADAM7" );\
  109. } else { MI(ILLEGAL_VALUE);} \
  110. }
  111. // pHYs, pHYg
  112. #define MI_UNITS( _i_ )\
  113. if( WantsMacroIds() ) {\
  114. if( (_i_) == MNG_UNIT_UNKNOWN ) {\
  115. MI( "MNG_UNIT_UNKNOWN" )\
  116. } else if( (_i_) == MNG_UNIT_METER ) {\
  117. MI( "MNG_UNIT_METER" );\
  118. } else { MI(UNKNOWN);} \
  119. }
  120. // CLON & MOVE
  121. #define MI_LOCATION( _i_ )\
  122. if( WantsMacroIds() ) {\
  123. if( (_i_) == MNG_LOCATION_ABSOLUTE ) {\
  124. MI( "MNG_LOCATION_ABSOLUTE" )\
  125. } else if( (_i_) == MNG_LOCATION_RELATIVE ) {\
  126. MI( "MNG_LOCATION_RELATIVE" );\
  127. } else { MI(ILLEGAL_VALUE);} \
  128. }
  129. //---------------------------------------------------------------------------
  130. bool __fastcall TMainForm::Info_BACK( mng_handle hMNG, mng_handle hChunk, String &as )
  131. {
  132. // NB for BACKGROUND other values are only advisory
  133. #define MI_BACKGROUND( _i_ )\
  134. if( WantsMacroIds() ) {\
  135. if( (_i_) == MNG_BACKGROUNDCOLOR_MANDATORY ) {\
  136. MI( "MNG_BACKGROUNDCOLOR_MANDATORY" )\
  137. } else if( (_i_) == MNG_BACKGROUNDIMAGE_MANDATORY ) {\
  138. MI( "MNG_BACKGROUNDIMAGE_MANDATORY" );\
  139. } \
  140. }
  141. # define MI_BACKGROUND_TILE( _i_ )\
  142. if( WantsMacroIds() )\
  143. switch( _i_ ) {\
  144. case MNG_BACKGROUNDIMAGE_NOTILE : MI( "MNG_BACKGROUNDIMAGE_NOTILE" ); break;\
  145. case MNG_BACKGROUNDIMAGE_TILE : MI( "MNG_BACKGROUNDIMAGE_TILE" ); break;\
  146. default : MI(UNKNOWN);\
  147. }
  148. mng_uint16 iRed;
  149. mng_uint16 iGreen;
  150. mng_uint16 iBlue;
  151. mng_uint8 iMandatory;
  152. mng_uint16 iImageid;
  153. mng_uint8 iTile;
  154. if( mng_getchunk_back( hMNG, hChunk,
  155. &iRed, &iGreen, &iBlue,
  156. &iMandatory, &iImageid, &iTile ) != 0 )
  157. return false;
  158. IARG( "iRed", iRed );
  159. NL; IARG( "iGreen",iGreen );
  160. NL; IARG( "iBlue", iBlue );
  161. NL; IARG( "iMandatory", iMandatory ); MI_BACKGROUND( iMandatory );
  162. NL; IARG( "iImageid", iImageid );
  163. NL; IARG( "iTile", iTile ); MI_BACKGROUND_TILE( iTile );
  164. return true;
  165. # undef MI_BACKGROUND
  166. # undef MI_BACKGROUND_TILE
  167. }
  168. //---------------------------------------------------------------------------
  169. bool __fastcall TMainForm::Info_BASI( mng_handle hMNG, mng_handle hChunk, String &as )
  170. {
  171. #define MI_VIEWABLE( _i_ )\
  172. if( WantsMacroIds() ) {\
  173. if( (_i_) == MNG_NOTVIEWABLE ) {\
  174. MI( "MNG_NOTVIEWABLE" )\
  175. } else if( (_i_) == MNG_VIEWABLE ) {\
  176. MI( "MNG_VIEWABLE" );\
  177. } else { MI(UNKNOWN);} \
  178. }
  179. mng_uint32 iWidth;
  180. mng_uint32 iHeight;
  181. mng_uint8 iBitdepth;
  182. mng_uint8 iColortype;
  183. mng_uint8 iCompression;
  184. mng_uint8 iFilter;
  185. mng_uint8 iInterlace;
  186. mng_uint16 iRed;
  187. mng_uint16 iGreen;
  188. mng_uint16 iBlue;
  189. mng_uint16 iAlpha;
  190. mng_uint8 iViewable;
  191. if( mng_getchunk_basi( hMNG, hChunk,
  192. &iWidth, &iHeight, &iBitdepth, &iColortype,
  193. &iCompression, &iFilter, &iInterlace,
  194. &iRed, &iGreen, &iBlue, &iAlpha,
  195. &iViewable ) != 0 )
  196. return false;
  197. IARG( "iWidth", iWidth );
  198. NL; IARG( "iHeight", iHeight );
  199. NL; IARG( "iBitdepth", iBitdepth ); MI_BITDEPTH( iBitdepth );
  200. NL; IARG( "iColortype", iColortype ); MI_COLORTYPE( iColortype );
  201. NL; IARG( "iCompression", iCompression ); MI_COMPRESSION_DEFLATE( iCompression );
  202. NL; IARG( "iFilter", iFilter ); MI_FILTER( iFilter );
  203. NL; IARG( "iInterlace", iInterlace ); MI_INTERLACE( iInterlace );
  204. NL; IARG( "iRed", iRed );
  205. NL; IARG( "iGreen", iGreen );
  206. NL; IARG( "iBlue", iBlue );
  207. NL; IARG( "iAlpha", iAlpha );
  208. NL; IARG( "iViewable", iViewable ); MI_VIEWABLE( iViewable );
  209. return true;
  210. # undef MI_VIEWABLE
  211. }
  212. //---------------------------------------------------------------------------
  213. bool __fastcall TMainForm::Info_CLIP( mng_handle hMNG, mng_handle hChunk, String &as )
  214. {
  215. # define MI_CLIPPING( _i_ )\
  216. if( WantsMacroIds() )\
  217. switch( _i_ ) {\
  218. case MNG_CLIPPING_ABSOLUTE : MI( "MNG_CLIPPING_ABSOLUTE" ); break;\
  219. case MNG_CLIPPING_RELATIVE : MI( "MNG_CLIPPING_RELATIVE" ); break;\
  220. default : MI(UNKNOWN);\
  221. }
  222. mng_uint16 iFirstid;
  223. mng_uint16 iLastid;
  224. mng_uint8 iCliptype;
  225. mng_int32 iClipl;
  226. mng_int32 iClipr;
  227. mng_int32 iClipt;
  228. mng_int32 iClipb;
  229. if( mng_getchunk_clip( hMNG, hChunk,
  230. &iFirstid, &iLastid,
  231. &iCliptype, &iClipl, &iClipr, &iClipt, &iClipb ) != 0 )
  232. return false;
  233. IARG( "iFirstid", iFirstid );
  234. NL; IARG( "iLastid", iLastid );
  235. NL; IARG( "iCliptype", iCliptype ); MI_CLIPPING( iCliptype );
  236. NL; IARG( "iClipl", iClipl );
  237. NL; IARG( "iClipr", iClipr );
  238. NL; IARG( "iClipt", iClipt );
  239. NL; IARG( "iClipb", iClipb );
  240. return true;
  241. # undef MI_CLIPPING
  242. }
  243. //---------------------------------------------------------------------------
  244. bool __fastcall TMainForm::Info_CLON( mng_handle hMNG, mng_handle hChunk, String &as )
  245. {
  246. # define MI_CLONTYPE( _i_ )\
  247. if( WantsMacroIds() )\
  248. switch( (_i_) ) {\
  249. case MNG_FULL_CLONE : MI( "MNG_FULL_CLONE" ); break;\
  250. case MNG_PARTIAL_CLONE : MI( "MNG_PARTIAL_CLONE" ); break;\
  251. case MNG_RENUMBER : MI( "MNG_RENUMBER" ); break;\
  252. default : MI(UNKNOWN);\
  253. }
  254. #define MI_CLON_CONCRETE( _i_ )\
  255. if( WantsMacroIds() ) {\
  256. if( (_i_) == MNG_CONCRETE_ASPARENT ) {\
  257. MI( "MNG_CONCRETE_ASPARENT" )\
  258. } else if( (_i_) == MNG_CONCRETE_MAKEABSTRACT ) {\
  259. MI( "MNG_CONCRETE_MAKEABSTRACT" );\
  260. } else { MI(UNKNOWN);} \
  261. }
  262. mng_uint16 iSourceid;
  263. mng_uint16 iCloneid;
  264. mng_uint8 iClonetype;
  265. mng_uint8 iDonotshow;
  266. mng_uint8 iConcrete;
  267. mng_bool bHasloca;
  268. mng_uint8 iLocationtype;
  269. mng_int32 iLocationx;
  270. mng_int32 iLocationy;
  271. if( mng_getchunk_clon( hMNG, hChunk,
  272. &iSourceid, &iCloneid, &iClonetype, &iDonotshow,
  273. &iConcrete, &bHasloca,
  274. &iLocationtype, &iLocationx, &iLocationy ) != 0 )
  275. return false;
  276. IARG( "iSourceid", iSourceid );
  277. NL; IARG( "iCloneid", iCloneid );
  278. NL; IARG( "iClonetype", iClonetype ); MI_CLONTYPE( iClonetype );
  279. NL; IARG( "iDonotshow", iDonotshow );
  280. NL; IARG( "iConcrete", iConcrete ); MI_CLON_CONCRETE( iConcrete );
  281. NL; BARG( "bHasloca", bHasloca );
  282. NL; IARG( "iLocationtype", iLocationtype ); MI_LOCATION( iLocationtype );
  283. NL; IARG( "iLocationx", iLocationx );
  284. NL; IARG( "iLocationy", iLocationy );
  285. return true;
  286. # undef MI_CLONTYPE
  287. # undef MI_CLON_CONCRETE
  288. }
  289. //---------------------------------------------------------------------------
  290. bool __fastcall TMainForm::Info_DBYK( mng_handle hMNG, mng_handle hChunk, String &as )
  291. {
  292. # define MI_POLARITY( _i_ )\
  293. if( WantsMacroIds() )\
  294. switch( _i_ ) {\
  295. case MNG_POLARITY_ONLY : MI( "MNG_POLARITY_ONLY" ); break;\
  296. case MNG_POLARITY_ALLBUT : MI( "MNG_POLARITY_ALLBUT" ); break;\
  297. default : MI(UNKNOWN);\
  298. }
  299. mng_chunkid iChunkname;
  300. mng_uint8 iPolarity;
  301. mng_uint32 iKeywordssize;
  302. mng_pchar zKeywords;
  303. if( mng_getchunk_dbyk( hMNG, hChunk,
  304. &iChunkname, &iPolarity, &iKeywordssize, &zKeywords ) != 0 )
  305. return false;
  306. IARG( "iChunkname", iChunkname ); // show chunk name ? @todo@
  307. NL; IARG( "iPolarity", iPolarity ); MI_POLARITY( iPolarity );
  308. NL; IARG( "iKeywordssize", iKeywordssize );
  309. NL; ZARG( "zKeywords", zKeywords );
  310. return true;
  311. # undef MI_POLARITY
  312. }
  313. //---------------------------------------------------------------------------
  314. bool __fastcall TMainForm::Info_DEFI( mng_handle hMNG, mng_handle hChunk, String &as )
  315. {
  316. #define MI_DONOTSHOW( _i_ )\
  317. if( WantsMacroIds() ) {\
  318. if( (_i_) == MNG_DONOTSHOW_VISIBLE ) {\
  319. MI( "MNG_DONOTSHOW_VISIBLE" )\
  320. } else if( (_i_) == MNG_DONOTSHOW_NOTVISIBLE ) {\
  321. MI( "MNG_DONOTSHOW_NOTVISIBLE" );\
  322. }\
  323. }
  324. #define MI_DEFI_CONCRETE( _i_ )\
  325. if( WantsMacroIds() ) {\
  326. if( (_i_) == MNG_ABSTRACT ) {\
  327. MI( "MNG_ABSTRACT" )\
  328. } else if( (_i_) == MNG_CONCRETE ) {\
  329. MI( "MNG_CONCRETE" );\
  330. }\
  331. }
  332. mng_uint16 iObjectid;
  333. mng_uint8 iDonotshow;
  334. mng_uint8 iConcrete;
  335. mng_bool bHasloca;
  336. mng_int32 iXlocation;
  337. mng_int32 iYlocation;
  338. mng_bool bHasclip;
  339. mng_int32 iLeftcb;
  340. mng_int32 iRightcb;
  341. mng_int32 iTopcb;
  342. mng_int32 iBottomcb;
  343. if( mng_getchunk_defi( hMNG, hChunk,
  344. &iObjectid, &iDonotshow, &iConcrete,
  345. &bHasloca, &iXlocation, &iYlocation,
  346. &bHasclip, &iLeftcb, &iRightcb, &iTopcb, &iBottomcb ) != 0 )
  347. return false;
  348. IARG( "iObjectid", iObjectid );
  349. NL; IARG( "iDonotshow", iDonotshow ); MI_DONOTSHOW( iDonotshow );
  350. NL; IARG( "iConcrete", iConcrete ); MI_DEFI_CONCRETE( iConcrete );
  351. NL; BARG( "bHasloca", bHasloca );
  352. NL; IARG( "iXlocation", iXlocation );
  353. NL; IARG( "iYlocation", iYlocation );
  354. NL; BARG( "bHasclip", bHasclip );
  355. NL; IARG( "iLeftcb", iLeftcb );
  356. NL; IARG( "iRightcb", iRightcb );
  357. NL; IARG( "iTopcb", iTopcb );
  358. NL; IARG( "iBottomcb", iBottomcb );
  359. return true;
  360. # undef MI_DONOTSHOW
  361. # undef MI_DEFI_CONCRETE
  362. }
  363. //---------------------------------------------------------------------------
  364. bool __fastcall TMainForm::Info_DHDR( mng_handle hMNG, mng_handle hChunk, String &as )
  365. {
  366. # define MI_IMAGETYPE( _i_ )\
  367. if( WantsMacroIds() )\
  368. switch( _i_ ) {\
  369. case MNG_IMAGETYPE_UNKNOWN : MI( "MNG_IMAGETYPE_UNKNOWN" ); break;\
  370. case MNG_IMAGETYPE_PNG : MI( "MNG_IMAGETYPE_PNG" ); break;\
  371. case MNG_IMAGETYPE_JNG : MI( "MNG_IMAGETYPE_JNG" ); break;\
  372. default : MI(UNKNOWN);\
  373. }
  374. # define MI_DELTATYPE( _i_ )\
  375. if( WantsMacroIds() )\
  376. switch( _i_ ) {\
  377. case MNG_DELTATYPE_REPLACE : MI( "MNG_DELTATYPE_REPLACE" ); break;\
  378. case MNG_DELTATYPE_BLOCKPIXELADD : MI( "MNG_DELTATYPE_BLOCKPIXELADD" ); break;\
  379. case MNG_DELTATYPE_BLOCKALPHAADD : MI( "MNG_DELTATYPE_BLOCKALPHAADD" ); break;\
  380. case MNG_DELTATYPE_BLOCKCOLORADD : MI( "MNG_DELTATYPE_BLOCKCOLORADD" ); break;\
  381. case MNG_DELTATYPE_BLOCKPIXELREPLACE : MI( "MNG_DELTATYPE_BLOCKPIXELREPLACE" ); break;\
  382. case MNG_DELTATYPE_BLOCKALPHAREPLACE : MI( "MNG_DELTATYPE_BLOCKALPHAREPLACE" ); break;\
  383. case MNG_DELTATYPE_BLOCKCOLORREPLACE : MI( "MNG_DELTATYPE_BLOCKCOLORREPLACE" ); break;\
  384. case MNG_DELTATYPE_NOCHANGE : MI( "MNG_DELTATYPE_NOCHANGE" ); break;\
  385. default : MI(UNKNOWN);\
  386. }
  387. mng_uint16 iObjectid;
  388. mng_uint8 iImagetype;
  389. mng_uint8 iDeltatype;
  390. mng_uint32 iBlockwidth;
  391. mng_uint32 iBlockheight;
  392. mng_uint32 iBlockx;
  393. mng_uint32 iBlocky;
  394. if( mng_getchunk_dhdr( hMNG, hChunk,
  395. &iObjectid, &iImagetype, &iDeltatype,
  396. &iBlockwidth, &iBlockheight, &iBlockx, &iBlocky ) != 0 )
  397. return false;
  398. IARG( "iObjectid", iObjectid );
  399. NL; IARG( "iImagetype", iImagetype ); MI_IMAGETYPE( iImagetype );
  400. NL; IARG( "iDeltatype", iDeltatype ); MI_DELTATYPE( iDeltatype );
  401. NL; IARG( "iBlockwidth", iBlockwidth );
  402. NL; IARG( "iBlockheight", iBlockheight );
  403. NL; IARG( "iBlockx", iBlockx );
  404. NL; IARG( "iBlocky", iBlocky );
  405. return true;
  406. # undef MI_IMAGETYPE
  407. # undef MI_DELTATYPE
  408. }
  409. //---------------------------------------------------------------------------
  410. bool __fastcall TMainForm::Info_DISC( mng_handle hMNG, mng_handle hChunk, String &as )
  411. {
  412. mng_uint32 iCount;
  413. mng_uint16p pObjectids;
  414. if( mng_getchunk_disc( hMNG, hChunk, &iCount, &pObjectids ) != 0 )
  415. return false;
  416. IARG( "iCount", iCount );
  417. //pObjectids pObjectids
  418. return true;
  419. }
  420. //---------------------------------------------------------------------------
  421. bool __fastcall TMainForm::Info_DROP( mng_handle hMNG, mng_handle hChunk, String &as )
  422. {
  423. mng_uint32 iCount;
  424. mng_chunkidp pChunknames;
  425. if( mng_getchunk_drop( hMNG, hChunk, &iCount, &pChunknames ) != 0 )
  426. return false;
  427. IARG( "iCount", iCount );
  428. // pChunknamesp Chunknames // Iterate chunk names ? @todo@
  429. return true;
  430. }
  431. //---------------------------------------------------------------------------
  432. bool __fastcall TMainForm::Info_ENDL( mng_handle hMNG, mng_handle hChunk, String &as )
  433. {
  434. mng_uint8 iLevel;
  435. if( mng_getchunk_endl( hMNG, hChunk, &iLevel ) != 0 )
  436. return false;
  437. IARG( "iLevel", iLevel );
  438. return true;
  439. }
  440. //---------------------------------------------------------------------------
  441. bool __fastcall TMainForm::Info_FRAM( mng_handle hMNG, mng_handle hChunk, String &as )
  442. {
  443. # define MI_BOUNDARY( _i_ )\
  444. if( WantsMacroIds() )\
  445. switch( _i_ ) {\
  446. case MNG_BOUNDARY_ABSOLUTE : MI( "MNG_BOUNDARY_ABSOLUTE" ); break;\
  447. case MNG_BOUNDARY_RELATIVE : MI( "MNG_BOUNDARY_RELATIVE" ); break;\
  448. default : MI(UNKNOWN);\
  449. }
  450. # define MI_FRAMINGMODE( _i_ )\
  451. if( WantsMacroIds() )\
  452. switch( _i_ ) {\
  453. case MNG_FRAMINGMODE_NOCHANGE : MI( "MNG_FRAMINGMODE_NOCHANGE" ); break;\
  454. case MNG_FRAMINGMODE_1 : MI( "MNG_FRAMINGMODE_1" ); break;\
  455. case MNG_FRAMINGMODE_2 : MI( "MNG_FRAMINGMODE_2" ); break;\
  456. case MNG_FRAMINGMODE_3 : MI( "MNG_FRAMINGMODE_3" ); break;\
  457. case MNG_FRAMINGMODE_4 : MI( "MNG_FRAMINGMODE_4" ); break;\
  458. default : MI(UNKNOWN);\
  459. }
  460. # define MI_CHANGEDELAY( _i_ )\
  461. if( WantsMacroIds() )\
  462. switch( _i_ ) {\
  463. case MNG_CHANGEDELAY_NO : MI( "MNG_CHANGEDELAY_NO" ); break;\
  464. case MNG_CHANGEDELAY_NEXTSUBFRAME : MI( "MNG_CHANGEDELAY_NEXTSUBFRAME" ); break;\
  465. case MNG_CHANGEDELAY_DEFAULT : MI( "MNG_CHANGEDELAY_DEFAULT" ); break;\
  466. default : MI(UNKNOWN);\
  467. }
  468. # define MI_CHANGETIMOUT( _i_ )\
  469. if( WantsMacroIds() )\
  470. switch( _i_ ) {\
  471. case MNG_CHANGETIMOUT_NO : MI( "MNG_CHANGETIMOUT_NO" ); break;\
  472. case MNG_CHANGETIMOUT_DETERMINISTIC_1 : MI( "MNG_CHANGETIMOUT_DETERMINISTIC_1" ); break;\
  473. case MNG_CHANGETIMOUT_DETERMINISTIC_2 : MI( "MNG_CHANGETIMOUT_DETERMINISTIC_2" ); break;\
  474. case MNG_CHANGETIMOUT_DECODER_1 : MI( "MNG_CHANGETIMOUT_DECODER_1" ); break;\
  475. case MNG_CHANGETIMOUT_DECODER_2 : MI( "MNG_CHANGETIMOUT_DECODER_2" ); break;\
  476. case MNG_CHANGETIMOUT_USER_1 : MI( "MNG_CHANGETIMOUT_USER_1" ); break;\
  477. case MNG_CHANGETIMOUT_USER_2 : MI( "MNG_CHANGETIMOUT_USER_2" ); break;\
  478. case MNG_CHANGETIMOUT_EXTERNAL_1 : MI( "MNG_CHANGETIMOUT_EXTERNAL_1" ); break;\
  479. case MNG_CHANGETIMOUT_EXTERNAL_2 : MI( " MNG_CHANGETIMOUT_EXTERNAL_2" ); break;\
  480. default : MI(UNKNOWN);\
  481. }
  482. # define MI_CHANGECLIPPING( _i_ )\
  483. if( WantsMacroIds() )\
  484. switch( _i_ ) {\
  485. case MNG_CHANGECLIPPING_NO : MI( "MNG_CHANGECLIPPING_NO" ); break;\
  486. case MNG_CHANGECLIPPING_NEXTSUBFRAME : MI( "MNG_CHANGECLIPPING_NEXTSUBFRAME" ); break;\
  487. case MNG_CHANGECLIPPING_DEFAULT : MI( "MNG_CHANGECLIPPING_DEFAULT" ); break;\
  488. default : MI(UNKNOWN);\
  489. }
  490. # define MI_CHANGESYNCID( _i_ )\
  491. if( WantsMacroIds() )\
  492. switch( _i_ ) {\
  493. case MNG_CHANGESYNCID_NO : MI( "MNG_CHANGESYNCID_NO" ); break;\
  494. case MNG_CHANGESYNCID_NEXTSUBFRAME : MI( "MNG_CHANGESYNCID_NEXTSUBFRAME" ); break;\
  495. case MNG_CHANGESYNCID_DEFAULT : MI( "MNG_CHANGESYNCID_DEFAULT" ); break;\
  496. default : MI(UNKNOWN);\
  497. }
  498. mng_bool bEmpty;
  499. mng_uint8 iMode;
  500. mng_uint32 iNamesize;
  501. mng_pchar zName;
  502. mng_uint8 iChangedelay;
  503. mng_uint8 iChangetimeout;
  504. mng_uint8 iChangeclipping;
  505. mng_uint8 iChangesyncid;
  506. mng_uint32 iDelay;
  507. mng_uint32 iTimeout;
  508. mng_uint8 iBoundarytype;
  509. mng_int32 iBoundaryl;
  510. mng_int32 iBoundaryr;
  511. mng_int32 iBoundaryt;
  512. mng_int32 iBoundaryb;
  513. mng_uint32 iCount;
  514. mng_uint32p pSyncids;
  515. if( mng_getchunk_fram( hMNG, hChunk,
  516. &bEmpty, &iMode, &iNamesize, &zName,
  517. &iChangedelay, &iChangetimeout, &iChangeclipping, &iChangesyncid,
  518. &iDelay, &iTimeout,
  519. &iBoundarytype, &iBoundaryl, &iBoundaryr,&iBoundaryt, &iBoundaryb,
  520. &iCount, &pSyncids ) != 0 )
  521. return false;
  522. BARG( "bEmpty", bEmpty );
  523. NL; IARG( "iMode", iMode ); MI_FRAMINGMODE( iMode );
  524. NL; IARG( "iNamesize", iNamesize );
  525. NL; ZARG( "zName", zName );
  526. NL; IARG( "iChangedelay", iChangedelay ); MI_CHANGEDELAY( iChangedelay );
  527. NL; IARG( "iChangetimeout", iChangetimeout ); MI_CHANGETIMOUT( iChangetimeout );
  528. NL; IARG( "iChangeclipping", iChangeclipping ); MI_CHANGECLIPPING( iChangeclipping );
  529. NL; IARG( "iChangesyncid", iChangesyncid ); MI_CHANGESYNCID( iChangesyncid );
  530. NL; IARG( "iDelay", iDelay );
  531. NL; IARG( "iTimeout", iTimeout );
  532. NL; IARG( "iBoundarytype", iBoundarytype ); MI_BOUNDARY( iBoundarytype );
  533. NL; IARG( "iBoundaryl", iBoundaryl );
  534. NL; IARG( "iBoundaryr", iBoundaryr );
  535. NL; IARG( "iBoundaryt", iBoundaryt );
  536. NL; IARG( "iBoundaryb", iBoundaryb );
  537. NL; IARG( "iCount", iCount );
  538. //pSyncids pSyncids @todo@
  539. return true;
  540. # undef MI_BOUNDARY
  541. # undef MI_FRAMINGMODE
  542. # undef MI_CHANGEDELAY
  543. # undef MI_CHANGETIMOUT
  544. # undef MI_CHANGECLIPPING
  545. # undef MI_CHANGESYNCID
  546. }
  547. //---------------------------------------------------------------------------
  548. bool __fastcall TMainForm::Info_IDAT( mng_handle hMNG, mng_handle hChunk, String &as )
  549. {
  550. mng_uint32 iRawlen;
  551. mng_ptr pRawdata;
  552. if( mng_getchunk_idat( hMNG, hChunk, &iRawlen, &pRawdata ) != 0 )
  553. return false;
  554. IARG( "iRawlen", iRawlen );
  555. if( WantsRawData() ) {
  556. Byte *bp = (Byte*)pRawdata;
  557. NL; STR( TAB + "Rawdata : " );
  558. // show the first 16 bytes, as hex
  559. for( int n = 0; n < 16; n +=1 )
  560. HEXSTR( (int)bp[n] ) + " ";
  561. }
  562. return true;
  563. }
  564. //---------------------------------------------------------------------------
  565. bool __fastcall TMainForm::Info_IEND( mng_handle hMNG, mng_handle hChunk, String &as )
  566. {
  567. NL + TAB; STR( "End of Image." );
  568. return true;
  569. }
  570. //---------------------------------------------------------------------------
  571. bool __fastcall TMainForm::Info_IHDR(
  572. mng_handle hMNG, mng_handle hChunk, String &as )
  573. {
  574. mng_uint32 iWidth;
  575. mng_uint32 iHeight;
  576. mng_uint8 iBitdepth;
  577. mng_uint8 iColortype;
  578. mng_uint8 iCompression;
  579. mng_uint8 iFilter;
  580. mng_uint8 iInterlace;
  581. if( mng_getchunk_ihdr( hMNG, hChunk, &iWidth, &iHeight, &iBitdepth,
  582. &iColortype, &iCompression, &iFilter, &iInterlace ) != 0 )
  583. return false;
  584. IARG( "iWidth", iWidth );
  585. NL; IARG( "iHeight", iHeight );
  586. NL; IARG( "iBitdepth", iBitdepth ); MI_BITDEPTH( iBitdepth );
  587. NL; IARG( "iColortype", iColortype ); MI_COLORTYPE( iColortype );
  588. NL; IARG( "iCompression", iCompression ); MI_COMPRESSION_DEFLATE( iCompression );
  589. NL; IARG( "iFilter", iFilter ); MI_FILTER( iFilter );
  590. NL; IARG( "iInterlace", iInterlace ); MI_INTERLACE( iInterlace );
  591. if( WantsComments() )
  592. {
  593. NL; NL + TAB;
  594. switch( iColortype ) {
  595. case MNG_COLORTYPE_GRAY :
  596. switch( iBitdepth ) {
  597. case 1 : case 2 : case 4 : case 8 : case 16 :
  598. STR( "Each pixel value is a greyscale level -" );
  599. } // inner switch
  600. break;
  601. case MNG_COLORTYPE_RGB :
  602. switch( iBitdepth ) {
  603. case 8 : case 16 :
  604. STR( "Each pixel value is an R,G,B series -" );
  605. } // inner switch
  606. break;
  607. case MNG_COLORTYPE_INDEXED :
  608. switch( iBitdepth ) {
  609. case 1 : case 2 : case 4 : case 8 :
  610. STR( "Each pixel value is a palette index -" );
  611. } // inner switch
  612. break;
  613. case MNG_COLORTYPE_GRAYA :
  614. switch( iBitdepth ) {
  615. case 8 : case 16 :
  616. STR( "Each pixel value is a greyscale level, "\
  617. "followed by an Alpha channel level -" );
  618. } // inner switch
  619. break;
  620. case MNG_COLORTYPE_RGBA :
  621. switch( iBitdepth ){
  622. case 8 : case 16:
  623. STR( "Each pixel value is an R,G,B "\
  624. "series, followed by an Alpha channel level -" );
  625. } // inner switch
  626. break;
  627. }
  628. STR( " " + String(iBitdepth) + " bits per pixel." );
  629. }
  630. return true;
  631. }
  632. //---------------------------------------------------------------------------
  633. bool __fastcall TMainForm::Info_JDAT( mng_handle hMNG, mng_handle hChunk, String &as )
  634. {
  635. mng_uint32 iRawlen;
  636. mng_ptr pRawdata = NULL;
  637. if( mng_getchunk_jdat( hMNG, hChunk, &iRawlen, &pRawdata ) != 0 )
  638. return false;
  639. IARG( "iRawlen", iRawlen );
  640. if( WantsRawData() ) {
  641. Byte *bp = (Byte*)pRawdata;
  642. NL; STR( TAB + "Rawdata : " );
  643. // show the first 16 bytes, as hex
  644. for( int n = 0; n < 16; n +=1 )
  645. HEXSTR( (int)bp[n] ) + " ";
  646. }
  647. return true;
  648. }
  649. //---------------------------------------------------------------------------
  650. bool __fastcall TMainForm::Info_JHDR( mng_handle hMNG, mng_handle hChunk, String &as )
  651. {
  652. # define MI_JPEG_COLORTYPE( _i_ )\
  653. if( WantsMacroIds() ) {\
  654. switch( _i_ ){\
  655. case MNG_COLORTYPE_JPEGGRAY : MI( "MNG_COLORTYPE_JPEGGRAY");break;\
  656. case MNG_COLORTYPE_JPEGCOLOR : MI( "MNG_COLORTYPE_JPEGCOLOR");break;\
  657. case MNG_COLORTYPE_JPEGGRAYA : MI( "MNG_COLORTYPE_JPEGGRAYA");break;\
  658. case MNG_COLORTYPE_JPEGCOLORA : MI( "MNG_COLORTYPE_JPEGCOLORA");break;\
  659. default : MI(UNKNOWN);\
  660. }\
  661. }
  662. # define MI_JPEG_BITDEPTH( _i_ )\
  663. if( WantsMacroIds() ) {\
  664. switch( _i_ ){\
  665. case MNG_BITDEPTH_JPEG8 : MI("MNG_BITDEPTH_JPEG8");break;\
  666. case MNG_BITDEPTH_JPEG12 : MI("MNG_BITDEPTH_JPEG12");break;\
  667. case MNG_BITDEPTH_JPEG8AND12 : MI("MNG_BITDEPTH_JPEG8AND12");break;\
  668. default : MI(UNKNOWN);\
  669. }\
  670. }
  671. # define MI_JPEGCOMPRESSION( _i_ )\
  672. if( WantsMacroIds() ) {\
  673. if( iImagecompression == MNG_COMPRESSION_BASELINEJPEG ) {\
  674. MI( "MNG_COMPRESSION_BASELINEJPEG" );\
  675. } else { MI(ILLEGAL_VALUE); };\
  676. }
  677. # define MI_JPEGINTERLACE( _i_ )\
  678. if( WantsMacroIds() ) {\
  679. if( iImageinterlace == MNG_INTERLACE_SEQUENTIAL ) {\
  680. MI( "MNG_INTERLACE_SEQUENTIAL");\
  681. } else {\
  682. MI( "MNG_INTERLACE_PROGRESSIVE" );\
  683. }\
  684. }
  685. // NB alpha bitdepth is not png bitdepth because it can be 0 (zero)
  686. # define MI_ALPHABITDEPTH( _i_ )\
  687. if( WantsMacroIds() )\
  688. switch( (_i_) ) {\
  689. case MNG_BITDEPTH_1 : MI( "MNG_BITDEPTH_1" ); break;\
  690. case MNG_BITDEPTH_2 : MI( "MNG_BITDEPTH_2" ); break;\
  691. case MNG_BITDEPTH_4 : MI( "MNG_BITDEPTH_4" ); break;\
  692. case MNG_BITDEPTH_8 : MI( "MNG_BITDEPTH_8" ); break;\
  693. case MNG_BITDEPTH_16 : MI( "MNG_BITDEPTH_16" ); break;\
  694. case 0 : break;\
  695. default : MI(ILLEGAL_VALUE);\
  696. }
  697. mng_uint32 iWidth;
  698. mng_uint32 iHeight;
  699. mng_uint8 iColortype;
  700. mng_uint8 iImagesampledepth;
  701. mng_uint8 iImagecompression;
  702. mng_uint8 iImageinterlace;
  703. mng_uint8 iAlphasampledepth;
  704. mng_uint8 iAlphacompression;
  705. mng_uint8 iAlphafilter;
  706. mng_uint8 iAlphainterlace;
  707. if( mng_getchunk_jhdr( hMNG, hChunk,
  708. &iWidth, &iHeight, &iColortype, &iImagesampledepth,
  709. &iImagecompression, &iImageinterlace,
  710. &iAlphasampledepth, &iAlphacompression,
  711. &iAlphafilter, &iAlphainterlace ) != 0 )
  712. return false;
  713. IARG( "iWidth", iWidth );
  714. NL; IARG( "iHeight", iHeight );
  715. NL; IARG( "iColortype", iColortype ); MI_JPEG_COLORTYPE( iColortype );
  716. NL; IARG( "iImagesampledepth", iImagesampledepth ); MI_JPEG_BITDEPTH( iImagesampledepth );
  717. NL; IARG( "iImagecompression", iImagecompression ); MI_JPEGCOMPRESSION( iImagecompression );
  718. NL; IARG( "iImageinterlace", iImageinterlace ); MI_JPEGINTERLACE( iImageinterlace );
  719. NL; IARG( "iAlphasampledepth", iAlphasampledepth ); MI_ALPHABITDEPTH( iAlphasampledepth );
  720. NL; IARG( "iAlphacompression", iAlphacompression ); MI_COMPRESSION_DEFLATE( iAlphacompression );
  721. NL; IARG( "iAlphafilter", iAlphafilter ); MI_FILTER( iAlphafilter );
  722. NL; IARG( "iAlphainterlace", iAlphainterlace ); MI_INTERLACE( iAlphainterlace );
  723. return true;
  724. # undef MI_JPEG_COLORTYPE
  725. # undef MI_JPEG_BITDEPTH
  726. # undef MI_JPEGCOMPRESSION
  727. # undef MI_JPEGINTERLACE
  728. # undef MI_ALPHABITDEPTH
  729. }
  730. //---------------------------------------------------------------------------
  731. bool __fastcall TMainForm::Info_LOOP( mng_handle hMNG, mng_handle hChunk, String &as )
  732. {
  733. # define MI_TERMINATION( _i_ )\
  734. if( WantsMacroIds() )\
  735. switch( (_i_) ) {\
  736. case MNG_TERMINATION_DECODER_NC :\
  737. MI( "MNG_TERMINATION_DECODER_NC" ); break;\
  738. case MNG_TERMINATION_USER_NC :\
  739. MI( "MNG_TERMINATION_USER_NC" ); break;\
  740. case MNG_TERMINATION_EXTERNAL_NC :\
  741. MI( "MNG_TERMINATION_EXTERNAL_NC" ); break;\
  742. case MNG_TERMINATION_DETERMINISTIC_NC :\
  743. MI( "MNG_TERMINATION_DETERMINISTIC_NC" ); break;\
  744. case MNG_TERMINATION_DECODER_C :\
  745. MI( "MNG_TERMINATION_DECODER_C" ); break;\
  746. case MNG_TERMINATION_USER_C :\
  747. MI( "MNG_TERMINATION_USER_C" ); break;\
  748. case MNG_TERMINATION_EXTERNAL_C :\
  749. MI( "MNG_TERMINATION_EXTERNAL_C" ); break;\
  750. case MNG_TERMINATION_DETERMINISTIC_C :\
  751. MI( "MNG_TERMINATION_DETERMINISTIC_C" ); break;\
  752. default : MI(UNKNOWN);\
  753. }
  754. mng_uint8 iLevel;
  755. mng_uint32 iRepeat;
  756. mng_uint8 iTermination;
  757. mng_uint32 iItermin;
  758. mng_uint32 iItermax;
  759. mng_uint32 iCount;
  760. mng_uint32p pSignals;
  761. if( mng_getchunk_loop( hMNG, hChunk,
  762. &iLevel, &iRepeat, &iTermination,
  763. &iItermin, &iItermax, &iCount, &pSignals ) != 0 )
  764. return false;
  765. IARG( "iLevel", iLevel );
  766. NL; IARG( "iRepeat", iRepeat );
  767. NL; IARG( "iTermination", iTermination ); MI_TERMINATION( iTermination );
  768. NL; IARG( "iItermin", iItermin );
  769. NL; IARG( "iItermax", iItermax );
  770. NL; IARG( "iCount", iCount );
  771. //pSignals pSignals //@todo@
  772. return true;
  773. # undef MI_TERMINATION
  774. }
  775. //---------------------------------------------------------------------------
  776. /*
  777. bool __fastcall TMainForm::Info_M?GN( mng_handle hMNG, mng_handle hChunk, String &as )
  778. {
  779. mng_uint16 iFirstid;
  780. mng_uint16 iLastid;
  781. mng_uint16 iMethodX;
  782. mng_uint16 iMX;
  783. mng_uint16 iMY;
  784. mng_uint16 iML;
  785. mng_uint16 iMR;
  786. mng_uint16 iMT;
  787. mng_uint16 iMB;
  788. mng_uint16 iMethodY;
  789. if( mng_getchunk_magn( hMNG, hChunk,
  790. &iFirstid, &iLastid,
  791. &iMethodX, &iMX, &iMY, &iML, &iMR, &iMT, &iMB,
  792. &iMethodY ) != 0 )
  793. return false;
  794. IARG( "iFirstid", iFirstid );
  795. NL; IARG( "iLastid", iLastid );
  796. NL; IARG( "iMethodX", iMethodX );
  797. NL; IARG( "iMX", iMX );
  798. NL; IARG( "iMY", iMY );
  799. NL; IARG( "iML", iML );
  800. NL; IARG( "iMR", iMR );
  801. NL; IARG( "iMT", iMT );
  802. NL; IARG( "iMB", iMB );
  803. NL; IARG( "iMethodY", iMethodY );
  804. return true;
  805. }
  806. */
  807. //---------------------------------------------------------------------------
  808. bool __fastcall TMainForm::Info_MEND( mng_handle hMNG, mng_handle hChunk, String &as )
  809. {
  810. NL + TAB; STR( "End of Multiply Network Graphic." );
  811. return true;
  812. }
  813. //---------------------------------------------------------------------------
  814. bool __fastcall TMainForm::Info_MHDR( mng_handle hMNG, mng_handle hChunk, String &as )
  815. {
  816. // NB "iSimplicity" is a bit field
  817. # define MI_SIMPLICITY( _i_ )\
  818. if( WantsMacroIds() ) {\
  819. if( (_i_) & MNG_SIMPLICITY_VALID )\
  820. MI( "MNG_SIMPLICITY_VALID" );\
  821. if( (_i_) & MNG_SIMPLICITY_SIMPLEFEATURES )\
  822. MI( "MNG_SIMPLICITY_SIMPLEFEATURES" );\
  823. if( (_i_) & MNG_SIMPLICITY_COMPLEXFEATURES )\
  824. MI( "MNG_SIMPLICITY_COMPLEXFEATURES" );\
  825. if( (_i_) & MNG_SIMPLICITY_TRANSPARENCY )\
  826. MI( "MNG_SIMPLICITY_TRANSPARENCY" );\
  827. if( (_i_) & MNG_SIMPLICITY_JNG )\
  828. MI( "MNG_SIMPLICITY_JNG" );\
  829. if( (_i_) & MNG_SIMPLICITY_DELTAPNG )\
  830. MI( "MNG_SIMPLICITY_DELTAPNG" );\
  831. }
  832. mng_uint32 iWidth;
  833. mng_uint32 iHeight;
  834. mng_uint32 iTicks;
  835. mng_uint32 iLayercount;
  836. mng_uint32 iFramecount;
  837. mng_uint32 iPlaytime;
  838. mng_uint32 iSimplicity;
  839. if( mng_getchunk_mhdr( hMNG, hChunk,
  840. &iWidth, &iHeight, &iTicks,
  841. &iLayercount, &iFramecount, &iPlaytime,
  842. &iSimplicity ) != 0 )
  843. return false;
  844. IARG( "iWidth", iWidth );
  845. NL; IARG( "iHeight", iHeight );
  846. NL; IARG( "iTicks", iTicks );
  847. NL; IARG( "iLayercount", iLayercount );
  848. NL; IARG( "iFramecount", iFramecount );
  849. NL; IARG( "iPlaytime", iPlaytime );
  850. NL; IARG( "iSimplicity", iSimplicity ); MI_SIMPLICITY( iSimplicity );
  851. return true;
  852. # undef MI_SIMPLICITY
  853. }
  854. //---------------------------------------------------------------------------
  855. bool __fastcall TMainForm::Info_MOVE( mng_handle hMNG, mng_handle hChunk, String &as )
  856. {
  857. mng_uint16 iFirstid;
  858. mng_uint16 iLastid;
  859. mng_uint8 iMovetype;
  860. mng_int32 iMovex;
  861. mng_int32 iMovey;
  862. if( mng_getchunk_move( hMNG, hChunk,
  863. &iFirstid, &iLastid, &iMovetype, &iMovex, &iMovey ) != 0 )
  864. return false;
  865. IARG( "iFirstid", iFirstid );
  866. NL; IARG( "iLastid", iLastid );
  867. NL; IARG( "iMovetype", iMovetype ); MI_LOCATION( iMovetype );
  868. NL; IARG( "iMovex", iMovex );
  869. NL; IARG( "iMovey", iMovey );
  870. return true;
  871. }
  872. //---------------------------------------------------------------------------
  873. bool __fastcall TMainForm::Info_ORDR( mng_handle hMNG, mng_handle hChunk, String &as )
  874. {
  875. mng_uint32 iCount;
  876. if( mng_getchunk_ordr( hMNG, hChunk, &iCount ) != 0 )
  877. return false;
  878. IARG( "iCount", iCount );
  879. return true;
  880. }
  881. //---------------------------------------------------------------------------
  882. bool __fastcall TMainForm::Info_PAST( mng_handle hMNG, mng_handle hChunk, String &as )
  883. {
  884. // PAST
  885. # define MI_TARGET( _i_ )\
  886. if( WantsMacroIds() )\
  887. switch( _i_ ) {\
  888. case MNG_TARGET_ABSOLUTE : MI( "MNG_TARGET_ABSOLUTE" ); break;\
  889. case MNG_TARGET_RELATIVE_SAMEPAST : MI( "MNG_TARGET_RELATIVE_SAMEPAST" ); break;\
  890. case MNG_TARGET_RELATIVE_PREVPAST : MI( "MNG_TARGET_RELATIVE_PREVPAST" ); break;\
  891. default : MI(UNKNOWN);\
  892. }
  893. // COMPOSITE, ORIENTATION, OFFSET & BOUNDARY depend upon "iCount"
  894. mng_uint16 iDestid;
  895. mng_uint8 iTargettype;
  896. mng_int32 iTargetx;
  897. mng_int32 iTargety;
  898. mng_uint32 iCount;
  899. if( mng_getchunk_past( hMNG, hChunk,
  900. &iDestid, &iTargettype, &iTargetx, &iTargety, &iCount ) != 0 )
  901. return false;
  902. IARG( "iDestid", iDestid );
  903. NL; IARG( "iTargettype", iTargettype ); MI_TARGET( iTargettype );
  904. NL; IARG( "iTargetx", iTargetx );
  905. NL; IARG( "iTargety", iTargety );
  906. NL; IARG( "iCount", iCount );
  907. return true;
  908. # undef MI_TARGET
  909. }
  910. //---------------------------------------------------------------------------
  911. bool __fastcall TMainForm::Info_PLTE( mng_handle hMNG, mng_handle hChunk, String &as )
  912. {
  913. mng_uint32 iCount;
  914. mng_palette8 aPalette;
  915. mng_uint32 iPalEntry;
  916. if( mng_getchunk_plte( hMNG, hChunk, &iCount, &aPalette ) != 0 )
  917. return false;
  918. IARG( "iCount", iCount );
  919. if( WantsPaletteEntries() )
  920. {
  921. iPalEntry = 0;
  922. do{
  923. if( WantsRgbOrder() )
  924. {
  925. as = as + nl +
  926. TAB + "Palette entry [" + PadInt( iPalEntry ) + "]" +
  927. TAB + "R(" + PadInt( aPalette[ iPalEntry ].iRed ) + ") " +
  928. TAB + "G(" + PadInt( aPalette[ iPalEntry ].iGreen ) + ") " +
  929. TAB + "B(" + PadInt( aPalette[ iPalEntry ].iBlue ) + ")";
  930. }
  931. else
  932. {
  933. as = as + nl +
  934. TAB + "Palette entry [" + PadInt( iPalEntry ) + "]" +
  935. TAB + "B(" + PadInt( aPalette[ iPalEntry ].iBlue ) + ") " +
  936. TAB + "G(" + PadInt( aPalette[ iPalEntry ].iGreen ) + ") " +
  937. TAB + "R(" + PadInt( aPalette[ iPalEntry ].iRed ) + ")";
  938. };
  939. iPalEntry += 1;
  940. } while( iPalEntry < iCount );
  941. }
  942. return true;
  943. }
  944. //---------------------------------------------------------------------------
  945. bool __fastcall TMainForm::Info_PPLT( mng_handle hMNG, mng_handle hChunk, String &as )
  946. {
  947. /*
  948. # define MI_DELTATYPE( _i_ )\
  949. if( WantsMacroIds() )\
  950. switch( _i_ ) {\
  951. case MNG_DELTATYPE_REPLACERGB : MI( "MNG_DELTATYPE_REPLACERGB" ); break;\
  952. case MNG_DELTATYPE_DELTARGB : MI( "MNG_DELTATYPE_DELTARGB" ); break;\
  953. case MNG_DELTATYPE_REPLACEALPHA : MI( "MNG_DELTATYPE_REPLACEALPHA" ); break;\
  954. case MNG_DELTATYPE_DELTAALPHA : MI( "MNG_DELTATYPE_DELTAALPHA" ); break;\
  955. case MNG_DELTATYPE_REPLACERGBA : MI( "MNG_DELTATYPE_REPLACERGBA" ); break;\
  956. case MNG_DELTATYPE_DELTARGBA : MI( "MNG_DELTATYPE_DELTARGBA" ); break;\
  957. default : MI(UNKNOWN);\
  958. }
  959. */
  960. mng_uint32 iCount;
  961. if( mng_getchunk_pplt( hMNG, hChunk, &iCount ) != 0 )
  962. return false;
  963. IARG( "iCount", iCount );
  964. return true;
  965. }
  966. //---------------------------------------------------------------------------
  967. bool __fastcall TMainForm::Info_PROM( mng_handle hMNG, mng_handle hChunk, String &as )
  968. {
  969. # define MI_FILLMETHOD( _i_ )\
  970. if( WantsMacroIds() )\
  971. switch( _i_ ) {\
  972. case MNG_FILLMETHOD_LEFTBITREPLICATE : MI( "MNG_FILLMETHOD_LEFTBITREPLICATE" ); break;\
  973. case MNG_FILLMETHOD_ZEROFILL : MI( "MNG_FILLMETHOD_ZEROFILL" ); break;\
  974. default : MI(UNKNOWN);\
  975. }
  976. mng_uint8 iColortype;
  977. mng_uint8 iSampledepth;
  978. mng_uint8 iFilltype;
  979. if( mng_getchunk_prom( hMNG, hChunk,
  980. &iColortype, &iSampledepth, &iFilltype ) != 0 )
  981. return false;
  982. IARG( "iColortype", iColortype ); MI_COLORTYPE( iColortype );
  983. NL; IARG( "iSampledepth", iSampledepth ); MI_BITDEPTH( iSampledepth );
  984. NL; IARG( "iFilltype", iFilltype ); MI_FILLMETHOD( iFilltype );
  985. return true;
  986. # undef MI_FILLMETHOD
  987. }
  988. //---------------------------------------------------------------------------
  989. bool __fastcall TMainForm::Info_SAVE( mng_handle hMNG, mng_handle hChunk, String &as )
  990. {
  991. # define MI_SAVEOFFSET( _i_ )\
  992. if( WantsMacroIds() )\
  993. switch( _i_ ) {\
  994. case MNG_SAVEOFFSET_4BYTE : MI( "MNG_SAVEOFFSET_4BYTE" ); break;\
  995. case MNG_SAVEOFFSET_8BYTE : MI( "MNG_SAVEOFFSET_8BYTE" ); break;\
  996. default : MI(UNKNOWN);\
  997. }
  998. /*
  999. # define MI_SAVEENTRY( _i_ )\
  1000. if( WantsMacroIds() )\
  1001. switch( _i_ ) {\
  1002. case MNG_SAVEENTRY_SEGMENTFULL : MI( "MNG_SAVEENTRY_SEGMENTFULL" ); break;\
  1003. case MNG_SAVEENTRY_SEGMENT : MI( "MNG_SAVEENTRY_SEGMENT" ); break;\
  1004. case MNG_SAVEENTRY_SUBFRAME : MI( "MNG_SAVEENTRY_SUBFRAME" ); break;\
  1005. case MNG_SAVEENTRY_EXPORTEDIMAGE : MI( "MNG_SAVEENTRY_EXPORTEDIMAGE" ); break;\
  1006. default : MI(UNKNOWN);\
  1007. }
  1008. */
  1009. mng_bool bEmpty;
  1010. mng_uint8 iOffsettype;
  1011. mng_uint32 iCount;
  1012. if( mng_getchunk_save( hMNG, hChunk,
  1013. &bEmpty, &iOffsettype, &iCount ) != 0 )
  1014. return false;
  1015. BARG( "bEmpty", bEmpty );
  1016. NL; IARG( "iOffsettype", iOffsettype ); MI_SAVEOFFSET( iOffsettype );
  1017. NL; IARG( "iCount", iCount );
  1018. return true;
  1019. # undef MI_SAVEOFFSET
  1020. }
  1021. //---------------------------------------------------------------------------
  1022. bool __fastcall TMainForm::Info_SEEK( mng_handle hMNG, mng_handle hChunk, String &as )
  1023. {
  1024. mng_uint32 iNamesize;
  1025. mng_pchar zName;
  1026. if( mng_getchunk_seek( hMNG, hChunk, &iNamesize, &zName ) != 0 )
  1027. return false;
  1028. IARG( "iNamesize", iNamesize );
  1029. NL; ZARG( "zName", zName );
  1030. return true;
  1031. }
  1032. //---------------------------------------------------------------------------
  1033. bool __fastcall TMainForm::Info_SHOW( mng_handle hMNG, mng_handle hChunk, String &as )
  1034. {
  1035. # define MI_SHOWMODE( _i_ )\
  1036. if( WantsMacroIds() )\
  1037. switch( _i_ ) {\
  1038. case MNG_SHOWMODE_0 : MI( "MNG_SHOWMODE_0" ); break;\
  1039. case MNG_SHOWMODE_1 : MI( "MNG_SHOWMODE_1" ); break;\
  1040. case MNG_SHOWMODE_2 : MI( "MNG_SHOWMODE_2" ); break;\
  1041. case MNG_SHOWMODE_3 : MI( "MNG_SHOWMODE_3" ); break;\
  1042. case MNG_SHOWMODE_4 : MI( "MNG_SHOWMODE_4" ); break;\
  1043. case MNG_SHOWMODE_5 : MI( "MNG_SHOWMODE_5" ); break;\
  1044. case MNG_SHOWMODE_6 : MI( "MNG_SHOWMODE_6" ); break;\
  1045. case MNG_SHOWMODE_7 : MI( "MNG_SHOWMODE_7" ); break;\
  1046. default : MI(UNKNOWN);\
  1047. }
  1048. mng_bool bEmpty;
  1049. mng_uint16 iFirstid;
  1050. mng_uint16 iLastid;
  1051. mng_uint8 iMode;
  1052. if( mng_getchunk_show( hMNG, hChunk,
  1053. &bEmpty, &iFirstid, &iLastid, &iMode ) != 0 )
  1054. return false;
  1055. BARG( "bEmpty", bEmpty );
  1056. NL; IARG( "iFirstid", iFirstid );
  1057. NL; IARG( "iLastid", iLastid );
  1058. NL; IARG( "iMode", iMode ); MI_SHOWMODE( iMode );
  1059. return true;
  1060. # undef MI_SHOWMODE
  1061. }
  1062. //---------------------------------------------------------------------------
  1063. bool __fastcall TMainForm::Info_TERM( mng_handle hMNG, mng_handle hChunk, String &as )
  1064. {
  1065. # define MI_TERMACTION( _i_ )\
  1066. if( WantsMacroIds() )\
  1067. switch( _i_ ) {\
  1068. case MNG_TERMACTION_LASTFRAME : MI( "MNG_TERMACTION_LASTFRAME" ); break;\
  1069. case MNG_TERMACTION_CLEAR : MI( "MNG_TERMACTION_CLEAR" ); break;\
  1070. case MNG_TERMACTION_FIRSTFRAME : MI( "MNG_TERMACTION_FIRSTFRAME" ); break;\
  1071. case MNG_TERMACTION_REPEAT : MI( "MNG_TERMACTION_REPEAT" ); break;\
  1072. default : MI(UNKNOWN);\
  1073. }
  1074. # define MI_ITERACTION( _i_ )\
  1075. if( WantsMacroIds() )\
  1076. switch( _i_ ) {\
  1077. case MNG_ITERACTION_LASTFRAME : MI( "MNG_ITERACTION_LASTFRAME" ); break;\
  1078. case MNG_ITERACTION_CLEAR : MI( "MNG_ITERACTION_CLEAR" ); break;\
  1079. case MNG_ITERACTION_FIRSTFRAME : MI( "MNG_ITERACTION_FIRSTFRAME" ); break;\
  1080. default : MI(UNKNOWN);\
  1081. }
  1082. mng_uint8 iTermaction;
  1083. mng_uint8 iIteraction;
  1084. mng_uint32 iDelay;
  1085. mng_uint32 iItermax;
  1086. if( mng_getchunk_term( hMNG, hChunk,
  1087. &iTermaction, &iIteraction, &iDelay, &iItermax ) != 0 )
  1088. return false;
  1089. IARG( "iTermaction", iTermaction ); MI_TERMACTION( iTermaction );
  1090. NL; IARG( "iIteraction", iIteraction ); MI_ITERACTION( iIteraction );
  1091. NL; IARG( "iDelay", iDelay );
  1092. NL; IARG( "iItermax", iItermax );
  1093. return true;
  1094. # undef MI_TERMACTION
  1095. # undef MI_ITERACTION
  1096. }
  1097. //---------------------------------------------------------------------------
  1098. bool __fastcall TMainForm::Info_bKGD( mng_handle hMNG, mng_handle hChunk, String &as )
  1099. {
  1100. mng_bool bEmpty;
  1101. mng_uint8 iType;
  1102. mng_uint8 iIndex;
  1103. mng_uint16 iGray;
  1104. mng_uint16 iRed;
  1105. mng_uint16 iGreen;
  1106. mng_uint16 iBlue;
  1107. if( mng_getchunk_bkgd( hMNG, hChunk,
  1108. &bEmpty, &iType, &iIndex, &iGray,
  1109. &iRed, &iGreen, &iBlue ) != 0 )
  1110. return false;
  1111. BARG( "bEmpty", bEmpty );
  1112. NL; IARG( "iType", iType );
  1113. NL; IARG( "iIndex", iIndex );
  1114. NL; IARG( "iGray", iGray );
  1115. NL; IARG( "iRed", iRed );
  1116. NL; IARG( "iGreen", iGreen );
  1117. NL; IARG( "iBlue", iBlue );
  1118. return true;
  1119. }
  1120. //---------------------------------------------------------------------------
  1121. bool __fastcall TMainForm::Info_cHRM( mng_handle hMNG, mng_handle hChunk, String &as )
  1122. {
  1123. mng_bool bEmpty;
  1124. mng_uint32 iWhitepointx;
  1125. mng_uint32 iWhitepointy;
  1126. mng_uint32 iRedx;
  1127. mng_uint32 iRedy;
  1128. mng_uint32 iGreenx;
  1129. mng_uint32 iGreeny;
  1130. mng_uint32 iBluex;
  1131. mng_uint32 iBluey;
  1132. if( mng_getchunk_chrm( hMNG, hChunk,
  1133. &bEmpty, &iWhitepointx, &iWhitepointy,
  1134. &iRedx, &iRedy,
  1135. &iGreenx,&iGreeny,
  1136. &iBluex, &iBluey ) != 0 )
  1137. return false;
  1138. BARG( "bEmpty", bEmpty );
  1139. NL; FARG( "iWhitepointx", iWhitepointx );
  1140. FPCOM( String( (float)(iWhitepointx /FFACTOR) ) );
  1141. NL; FARG( "iWhitepointy", iWhitepointy );
  1142. FPCOM( String( (float)(iWhitepointy /FFACTOR) ) );
  1143. NL; FARG( "iRedx", iRedx );
  1144. FPCOM( String( (float)(iRedx /FFACTOR) ) );
  1145. NL; FARG( "iRedy", iRedy );
  1146. FPCOM( String( (float)(iRedy /FFACTOR) ) );
  1147. NL; FARG( "iGreenx", iGreenx );
  1148. FPCOM( String( (float)(iGreenx /FFACTOR) ) );
  1149. NL; FARG( "iGreeny", iGreeny );
  1150. FPCOM( String( (float)(iGreeny /FFACTOR) ) );
  1151. NL; FARG( "iBluex", iBluex );
  1152. FPCOM( String( (float)(iBluex /FFACTOR) ) );
  1153. NL; FARG( "iBluey", iBluey );
  1154. FPCOM( String( (float)(iBluey /FFACTOR) ) );
  1155. return true;
  1156. }
  1157. //---------------------------------------------------------------------------
  1158. bool __fastcall TMainForm::Info_eXPI( mng_handle hMNG, mng_handle hChunk, String &as )
  1159. {
  1160. mng_uint16 iSnapshotid;
  1161. mng_uint32 iNamesize;
  1162. mng_pchar zName;
  1163. if( mng_getchunk_expi( hMNG, hChunk,
  1164. &iSnapshotid, &iNamesize, &zName ) != 0 )
  1165. return false;
  1166. IARG( "iSnapshotid", iSnapshotid );
  1167. NL; IARG( "iNamesize", iNamesize );
  1168. NL; ZARG( "zName", zName );
  1169. return true;
  1170. }
  1171. //---------------------------------------------------------------------------
  1172. bool __fastcall TMainForm::Info_fPRI( mng_handle hMNG, mng_handle hChunk, String &as )
  1173. {
  1174. # define MI_PRIORITY( _i_ )\
  1175. if( WantsMacroIds() )\
  1176. switch( _i_ ) {\
  1177. case MNG_PRIORITY_ABSOLUTE : MI( "MNG_PRIORITY_ABSOLUTE" ); break;\
  1178. case MNG_PRIORITY_RELATIVE : MI( "MNG_PRIORITY_RELATIVE" ); break;\
  1179. default : MI(UNKNOWN);\
  1180. }
  1181. mng_uint8 iDeltatype;
  1182. mng_uint8 iPriority;
  1183. if( mng_getchunk_fpri( hMNG, hChunk, &iDeltatype, &iPriority ) != 0 )
  1184. return false;
  1185. IARG( "iDeltatype", iDeltatype ); MI_PRIORITY( iDeltatype );
  1186. NL; IARG( "iPriority", iPriority );
  1187. return true;
  1188. # undef MI_PRIORITY
  1189. }
  1190. //---------------------------------------------------------------------------
  1191. bool __fastcall TMainForm::Info_gAMA( mng_handle hMNG, mng_handle hChunk, String &as )
  1192. {
  1193. mng_bool bEmpty;
  1194. mng_uint32 iGamma;
  1195. if( mng_getchunk_gama( hMNG, hChunk, &bEmpty, &iGamma ) != 0 )
  1196. return false;
  1197. BARG( "bEmpty", bEmpty );
  1198. NL; FARG( "iGamma", iGamma );
  1199. FPCOM( String( (float)(iGamma /FFACTOR) ) );
  1200. return true;
  1201. }
  1202. //---------------------------------------------------------------------------
  1203. bool __fastcall TMainForm::Info_hIST( mng_handle hMNG, mng_handle hChunk, String &as )
  1204. {
  1205. mng_uint32 iEntrycount;
  1206. mng_uint16arr aEntries;
  1207. if( mng_getchunk_hist( hMNG, hChunk, &iEntrycount, &aEntries ) != 0 )
  1208. return false;
  1209. IARG( "iEntrycount", iEntrycount );
  1210. //aEntries aEntries @todo@
  1211. return true;
  1212. }
  1213. //---------------------------------------------------------------------------
  1214. bool __fastcall TMainForm::Info_iCCP( mng_handle hMNG, mng_handle hChunk, String &as )
  1215. {
  1216. mng_bool bEmpty;
  1217. mng_uint32 iNamesize;
  1218. mng_pchar zName;
  1219. mng_uint8 iCompression;
  1220. mng_uint32 iProfilesize;
  1221. mng_ptr pProfile;
  1222. if( mng_getchunk_iccp( hMNG, hChunk,
  1223. &bEmpty, &iNamesize, &zName, &iCompression,
  1224. &iProfilesize,&pProfile ) != 0 )
  1225. return false;
  1226. BARG( "bEmpty", bEmpty );
  1227. NL; IARG( "iNamesize", iNamesize );
  1228. NL; ZARG( "Name", zName );
  1229. NL; IARG( "iCompression", iCompression ); MI_COMPRESSION_DEFLATE( iCompression );
  1230. NL; IARG( "iProfilesize", iProfilesize );
  1231. // "pProfile " + String( pProfile );
  1232. return true;
  1233. }
  1234. //---------------------------------------------------------------------------
  1235. bool __fastcall TMainForm::Info_iTXt( mng_handle hMNG, mng_handle hChunk, String &as )
  1236. {
  1237. #define MI_ITXT_FLAG( _i_ )\
  1238. if( WantsMacroIds() ) {\
  1239. if( (_i_) == MNG_FLAG_UNCOMPRESSED ) {\
  1240. MI( "MNG_FLAG_UNCOMPRESSED" )\
  1241. } else if( (_i_) == MNG_FLAG_COMPRESSED ) {\
  1242. MI( "MNG_FLAG_COMPRESSED" );\
  1243. }\
  1244. }
  1245. mng_uint32 iKeywordsize;
  1246. mng_pchar zKeyword;
  1247. mng_uint8 iCompressionflag;
  1248. mng_uint8 iCompressionmethod;
  1249. mng_uint32 iLanguagesize;
  1250. mng_pchar zLanguage;
  1251. mng_uint32 iTranslationsize;
  1252. mng_pchar zTranslation;
  1253. mng_uint32 iTextsize;
  1254. mng_pchar zText;
  1255. if( mng_getchunk_itxt( hMNG, hChunk,
  1256. &iKeywordsize, &zKeyword,
  1257. &iCompressionflag, &iCompressionmethod,
  1258. &iLanguagesize, &zLanguage,
  1259. &iTranslationsize, &zTranslation,
  1260. &iTextsize, &zText ) != 0 )
  1261. return false;
  1262. IARG( "iKeywordsize", iKeywordsize );
  1263. NL; ZARG( "zKeyword", zKeyword );
  1264. NL; IARG( "iCompressionflag", iCompressionflag ); MI_ITXT_FLAG( iCompressionflag );
  1265. NL; IARG( "iCompressionmethod", iCompressionmethod ); MI_COMPRESSION_DEFLATE( iCompressionflag );
  1266. NL; IARG( "iLanguagesize", iLanguagesize );
  1267. NL; ZARG( "zLanguage", zLanguage );
  1268. NL; IARG( "iTranslationsize", iTranslationsize );
  1269. NL; ZARG( "zTranslation", zTranslation );
  1270. NL; IARG( "iTextsize", iTextsize );
  1271. NL; ZARG( "zText", zText );
  1272. return true;
  1273. # undef MI_ITXT_FLAG
  1274. }
  1275. //---------------------------------------------------------------------------
  1276. bool __fastcall TMainForm::Info_nEED( mng_handle hMNG, mng_handle hChunk, String &as )
  1277. {
  1278. mng_uint32 iKeywordssize;
  1279. mng_pchar zKeywords;
  1280. if( mng_getchunk_need( hMNG, hChunk, &iKeywordssize, &zKeywords ) != 0)
  1281. return false;
  1282. IARG( "iKeywordssize", iKeywordssize );
  1283. NL; IARG( "zKeywords", zKeywords );
  1284. return true;
  1285. }
  1286. //---------------------------------------------------------------------------
  1287. bool __fastcall TMainForm::Info_pHYg( mng_handle hMNG, mng_handle hChunk, String &as )
  1288. {
  1289. mng_bool bEmpty;
  1290. mng_uint32 iSizex;
  1291. mng_uint32 iSizey;
  1292. mng_uint8 iUnit;
  1293. if( mng_getchunk_phyg( hMNG, hChunk,
  1294. &bEmpty, &iSizex, &iSizey, &iUnit ) != 0 )
  1295. return false;
  1296. BARG( "bEmpty", bEmpty );
  1297. NL; IARG( "iSizex", iSizex );
  1298. NL; IARG( "iSizey", iSizey );
  1299. NL; IARG( "iUnit", iUnit ); MI_UNITS( iUnit );
  1300. if( iUnit ) {
  1301. PCOM("X/Y pixels per unit" );
  1302. } else {
  1303. if( iSizex == iSizey ) {
  1304. PCOM( "Square pixels" );
  1305. }
  1306. }
  1307. return true;
  1308. }
  1309. //---------------------------------------------------------------------------
  1310. bool __fastcall TMainForm::Info_pHYs( mng_handle hMNG, mng_handle hChunk, String &as )
  1311. {
  1312. mng_bool bEmpty;
  1313. mng_uint32 iSizex;
  1314. mng_uint32 iSizey;
  1315. mng_uint8 iUnit;
  1316. if( mng_getchunk_phys( hMNG, hChunk,
  1317. &bEmpty, &iSizex, &iSizey, &iUnit ) != 0 )
  1318. return false;
  1319. BARG( "bEmpty", bEmpty );
  1320. NL; IARG( "iSizex", iSizex );
  1321. NL; IARG( "iSizey", iSizey );
  1322. NL; IARG( "iUnit", iUnit ); MI_UNITS( iUnit );
  1323. if( iUnit ) {
  1324. PCOM("X/Y pixels per unit" );
  1325. } else {
  1326. if( iSizex == iSizey ) {
  1327. PCOM( "Square pixels" );
  1328. }
  1329. }
  1330. return true;
  1331. }
  1332. //---------------------------------------------------------------------------
  1333. bool __fastcall TMainForm::Info_sBIT( mng_handle hMNG, mng_handle hChunk, String &as )
  1334. { // tested with cs3* cs5* cs8*
  1335. mng_bool bEmpty;
  1336. mng_uint8 iType;
  1337. mng_uint8arr4 aBits;
  1338. if( mng_getchunk_sbit( hMNG, hChunk, &bEmpty, &iType, &aBits ) != 0 )
  1339. return false;
  1340. BARG( "bEmpty", bEmpty );
  1341. NL; IARG( "iType", iType );
  1342. //aBits aBits @todo@
  1343. return true;
  1344. }
  1345. //---------------------------------------------------------------------------
  1346. bool __fastcall TMainForm::Info_sPLT( mng_handle hMNG, mng_handle hChunk, String &as )
  1347. {
  1348. mng_bool bEmpty;
  1349. mng_uint32 iNamesize;
  1350. mng_pchar zName;
  1351. mng_uint8 iSampledepth;
  1352. mng_uint32 iEntrycount;
  1353. mng_ptr pEntries;
  1354. if( mng_getchunk_splt( hMNG, hChunk,
  1355. &bEmpty, &iNamesize, &zName,
  1356. &iSampledepth, &iEntrycount, &pEntries ) != 0 )
  1357. return false;
  1358. BARG( "bEmpty", bEmpty );
  1359. NL; IARG( "iNamesize", iNamesize );
  1360. NL; ZARG( "zName", zName );
  1361. NL; IARG( "iSampledepth", iSampledepth ); MI_BITDEPTH( iSampledepth );
  1362. NL; IARG( "iEntrycount", iEntrycount );
  1363. //pEntries pEntries @todo@
  1364. return true;
  1365. }
  1366. //---------------------------------------------------------------------------
  1367. bool __fastcall TMainForm::Info_sRGB( mng_handle hMNG, mng_handle hChunk, String &as )
  1368. {
  1369. # define MI_RENDERINGINTENT( _i_ )\
  1370. if( WantsMacroIds() ) {\
  1371. switch( (_i_) ) {\
  1372. case MNG_INTENT_PERCEPTUAL :\
  1373. MI( "MNG_INTENT_PERCEPTUAL" ); break;\
  1374. case MNG_INTENT_RELATIVECOLORIMETRIC :\
  1375. MI( "MNG_INTENT_RELATIVECOLORIMETRIC" );break;\
  1376. case MNG_INTENT_SATURATION :\
  1377. MI( "MNG_INTENT_SATURATION" ); break;\
  1378. case MNG_INTENT_ABSOLUTECOLORIMETRIC :\
  1379. MI( "MNG_INTENT_ABSOLUTECOLORIMETRIC" );break;\
  1380. }\
  1381. }
  1382. mng_bool bEmpty;
  1383. mng_uint8 iRenderingintent;
  1384. if( mng_getchunk_srgb( hMNG, hChunk,&bEmpty, &iRenderingintent ) != 0)
  1385. return false;
  1386. BARG( "bEmpty", bEmpty );
  1387. NL; IARG( "iRenderingintent", iRenderingintent );
  1388. MI_RENDERINGINTENT( iRenderingintent );
  1389. return true;
  1390. # undef MI_RENDERINGINTENT
  1391. }
  1392. //---------------------------------------------------------------------------
  1393. bool __fastcall TMainForm::Info_tEXt( mng_handle hMNG, mng_handle hChunk, String &as )
  1394. {
  1395. mng_uint32 iKeywordsize;
  1396. mng_pchar zKeyword;
  1397. mng_uint32 iTextsize;
  1398. mng_pchar zText;
  1399. if( mng_getchunk_text( hMNG, hChunk,
  1400. &iKeywordsize, &zKeyword, &iTextsize, &zText ) != 0 )
  1401. return false;
  1402. IARG( "iKeywordsize", iKeywordsize );
  1403. NL; ZARG( "zKeyword", zKeyword );
  1404. NL; IARG( "iTextsize", iTextsize );
  1405. NL; ZARG( "zText", zText );
  1406. return true;
  1407. }
  1408. //---------------------------------------------------------------------------
  1409. bool __fastcall TMainForm::Info_tIME( mng_handle hMNG, mng_handle hChunk, String &as )
  1410. {
  1411. mng_uint16 iYear;
  1412. mng_uint8 iMonth;
  1413. mng_uint8 iDay;
  1414. mng_uint8 iHour;
  1415. mng_uint8 iMinute;
  1416. mng_uint8 iSecond;
  1417. if( mng_getchunk_time( hMNG, hChunk,
  1418. &iYear, &iMonth, &iDay, &iHour, &iMinute, &iSecond ) != 0 )
  1419. return false;
  1420. IARG( "iYear", iYear );
  1421. NL; IARG( "iMonth", iMonth );
  1422. NL; IARG( "iDay", iDay );
  1423. NL; IARG( "iHour", iHour );
  1424. NL; IARG( "iMinute", iMinute );
  1425. NL; IARG( "iSecond", iSecond );
  1426. // Do not do help line here - may confuse international readers !
  1427. return true;
  1428. }
  1429. //---------------------------------------------------------------------------
  1430. bool __fastcall TMainForm::Info_tRNS( mng_handle hMNG, mng_handle hChunk, String &as )
  1431. {
  1432. mng_bool bEmpty;
  1433. mng_bool bGlobal;
  1434. mng_uint8 iType;
  1435. mng_uint32 iCount;
  1436. mng_uint8arr aAlphas;
  1437. mng_uint16 iGray;
  1438. mng_uint16 iRed;
  1439. mng_uint16 iGreen;
  1440. mng_uint16 iBlue;
  1441. mng_uint32 iRawlen;
  1442. mng_uint8arr aRawdata;
  1443. if( mng_getchunk_trns( hMNG, hChunk,
  1444. &bEmpty, &bGlobal, &iType, &iCount,
  1445. &aAlphas,
  1446. &iGray, &iRed, &iGreen, &iBlue,
  1447. &iRawlen,
  1448. &aRawdata ) != 0 )
  1449. return false;
  1450. BARG( "bEmpty", bEmpty );
  1451. NL; BARG( "bGlobal", bGlobal );
  1452. NL; IARG( "iType", iType );
  1453. NL; IARG( "iCount", iCount );
  1454. //aAlphas aAlphas @todo@
  1455. NL; IARG( "iGray", iGray );
  1456. NL; IARG( "iRed", iRed );
  1457. NL; IARG( "iGreen", iGreen );
  1458. NL; IARG( "iBlue", iBlue );
  1459. NL; IARG( "iRawlen", iRawlen );
  1460. //aRawdata aRawdata @todo@
  1461. return true;
  1462. }
  1463. //---------------------------------------------------------------------------
  1464. bool __fastcall TMainForm::Info_zTXt( mng_handle hMNG, mng_handle hChunk, String &as )
  1465. {
  1466. mng_uint32 iKeywordsize;
  1467. mng_pchar zKeyword;
  1468. mng_uint8 iCompression;
  1469. mng_uint32 iTextsize;
  1470. mng_pchar zText;
  1471. if( mng_getchunk_ztxt( hMNG, hChunk,
  1472. &iKeywordsize, &zKeyword, &iCompression, &iTextsize, &zText ) != 0 )
  1473. return false;
  1474. IARG( "iKeywordsize", iKeywordsize );
  1475. NL; ZARG( "zKeyword", zKeyword );
  1476. NL; IARG( "iCompression", iCompression ); MI_COMPRESSION_DEFLATE( iCompression );
  1477. NL; IARG( "iTextsize", iTextsize );
  1478. NL; ZARG( "zText", zText );
  1479. return true;
  1480. }
  1481. //---------------------------------------------------------------------------
  1482. bool __fastcall TMainForm::Info_Unknown( mng_handle hMNG, mng_handle hChunk, String &as )
  1483. {
  1484. NL + TAB; STR( "Unknown Chunk" );
  1485. NL + TAB; STR( nl + TAB + "(See help tab for a list of unsupported chunks)!" );
  1486. return true;
  1487. }
  1488. //---------------------------------------------------------------------------