Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.72 KB | None | 0 0
  1. procedure TForm1.N16bitBGR1Click( Sender: TObject );
  2. var
  3. wicImg: TWICImage;
  4. wicBitmap: IWICBitmap;
  5. iBmpSource: IWICBitmapSource;
  6. puiWidth, puiHeight: UINT;
  7. iConverter: IWICFormatConverter;
  8. begin
  9. if cxImage1.Picture.Graphic is TWICImage then
  10. begin
  11. Screen.Cursor := crHourGlass;
  12. try
  13. wicImg := TWICImage( cxImage1.Picture.Graphic );
  14. wicImg.ImagingFactory.CreateFormatConverter( iConverter );
  15. iBmpSource := wicImg.Handle as IWICBitmapSource;
  16. iBmpSource.GetSize( puiWidth, puiHeight );
  17. iConverter.Initialize( iBmpSource, GUID_WICPixelFormat16bppBGR555, WICBitmapDitherTypeNone, nil, 0,
  18. WICBitmapPaletteTypeMedianCut );
  19. wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
  20. if Assigned( wicBitmap ) then
  21. wicImg.Handle := wicBitmap;
  22. cxImage1.Repaint;
  23. cxImage1.Update;
  24. cxImage1.Invalidate;
  25. dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
  26. dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
  27. dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
  28. dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
  29. dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
  30. finally
  31. Screen.Cursor := crDefault;
  32. end;
  33. end;
  34. end;
  35.  
  36. procedure TForm1.N16bitGray1Click( Sender: TObject );
  37. var
  38. wicImg: TWICImage;
  39. wicBitmap: IWICBitmap;
  40. iBmpSource: IWICBitmapSource;
  41. puiWidth, puiHeight: UINT;
  42. iConverter: IWICFormatConverter;
  43. begin
  44. if cxImage1.Picture.Graphic is TWICImage then
  45. begin
  46. Screen.Cursor := crHourGlass;
  47. try
  48. wicImg := TWICImage( cxImage1.Picture.Graphic );
  49. wicImg.ImagingFactory.CreateFormatConverter( iConverter );
  50. iBmpSource := wicImg.Handle as IWICBitmapSource;
  51. iBmpSource.GetSize( puiWidth, puiHeight );
  52. iConverter.Initialize( iBmpSource, GUID_WICPixelFormat16bppGray, WICBitmapDitherTypeSolid, nil, 0,
  53. WICBitmapPaletteTypeFixedGray16 );
  54. wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
  55. if Assigned( wicBitmap ) then
  56. wicImg.Handle := wicBitmap;
  57. cxImage1.Repaint;
  58. cxImage1.Update;
  59. cxImage1.Invalidate;
  60. dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
  61. dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
  62. dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
  63. dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
  64. dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
  65. finally
  66. Screen.Cursor := crDefault;
  67. end;
  68. end;
  69. end;
  70.  
  71. procedure TForm1.N24bitGBB1Click( Sender: TObject );
  72. var
  73. wicImg: TWICImage;
  74. wicBitmap: IWICBitmap;
  75. iBmpSource: IWICBitmapSource;
  76. puiWidth, puiHeight: UINT;
  77. iConverter: IWICFormatConverter;
  78. begin
  79. if cxImage1.Picture.Graphic is TWICImage then
  80. begin
  81. Screen.Cursor := crHourGlass;
  82. try
  83. wicImg := TWICImage( cxImage1.Picture.Graphic );
  84. wicImg.ImagingFactory.CreateFormatConverter( iConverter );
  85. iBmpSource := wicImg.Handle as IWICBitmapSource;
  86. iBmpSource.GetSize( puiWidth, puiHeight );
  87. iConverter.Initialize( iBmpSource, GUID_WICPixelFormat24bppBGR, WICBitmapDitherTypeNone, nil, 0,
  88. WICBitmapPaletteTypeMedianCut );
  89. wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
  90. if Assigned( wicBitmap ) then
  91. wicImg.Handle := wicBitmap;
  92. cxImage1.Repaint;
  93. cxImage1.Update;
  94. cxImage1.Invalidate;
  95. dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
  96. dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
  97. dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
  98. dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
  99. dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
  100. finally
  101. Screen.Cursor := crDefault;
  102. end;
  103. end;
  104. end;
  105.  
  106. procedure TForm1.N2bitIndexed1Click( Sender: TObject );
  107. var
  108. wicImg: TWICImage;
  109. wicBitmap: IWICBitmap;
  110. iBmpSource: IWICBitmapSource;
  111. puiWidth, puiHeight: UINT;
  112. iConverter: IWICFormatConverter;
  113. begin
  114. if cxImage1.Picture.Graphic is TWICImage then
  115. begin
  116. Screen.Cursor := crHourGlass;
  117. try
  118. wicImg := TWICImage( cxImage1.Picture.Graphic );
  119. wicImg.ImagingFactory.CreateFormatConverter( iConverter );
  120. iBmpSource := wicImg.Handle as IWICBitmapSource;
  121. iBmpSource.GetSize( puiWidth, puiHeight );
  122. iConverter.Initialize( iBmpSource, GUID_WICPixelFormat2bppIndexed, WICBitmapDitherTypeNone, nil, 0,
  123. WICBitmapPaletteTypeMedianCut );
  124. wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
  125. if Assigned( wicBitmap ) then
  126. wicImg.Handle := wicBitmap;
  127. cxImage1.Repaint;
  128. cxImage1.Update;
  129. cxImage1.Invalidate;
  130. dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
  131. dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
  132. dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
  133. dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
  134. dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
  135. finally
  136. Screen.Cursor := crDefault;
  137. end;
  138. end;
  139. end;
  140.  
  141. procedure TForm1.N32bitGray1Click( Sender: TObject );
  142. var
  143. wicImg: TWICImage;
  144. wicBitmap: IWICBitmap;
  145. iBmpSource: IWICBitmapSource;
  146. puiWidth, puiHeight: UINT;
  147. iConverter: IWICFormatConverter;
  148. begin
  149. if cxImage1.Picture.Graphic is TWICImage then
  150. begin
  151. Screen.Cursor := crHourGlass;
  152. try
  153. wicImg := TWICImage( cxImage1.Picture.Graphic );
  154. wicImg.ImagingFactory.CreateFormatConverter( iConverter );
  155. iBmpSource := wicImg.Handle as IWICBitmapSource;
  156. iBmpSource.GetSize( puiWidth, puiHeight );
  157. iConverter.Initialize( iBmpSource, GUID_WICPixelFormat32bppGrayFloat, WICBitmapDitherTypeSolid, nil, 0,
  158. WICBitmapPaletteTypeFixedGray256 );
  159. wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
  160. if Assigned( wicBitmap ) then
  161. wicImg.Handle := wicBitmap;
  162. cxImage1.Repaint;
  163. cxImage1.Update;
  164. cxImage1.Invalidate;
  165. dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
  166. dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
  167. dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
  168. dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
  169. dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
  170. finally
  171. Screen.Cursor := crDefault;
  172. end;
  173. end;
  174. end;
  175.  
  176. procedure TForm1.N32bitGRBA1Click( Sender: TObject );
  177. var
  178. wicImg: TWICImage;
  179. wicBitmap: IWICBitmap;
  180. iBmpSource: IWICBitmapSource;
  181. puiWidth, puiHeight: UINT;
  182. iConverter: IWICFormatConverter;
  183. begin
  184. if cxImage1.Picture.Graphic is TWICImage then
  185. begin
  186. Screen.Cursor := crHourGlass;
  187. try
  188. wicImg := TWICImage( cxImage1.Picture.Graphic );
  189. wicImg.ImagingFactory.CreateFormatConverter( iConverter );
  190. iBmpSource := wicImg.Handle as IWICBitmapSource;
  191. iBmpSource.GetSize( puiWidth, puiHeight );
  192. iConverter.Initialize( iBmpSource, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, nil, 0,
  193. WICBitmapPaletteTypeMedianCut );
  194. wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
  195. if Assigned( wicBitmap ) then
  196. wicImg.Handle := wicBitmap;
  197. cxImage1.Repaint;
  198. cxImage1.Update;
  199. cxImage1.Invalidate;
  200. dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
  201. dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
  202. dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
  203. dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
  204. dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
  205. finally
  206. Screen.Cursor := crDefault;
  207. end;
  208. end;
  209. end;
  210.  
  211. procedure TForm1.N4bitIndexed1Click( Sender: TObject );
  212. var
  213. wicImg: TWICImage;
  214. wicBitmap: IWICBitmap;
  215. iBmpSource: IWICBitmapSource;
  216. puiWidth, puiHeight: UINT;
  217. iConverter: IWICFormatConverter;
  218. begin
  219. if cxImage1.Picture.Graphic is TWICImage then
  220. begin
  221. Screen.Cursor := crHourGlass;
  222. try
  223. wicImg := TWICImage( cxImage1.Picture.Graphic );
  224. wicImg.ImagingFactory.CreateFormatConverter( iConverter );
  225. iBmpSource := wicImg.Handle as IWICBitmapSource;
  226. iBmpSource.GetSize( puiWidth, puiHeight );
  227. iConverter.Initialize( iBmpSource, GUID_WICPixelFormat4bppIndexed, WICBitmapDitherTypeNone, nil, 0,
  228. WICBitmapPaletteTypeMedianCut );
  229. wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
  230. if Assigned( wicBitmap ) then
  231. wicImg.Handle := wicBitmap;
  232. cxImage1.Repaint;
  233. cxImage1.Update;
  234. cxImage1.Invalidate;
  235. dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
  236. dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
  237. dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
  238. dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
  239. dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
  240. finally
  241. Screen.Cursor := crDefault;
  242. end;
  243. end;
  244. end;
  245.  
  246. procedure TForm1.N8bitGray1Click( Sender: TObject );
  247. var
  248. wicImg: TWICImage;
  249. wicBitmap: IWICBitmap;
  250. iBmpSource: IWICBitmapSource;
  251. puiWidth, puiHeight: UINT;
  252. iConverter: IWICFormatConverter;
  253. begin
  254. if cxImage1.Picture.Graphic is TWICImage then
  255. begin
  256. Screen.Cursor := crHourGlass;
  257. try
  258. wicImg := TWICImage( cxImage1.Picture.Graphic );
  259. wicImg.ImagingFactory.CreateFormatConverter( iConverter );
  260. iBmpSource := wicImg.Handle as IWICBitmapSource;
  261. iBmpSource.GetSize( puiWidth, puiHeight );
  262. iConverter.Initialize( iBmpSource, GUID_WICPixelFormat8bppGray, WICBitmapDitherTypeSolid, nil, 0,
  263. WICBitmapPaletteTypeMedianCut );
  264. wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
  265. if Assigned( wicBitmap ) then
  266. wicImg.Handle := wicBitmap;
  267. cxImage1.Repaint;
  268. cxImage1.Update;
  269. cxImage1.Invalidate;
  270. dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
  271. dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
  272. dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
  273. dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
  274. dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
  275. finally
  276. Screen.Cursor := crDefault;
  277. end;
  278. end;
  279. end;
  280.  
  281. procedure TForm1.N8bitIndexed1Click( Sender: TObject );
  282. var
  283. wicImg: TWICImage;
  284. wicBitmap: IWICBitmap;
  285. iBmpSource: IWICBitmapSource;
  286. puiWidth, puiHeight: UINT;
  287. iConverter: IWICFormatConverter;
  288. begin
  289. if cxImage1.Picture.Graphic is TWICImage then
  290. begin
  291. Screen.Cursor := crHourGlass;
  292. try
  293. wicImg := TWICImage( cxImage1.Picture.Graphic );
  294. wicImg.ImagingFactory.CreateFormatConverter( iConverter );
  295. iBmpSource := wicImg.Handle as IWICBitmapSource;
  296. iBmpSource.GetSize( puiWidth, puiHeight );
  297. iConverter.Initialize( iBmpSource, GUID_WICPixelFormat8bppIndexed, WICBitmapDitherTypeNone, nil, 0,
  298. WICBitmapPaletteTypeFixedGray256 );
  299. wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
  300. if Assigned( wicBitmap ) then
  301. wicImg.Handle := wicBitmap;
  302. cxImage1.Repaint;
  303. cxImage1.Update;
  304. cxImage1.Invalidate;
  305. dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
  306. dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
  307. dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
  308. dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
  309. dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
  310. finally
  311. Screen.Cursor := crDefault;
  312. end;
  313. end;
  314. end;
  315.  
  316. procedure TForm1.N16bitBGR1Click( Sender: TObject );
  317. var
  318. wicImg: TWICImage;
  319. wicBitmap: IWICBitmap;
  320. iBmpSource: IWICBitmapSource;
  321. puiWidth, puiHeight: UINT;
  322. iConverter: IWICFormatConverter;
  323. begin
  324. if cxImage1.Picture.Graphic is TWICImage then
  325. begin
  326. Screen.Cursor := crHourGlass;
  327. try
  328. wicImg := TWICImage( cxImage1.Picture.Graphic );
  329. wicImg.ImagingFactory.CreateFormatConverter( iConverter );
  330. iBmpSource := wicImg.Handle as IWICBitmapSource;
  331. iBmpSource.GetSize( puiWidth, puiHeight );
  332. iConverter.Initialize( iBmpSource, GUID_WICPixelFormat16bppBGR555, WICBitmapDitherTypeNone, nil, 0,
  333. WICBitmapPaletteTypeMedianCut );
  334. wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
  335. if Assigned( wicBitmap ) then
  336. wicImg.Handle := wicBitmap;
  337. cxImage1.Repaint;
  338. cxImage1.Update;
  339. cxImage1.Invalidate;
  340. dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
  341. dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
  342. dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
  343. dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
  344. dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
  345. finally
  346. Screen.Cursor := crDefault;
  347. end;
  348. end;
  349. end;
  350.  
  351. procedure TForm1.N16bitGray1Click( Sender: TObject );
  352. var
  353. wicImg: TWICImage;
  354. wicBitmap: IWICBitmap;
  355. iBmpSource: IWICBitmapSource;
  356. puiWidth, puiHeight: UINT;
  357. iConverter: IWICFormatConverter;
  358. begin
  359. if cxImage1.Picture.Graphic is TWICImage then
  360. begin
  361. Screen.Cursor := crHourGlass;
  362. try
  363. wicImg := TWICImage( cxImage1.Picture.Graphic );
  364. wicImg.ImagingFactory.CreateFormatConverter( iConverter );
  365. iBmpSource := wicImg.Handle as IWICBitmapSource;
  366. iBmpSource.GetSize( puiWidth, puiHeight );
  367. iConverter.Initialize( iBmpSource, GUID_WICPixelFormat16bppGray, WICBitmapDitherTypeSolid, nil, 0,
  368. WICBitmapPaletteTypeFixedGray16 );
  369. wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
  370. if Assigned( wicBitmap ) then
  371. wicImg.Handle := wicBitmap;
  372. cxImage1.Repaint;
  373. cxImage1.Update;
  374. cxImage1.Invalidate;
  375. dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
  376. dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
  377. dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
  378. dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
  379. dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
  380. finally
  381. Screen.Cursor := crDefault;
  382. end;
  383. end;
  384. end;
  385.  
  386. procedure TForm1.N24bitGBB1Click( Sender: TObject );
  387. var
  388. wicImg: TWICImage;
  389. wicBitmap: IWICBitmap;
  390. iBmpSource: IWICBitmapSource;
  391. puiWidth, puiHeight: UINT;
  392. iConverter: IWICFormatConverter;
  393. begin
  394. if cxImage1.Picture.Graphic is TWICImage then
  395. begin
  396. Screen.Cursor := crHourGlass;
  397. try
  398. wicImg := TWICImage( cxImage1.Picture.Graphic );
  399. wicImg.ImagingFactory.CreateFormatConverter( iConverter );
  400. iBmpSource := wicImg.Handle as IWICBitmapSource;
  401. iBmpSource.GetSize( puiWidth, puiHeight );
  402. iConverter.Initialize( iBmpSource, GUID_WICPixelFormat24bppBGR, WICBitmapDitherTypeNone, nil, 0,
  403. WICBitmapPaletteTypeMedianCut );
  404. wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
  405. if Assigned( wicBitmap ) then
  406. wicImg.Handle := wicBitmap;
  407. cxImage1.Repaint;
  408. cxImage1.Update;
  409. cxImage1.Invalidate;
  410. dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
  411. dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
  412. dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
  413. dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
  414. dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
  415. finally
  416. Screen.Cursor := crDefault;
  417. end;
  418. end;
  419. end;
  420.  
  421. procedure TForm1.N2bitIndexed1Click( Sender: TObject );
  422. var
  423. wicImg: TWICImage;
  424. wicBitmap: IWICBitmap;
  425. iBmpSource: IWICBitmapSource;
  426. puiWidth, puiHeight: UINT;
  427. iConverter: IWICFormatConverter;
  428. begin
  429. if cxImage1.Picture.Graphic is TWICImage then
  430. begin
  431. Screen.Cursor := crHourGlass;
  432. try
  433. wicImg := TWICImage( cxImage1.Picture.Graphic );
  434. wicImg.ImagingFactory.CreateFormatConverter( iConverter );
  435. iBmpSource := wicImg.Handle as IWICBitmapSource;
  436. iBmpSource.GetSize( puiWidth, puiHeight );
  437. iConverter.Initialize( iBmpSource, GUID_WICPixelFormat2bppIndexed, WICBitmapDitherTypeNone, nil, 0,
  438. WICBitmapPaletteTypeMedianCut );
  439. wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
  440. if Assigned( wicBitmap ) then
  441. wicImg.Handle := wicBitmap;
  442. cxImage1.Repaint;
  443. cxImage1.Update;
  444. cxImage1.Invalidate;
  445. dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
  446. dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
  447. dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
  448. dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
  449. dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
  450. finally
  451. Screen.Cursor := crDefault;
  452. end;
  453. end;
  454. end;
  455.  
  456. procedure TForm1.N32bitGray1Click( Sender: TObject );
  457. var
  458. wicImg: TWICImage;
  459. wicBitmap: IWICBitmap;
  460. iBmpSource: IWICBitmapSource;
  461. puiWidth, puiHeight: UINT;
  462. iConverter: IWICFormatConverter;
  463. begin
  464. if cxImage1.Picture.Graphic is TWICImage then
  465. begin
  466. Screen.Cursor := crHourGlass;
  467. try
  468. wicImg := TWICImage( cxImage1.Picture.Graphic );
  469. wicImg.ImagingFactory.CreateFormatConverter( iConverter );
  470. iBmpSource := wicImg.Handle as IWICBitmapSource;
  471. iBmpSource.GetSize( puiWidth, puiHeight );
  472. iConverter.Initialize( iBmpSource, GUID_WICPixelFormat32bppGrayFloat, WICBitmapDitherTypeSolid, nil, 0,
  473. WICBitmapPaletteTypeFixedGray256 );
  474. wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
  475. if Assigned( wicBitmap ) then
  476. wicImg.Handle := wicBitmap;
  477. cxImage1.Repaint;
  478. cxImage1.Update;
  479. cxImage1.Invalidate;
  480. dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
  481. dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
  482. dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
  483. dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
  484. dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
  485. finally
  486. Screen.Cursor := crDefault;
  487. end;
  488. end;
  489. end;
  490.  
  491. procedure TForm1.N32bitGRBA1Click( Sender: TObject );
  492. var
  493. wicImg: TWICImage;
  494. wicBitmap: IWICBitmap;
  495. iBmpSource: IWICBitmapSource;
  496. puiWidth, puiHeight: UINT;
  497. iConverter: IWICFormatConverter;
  498. begin
  499. if cxImage1.Picture.Graphic is TWICImage then
  500. begin
  501. Screen.Cursor := crHourGlass;
  502. try
  503. wicImg := TWICImage( cxImage1.Picture.Graphic );
  504. wicImg.ImagingFactory.CreateFormatConverter( iConverter );
  505. iBmpSource := wicImg.Handle as IWICBitmapSource;
  506. iBmpSource.GetSize( puiWidth, puiHeight );
  507. iConverter.Initialize( iBmpSource, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, nil, 0,
  508. WICBitmapPaletteTypeMedianCut );
  509. wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
  510. if Assigned( wicBitmap ) then
  511. wicImg.Handle := wicBitmap;
  512. cxImage1.Repaint;
  513. cxImage1.Update;
  514. cxImage1.Invalidate;
  515. dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
  516. dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
  517. dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
  518. dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
  519. dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
  520. finally
  521. Screen.Cursor := crDefault;
  522. end;
  523. end;
  524. end;
  525.  
  526. procedure TForm1.N4bitIndexed1Click( Sender: TObject );
  527. var
  528. wicImg: TWICImage;
  529. wicBitmap: IWICBitmap;
  530. iBmpSource: IWICBitmapSource;
  531. puiWidth, puiHeight: UINT;
  532. iConverter: IWICFormatConverter;
  533. begin
  534. if cxImage1.Picture.Graphic is TWICImage then
  535. begin
  536. Screen.Cursor := crHourGlass;
  537. try
  538. wicImg := TWICImage( cxImage1.Picture.Graphic );
  539. wicImg.ImagingFactory.CreateFormatConverter( iConverter );
  540. iBmpSource := wicImg.Handle as IWICBitmapSource;
  541. iBmpSource.GetSize( puiWidth, puiHeight );
  542. iConverter.Initialize( iBmpSource, GUID_WICPixelFormat4bppIndexed, WICBitmapDitherTypeNone, nil, 0,
  543. WICBitmapPaletteTypeMedianCut );
  544. wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
  545. if Assigned( wicBitmap ) then
  546. wicImg.Handle := wicBitmap;
  547. cxImage1.Repaint;
  548. cxImage1.Update;
  549. cxImage1.Invalidate;
  550. dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
  551. dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
  552. dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
  553. dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
  554. dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
  555. finally
  556. Screen.Cursor := crDefault;
  557. end;
  558. end;
  559. end;
  560.  
  561. procedure TForm1.N8bitGray1Click( Sender: TObject );
  562. var
  563. wicImg: TWICImage;
  564. wicBitmap: IWICBitmap;
  565. iBmpSource: IWICBitmapSource;
  566. puiWidth, puiHeight: UINT;
  567. iConverter: IWICFormatConverter;
  568. begin
  569. if cxImage1.Picture.Graphic is TWICImage then
  570. begin
  571. Screen.Cursor := crHourGlass;
  572. try
  573. wicImg := TWICImage( cxImage1.Picture.Graphic );
  574. wicImg.ImagingFactory.CreateFormatConverter( iConverter );
  575. iBmpSource := wicImg.Handle as IWICBitmapSource;
  576. iBmpSource.GetSize( puiWidth, puiHeight );
  577. iConverter.Initialize( iBmpSource, GUID_WICPixelFormat8bppGray, WICBitmapDitherTypeSolid, nil, 0,
  578. WICBitmapPaletteTypeMedianCut );
  579. wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
  580. if Assigned( wicBitmap ) then
  581. wicImg.Handle := wicBitmap;
  582. cxImage1.Repaint;
  583. cxImage1.Update;
  584. cxImage1.Invalidate;
  585. dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
  586. dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
  587. dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
  588. dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
  589. dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
  590. finally
  591. Screen.Cursor := crDefault;
  592. end;
  593. end;
  594. end;
  595.  
  596. procedure TForm1.N8bitIndexed1Click( Sender: TObject );
  597. var
  598. wicImg: TWICImage;
  599. wicBitmap: IWICBitmap;
  600. iBmpSource: IWICBitmapSource;
  601. puiWidth, puiHeight: UINT;
  602. iConverter: IWICFormatConverter;
  603. begin
  604. if cxImage1.Picture.Graphic is TWICImage then
  605. begin
  606. Screen.Cursor := crHourGlass;
  607. try
  608. wicImg := TWICImage( cxImage1.Picture.Graphic );
  609. wicImg.ImagingFactory.CreateFormatConverter( iConverter );
  610. iBmpSource := wicImg.Handle as IWICBitmapSource;
  611. iBmpSource.GetSize( puiWidth, puiHeight );
  612. iConverter.Initialize( iBmpSource, GUID_WICPixelFormat8bppIndexed, WICBitmapDitherTypeNone, nil, 0,
  613. WICBitmapPaletteTypeFixedGray256 );
  614. wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
  615. if Assigned( wicBitmap ) then
  616. wicImg.Handle := wicBitmap;
  617. cxImage1.Repaint;
  618. cxImage1.Update;
  619. cxImage1.Invalidate;
  620. dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
  621. dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
  622. dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
  623. dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
  624. dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
  625. finally
  626. Screen.Cursor := crDefault;
  627. end;
  628. end;
  629. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement