如何在Delphi 2010中更改TWICImage的像素格式
我有一个TWicImage、IWicBitmap和一个IWicBitmapSource,可以很好地显示所有支持的图形文件格式,允许旋转、水平翻转、垂直翻转、缩放和剪切。所有这些看起来都很好,我可以得到WicImages的像素格式,但我不知道如何更改或设置TWicImage的像素格式 我创建了一个对话框,返回WICPixelFormatGUID作为转换的像素格式 任何人都可以分享一些代码来演示如何使用IWICColorTransform或其他Wincodec方法更改WicImage的像素格式吗 账单 现在已经是2011年的中期了。。。因此,对于那些可能想知道的人来说,我尝试了这个方法,它似乎起到了作用(它使用了Developer Express提供的TcxImage,但我怀疑TImage也会起作用):如何在Delphi 2010中更改TWICImage的像素格式,delphi,delphi-2010,Delphi,Delphi 2010,我有一个TWicImage、IWicBitmap和一个IWicBitmapSource,可以很好地显示所有支持的图形文件格式,允许旋转、水平翻转、垂直翻转、缩放和剪切。所有这些看起来都很好,我可以得到WicImages的像素格式,但我不知道如何更改或设置TWicImage的像素格式 我创建了一个对话框,返回WICPixelFormatGUID作为转换的像素格式 任何人都可以分享一些代码来演示如何使用IWICColorTransform或其他Wincodec方法更改WicImage的像素格式吗 账
Bummi和Warren p要求我发布我之前添加的答案。答案如下: 对于那些可能想知道的人,我尝试了这一点,它似乎起了作用(它使用开发者Express的TcxImage,但我怀疑TImage也会起作用):
+1,无论如何,你可以简单地使用这个函数,而不需要格式转换器。嗨,比尔,你的答案在德尔福未回答问题的顶部。如果我读对了,你就解决了问题,把你的答案写进你的问题里。你能把答案放在回答区并接受它吗?现在是11月,还没有完成,我建议有人为他做这件事,并附上归因。
procedure TForm1.N16bitBGR1Click( Sender: TObject );
var
wicImg: TWICImage;
wicBitmap: IWICBitmap;
iBmpSource: IWICBitmapSource;
puiWidth, puiHeight: UINT;
iConverter: IWICFormatConverter;
begin
if cxImage1.Picture.Graphic is TWICImage then
begin
Screen.Cursor := crHourGlass;
try
wicImg := TWICImage( cxImage1.Picture.Graphic );
wicImg.ImagingFactory.CreateFormatConverter( iConverter );
iBmpSource := wicImg.Handle as IWICBitmapSource;
iBmpSource.GetSize( puiWidth, puiHeight );
iConverter.Initialize( iBmpSource, GUID_WICPixelFormat16bppBGR555, WICBitmapDitherTypeNone, nil, 0,
WICBitmapPaletteTypeMedianCut );
wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
if Assigned( wicBitmap ) then
wicImg.Handle := wicBitmap;
cxImage1.Repaint;
cxImage1.Update;
cxImage1.Invalidate;
dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
finally
Screen.Cursor := crDefault;
end;
end;
end;
procedure TForm1.N16bitGray1Click( Sender: TObject );
var
wicImg: TWICImage;
wicBitmap: IWICBitmap;
iBmpSource: IWICBitmapSource;
puiWidth, puiHeight: UINT;
iConverter: IWICFormatConverter;
begin
if cxImage1.Picture.Graphic is TWICImage then
begin
Screen.Cursor := crHourGlass;
try
wicImg := TWICImage( cxImage1.Picture.Graphic );
wicImg.ImagingFactory.CreateFormatConverter( iConverter );
iBmpSource := wicImg.Handle as IWICBitmapSource;
iBmpSource.GetSize( puiWidth, puiHeight );
iConverter.Initialize( iBmpSource, GUID_WICPixelFormat16bppGray, WICBitmapDitherTypeSolid, nil, 0,
WICBitmapPaletteTypeFixedGray16 );
wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
if Assigned( wicBitmap ) then
wicImg.Handle := wicBitmap;
cxImage1.Repaint;
cxImage1.Update;
cxImage1.Invalidate;
dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
finally
Screen.Cursor := crDefault;
end;
end;
end;
procedure TForm1.N24bitGBB1Click( Sender: TObject );
var
wicImg: TWICImage;
wicBitmap: IWICBitmap;
iBmpSource: IWICBitmapSource;
puiWidth, puiHeight: UINT;
iConverter: IWICFormatConverter;
begin
if cxImage1.Picture.Graphic is TWICImage then
begin
Screen.Cursor := crHourGlass;
try
wicImg := TWICImage( cxImage1.Picture.Graphic );
wicImg.ImagingFactory.CreateFormatConverter( iConverter );
iBmpSource := wicImg.Handle as IWICBitmapSource;
iBmpSource.GetSize( puiWidth, puiHeight );
iConverter.Initialize( iBmpSource, GUID_WICPixelFormat24bppBGR, WICBitmapDitherTypeNone, nil, 0,
WICBitmapPaletteTypeMedianCut );
wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
if Assigned( wicBitmap ) then
wicImg.Handle := wicBitmap;
cxImage1.Repaint;
cxImage1.Update;
cxImage1.Invalidate;
dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
finally
Screen.Cursor := crDefault;
end;
end;
end;
procedure TForm1.N2bitIndexed1Click( Sender: TObject );
var
wicImg: TWICImage;
wicBitmap: IWICBitmap;
iBmpSource: IWICBitmapSource;
puiWidth, puiHeight: UINT;
iConverter: IWICFormatConverter;
begin
if cxImage1.Picture.Graphic is TWICImage then
begin
Screen.Cursor := crHourGlass;
try
wicImg := TWICImage( cxImage1.Picture.Graphic );
wicImg.ImagingFactory.CreateFormatConverter( iConverter );
iBmpSource := wicImg.Handle as IWICBitmapSource;
iBmpSource.GetSize( puiWidth, puiHeight );
iConverter.Initialize( iBmpSource, GUID_WICPixelFormat2bppIndexed, WICBitmapDitherTypeNone, nil, 0,
WICBitmapPaletteTypeMedianCut );
wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
if Assigned( wicBitmap ) then
wicImg.Handle := wicBitmap;
cxImage1.Repaint;
cxImage1.Update;
cxImage1.Invalidate;
dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
finally
Screen.Cursor := crDefault;
end;
end;
end;
procedure TForm1.N32bitGray1Click( Sender: TObject );
var
wicImg: TWICImage;
wicBitmap: IWICBitmap;
iBmpSource: IWICBitmapSource;
puiWidth, puiHeight: UINT;
iConverter: IWICFormatConverter;
begin
if cxImage1.Picture.Graphic is TWICImage then
begin
Screen.Cursor := crHourGlass;
try
wicImg := TWICImage( cxImage1.Picture.Graphic );
wicImg.ImagingFactory.CreateFormatConverter( iConverter );
iBmpSource := wicImg.Handle as IWICBitmapSource;
iBmpSource.GetSize( puiWidth, puiHeight );
iConverter.Initialize( iBmpSource, GUID_WICPixelFormat32bppGrayFloat, WICBitmapDitherTypeSolid, nil, 0,
WICBitmapPaletteTypeFixedGray256 );
wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
if Assigned( wicBitmap ) then
wicImg.Handle := wicBitmap;
cxImage1.Repaint;
cxImage1.Update;
cxImage1.Invalidate;
dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
finally
Screen.Cursor := crDefault;
end;
end;
end;
procedure TForm1.N32bitGRBA1Click( Sender: TObject );
var
wicImg: TWICImage;
wicBitmap: IWICBitmap;
iBmpSource: IWICBitmapSource;
puiWidth, puiHeight: UINT;
iConverter: IWICFormatConverter;
begin
if cxImage1.Picture.Graphic is TWICImage then
begin
Screen.Cursor := crHourGlass;
try
wicImg := TWICImage( cxImage1.Picture.Graphic );
wicImg.ImagingFactory.CreateFormatConverter( iConverter );
iBmpSource := wicImg.Handle as IWICBitmapSource;
iBmpSource.GetSize( puiWidth, puiHeight );
iConverter.Initialize( iBmpSource, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, nil, 0,
WICBitmapPaletteTypeMedianCut );
wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
if Assigned( wicBitmap ) then
wicImg.Handle := wicBitmap;
cxImage1.Repaint;
cxImage1.Update;
cxImage1.Invalidate;
dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
finally
Screen.Cursor := crDefault;
end;
end;
end;
procedure TForm1.N4bitIndexed1Click( Sender: TObject );
var
wicImg: TWICImage;
wicBitmap: IWICBitmap;
iBmpSource: IWICBitmapSource;
puiWidth, puiHeight: UINT;
iConverter: IWICFormatConverter;
begin
if cxImage1.Picture.Graphic is TWICImage then
begin
Screen.Cursor := crHourGlass;
try
wicImg := TWICImage( cxImage1.Picture.Graphic );
wicImg.ImagingFactory.CreateFormatConverter( iConverter );
iBmpSource := wicImg.Handle as IWICBitmapSource;
iBmpSource.GetSize( puiWidth, puiHeight );
iConverter.Initialize( iBmpSource, GUID_WICPixelFormat4bppIndexed, WICBitmapDitherTypeNone, nil, 0,
WICBitmapPaletteTypeMedianCut );
wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
if Assigned( wicBitmap ) then
wicImg.Handle := wicBitmap;
cxImage1.Repaint;
cxImage1.Update;
cxImage1.Invalidate;
dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
finally
Screen.Cursor := crDefault;
end;
end;
end;
procedure TForm1.N8bitGray1Click( Sender: TObject );
var
wicImg: TWICImage;
wicBitmap: IWICBitmap;
iBmpSource: IWICBitmapSource;
puiWidth, puiHeight: UINT;
iConverter: IWICFormatConverter;
begin
if cxImage1.Picture.Graphic is TWICImage then
begin
Screen.Cursor := crHourGlass;
try
wicImg := TWICImage( cxImage1.Picture.Graphic );
wicImg.ImagingFactory.CreateFormatConverter( iConverter );
iBmpSource := wicImg.Handle as IWICBitmapSource;
iBmpSource.GetSize( puiWidth, puiHeight );
iConverter.Initialize( iBmpSource, GUID_WICPixelFormat8bppGray, WICBitmapDitherTypeSolid, nil, 0,
WICBitmapPaletteTypeMedianCut );
wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
if Assigned( wicBitmap ) then
wicImg.Handle := wicBitmap;
cxImage1.Repaint;
cxImage1.Update;
cxImage1.Invalidate;
dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
finally
Screen.Cursor := crDefault;
end;
end;
end;
procedure TForm1.N8bitIndexed1Click( Sender: TObject );
var
wicImg: TWICImage;
wicBitmap: IWICBitmap;
iBmpSource: IWICBitmapSource;
puiWidth, puiHeight: UINT;
iConverter: IWICFormatConverter;
begin
if cxImage1.Picture.Graphic is TWICImage then
begin
Screen.Cursor := crHourGlass;
try
wicImg := TWICImage( cxImage1.Picture.Graphic );
wicImg.ImagingFactory.CreateFormatConverter( iConverter );
iBmpSource := wicImg.Handle as IWICBitmapSource;
iBmpSource.GetSize( puiWidth, puiHeight );
iConverter.Initialize( iBmpSource, GUID_WICPixelFormat8bppIndexed, WICBitmapDitherTypeNone, nil, 0,
WICBitmapPaletteTypeFixedGray256 );
wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
if Assigned( wicBitmap ) then
wicImg.Handle := wicBitmap;
cxImage1.Repaint;
cxImage1.Update;
cxImage1.Invalidate;
dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
finally
Screen.Cursor := crDefault;
end;
end;
end;
procedure TForm1.N16bitBGR1Click( Sender: TObject );
var
wicImg: TWICImage;
wicBitmap: IWICBitmap;
iBmpSource: IWICBitmapSource;
puiWidth, puiHeight: UINT;
iConverter: IWICFormatConverter;
begin
if cxImage1.Picture.Graphic is TWICImage then
begin
Screen.Cursor := crHourGlass;
try
wicImg := TWICImage( cxImage1.Picture.Graphic );
wicImg.ImagingFactory.CreateFormatConverter( iConverter );
iBmpSource := wicImg.Handle as IWICBitmapSource;
iBmpSource.GetSize( puiWidth, puiHeight );
iConverter.Initialize( iBmpSource, GUID_WICPixelFormat16bppBGR555, WICBitmapDitherTypeNone, nil, 0,
WICBitmapPaletteTypeMedianCut );
wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
if Assigned( wicBitmap ) then
wicImg.Handle := wicBitmap;
cxImage1.Repaint;
cxImage1.Update;
cxImage1.Invalidate;
dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
finally
Screen.Cursor := crDefault;
end;
end;
end;
procedure TForm1.N16bitGray1Click( Sender: TObject );
var
wicImg: TWICImage;
wicBitmap: IWICBitmap;
iBmpSource: IWICBitmapSource;
puiWidth, puiHeight: UINT;
iConverter: IWICFormatConverter;
begin
if cxImage1.Picture.Graphic is TWICImage then
begin
Screen.Cursor := crHourGlass;
try
wicImg := TWICImage( cxImage1.Picture.Graphic );
wicImg.ImagingFactory.CreateFormatConverter( iConverter );
iBmpSource := wicImg.Handle as IWICBitmapSource;
iBmpSource.GetSize( puiWidth, puiHeight );
iConverter.Initialize( iBmpSource, GUID_WICPixelFormat16bppGray, WICBitmapDitherTypeSolid, nil, 0,
WICBitmapPaletteTypeFixedGray16 );
wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
if Assigned( wicBitmap ) then
wicImg.Handle := wicBitmap;
cxImage1.Repaint;
cxImage1.Update;
cxImage1.Invalidate;
dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
finally
Screen.Cursor := crDefault;
end;
end;
end;
procedure TForm1.N24bitGBB1Click( Sender: TObject );
var
wicImg: TWICImage;
wicBitmap: IWICBitmap;
iBmpSource: IWICBitmapSource;
puiWidth, puiHeight: UINT;
iConverter: IWICFormatConverter;
begin
if cxImage1.Picture.Graphic is TWICImage then
begin
Screen.Cursor := crHourGlass;
try
wicImg := TWICImage( cxImage1.Picture.Graphic );
wicImg.ImagingFactory.CreateFormatConverter( iConverter );
iBmpSource := wicImg.Handle as IWICBitmapSource;
iBmpSource.GetSize( puiWidth, puiHeight );
iConverter.Initialize( iBmpSource, GUID_WICPixelFormat24bppBGR, WICBitmapDitherTypeNone, nil, 0,
WICBitmapPaletteTypeMedianCut );
wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
if Assigned( wicBitmap ) then
wicImg.Handle := wicBitmap;
cxImage1.Repaint;
cxImage1.Update;
cxImage1.Invalidate;
dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
finally
Screen.Cursor := crDefault;
end;
end;
end;
procedure TForm1.N2bitIndexed1Click( Sender: TObject );
var
wicImg: TWICImage;
wicBitmap: IWICBitmap;
iBmpSource: IWICBitmapSource;
puiWidth, puiHeight: UINT;
iConverter: IWICFormatConverter;
begin
if cxImage1.Picture.Graphic is TWICImage then
begin
Screen.Cursor := crHourGlass;
try
wicImg := TWICImage( cxImage1.Picture.Graphic );
wicImg.ImagingFactory.CreateFormatConverter( iConverter );
iBmpSource := wicImg.Handle as IWICBitmapSource;
iBmpSource.GetSize( puiWidth, puiHeight );
iConverter.Initialize( iBmpSource, GUID_WICPixelFormat2bppIndexed, WICBitmapDitherTypeNone, nil, 0,
WICBitmapPaletteTypeMedianCut );
wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
if Assigned( wicBitmap ) then
wicImg.Handle := wicBitmap;
cxImage1.Repaint;
cxImage1.Update;
cxImage1.Invalidate;
dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
finally
Screen.Cursor := crDefault;
end;
end;
end;
procedure TForm1.N32bitGray1Click( Sender: TObject );
var
wicImg: TWICImage;
wicBitmap: IWICBitmap;
iBmpSource: IWICBitmapSource;
puiWidth, puiHeight: UINT;
iConverter: IWICFormatConverter;
begin
if cxImage1.Picture.Graphic is TWICImage then
begin
Screen.Cursor := crHourGlass;
try
wicImg := TWICImage( cxImage1.Picture.Graphic );
wicImg.ImagingFactory.CreateFormatConverter( iConverter );
iBmpSource := wicImg.Handle as IWICBitmapSource;
iBmpSource.GetSize( puiWidth, puiHeight );
iConverter.Initialize( iBmpSource, GUID_WICPixelFormat32bppGrayFloat, WICBitmapDitherTypeSolid, nil, 0,
WICBitmapPaletteTypeFixedGray256 );
wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
if Assigned( wicBitmap ) then
wicImg.Handle := wicBitmap;
cxImage1.Repaint;
cxImage1.Update;
cxImage1.Invalidate;
dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
finally
Screen.Cursor := crDefault;
end;
end;
end;
procedure TForm1.N32bitGRBA1Click( Sender: TObject );
var
wicImg: TWICImage;
wicBitmap: IWICBitmap;
iBmpSource: IWICBitmapSource;
puiWidth, puiHeight: UINT;
iConverter: IWICFormatConverter;
begin
if cxImage1.Picture.Graphic is TWICImage then
begin
Screen.Cursor := crHourGlass;
try
wicImg := TWICImage( cxImage1.Picture.Graphic );
wicImg.ImagingFactory.CreateFormatConverter( iConverter );
iBmpSource := wicImg.Handle as IWICBitmapSource;
iBmpSource.GetSize( puiWidth, puiHeight );
iConverter.Initialize( iBmpSource, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, nil, 0,
WICBitmapPaletteTypeMedianCut );
wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
if Assigned( wicBitmap ) then
wicImg.Handle := wicBitmap;
cxImage1.Repaint;
cxImage1.Update;
cxImage1.Invalidate;
dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
finally
Screen.Cursor := crDefault;
end;
end;
end;
procedure TForm1.N4bitIndexed1Click( Sender: TObject );
var
wicImg: TWICImage;
wicBitmap: IWICBitmap;
iBmpSource: IWICBitmapSource;
puiWidth, puiHeight: UINT;
iConverter: IWICFormatConverter;
begin
if cxImage1.Picture.Graphic is TWICImage then
begin
Screen.Cursor := crHourGlass;
try
wicImg := TWICImage( cxImage1.Picture.Graphic );
wicImg.ImagingFactory.CreateFormatConverter( iConverter );
iBmpSource := wicImg.Handle as IWICBitmapSource;
iBmpSource.GetSize( puiWidth, puiHeight );
iConverter.Initialize( iBmpSource, GUID_WICPixelFormat4bppIndexed, WICBitmapDitherTypeNone, nil, 0,
WICBitmapPaletteTypeMedianCut );
wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
if Assigned( wicBitmap ) then
wicImg.Handle := wicBitmap;
cxImage1.Repaint;
cxImage1.Update;
cxImage1.Invalidate;
dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
finally
Screen.Cursor := crDefault;
end;
end;
end;
procedure TForm1.N8bitGray1Click( Sender: TObject );
var
wicImg: TWICImage;
wicBitmap: IWICBitmap;
iBmpSource: IWICBitmapSource;
puiWidth, puiHeight: UINT;
iConverter: IWICFormatConverter;
begin
if cxImage1.Picture.Graphic is TWICImage then
begin
Screen.Cursor := crHourGlass;
try
wicImg := TWICImage( cxImage1.Picture.Graphic );
wicImg.ImagingFactory.CreateFormatConverter( iConverter );
iBmpSource := wicImg.Handle as IWICBitmapSource;
iBmpSource.GetSize( puiWidth, puiHeight );
iConverter.Initialize( iBmpSource, GUID_WICPixelFormat8bppGray, WICBitmapDitherTypeSolid, nil, 0,
WICBitmapPaletteTypeMedianCut );
wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
if Assigned( wicBitmap ) then
wicImg.Handle := wicBitmap;
cxImage1.Repaint;
cxImage1.Update;
cxImage1.Invalidate;
dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
finally
Screen.Cursor := crDefault;
end;
end;
end;
procedure TForm1.N8bitIndexed1Click( Sender: TObject );
var
wicImg: TWICImage;
wicBitmap: IWICBitmap;
iBmpSource: IWICBitmapSource;
puiWidth, puiHeight: UINT;
iConverter: IWICFormatConverter;
begin
if cxImage1.Picture.Graphic is TWICImage then
begin
Screen.Cursor := crHourGlass;
try
wicImg := TWICImage( cxImage1.Picture.Graphic );
wicImg.ImagingFactory.CreateFormatConverter( iConverter );
iBmpSource := wicImg.Handle as IWICBitmapSource;
iBmpSource.GetSize( puiWidth, puiHeight );
iConverter.Initialize( iBmpSource, GUID_WICPixelFormat8bppIndexed, WICBitmapDitherTypeNone, nil, 0,
WICBitmapPaletteTypeFixedGray256 );
wicImg.ImagingFactory.CreateBitmapFromSourceRect( iConverter, 0, 0, puiWidth, puiHeight, wicBitmap );
if Assigned( wicBitmap ) then
wicImg.Handle := wicBitmap;
cxImage1.Repaint;
cxImage1.Update;
cxImage1.Invalidate;
dxStatusBar1.Panels[ 0 ].Text := ExtractFileDir( AFilename );
dxStatusBar1.Panels[ 1 ].Text := ExtractFileName( AFilename );
dxStatusBar1.Panels[ 2 ].Text := 'Width: ' + IntToStr( WICImageWidth( cxImage1 ) );
dxStatusBar1.Panels[ 3 ].Text := 'Height: ' + IntToStr( WICImageHeight( cxImage1 ) );
dxStatusBar1.Panels[ 4 ].Text := 'Pixel Format: ' + WICGetPixelFormat( cxImage1 );
finally
Screen.Cursor := crDefault;
end;
end;
end;