versiones edition descargar community borland delphi delphi-2010

edition - delphi versiones



Cómo cambiar el formato de píxel de un TWICImage en Delphi 2010 (1)

Bummi y Warren P me pidieron que publicara la respuesta que había agregado hace algún tiempo. Aquí está la respuesta:

Para aquellos que quieran saber, probé esto y parece funcionar (usa TcxImage de Developer Express, pero sospecho que TImage también funcionará):

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;

Tengo un TWicImage, IWicBitmap y un IWicBitmapSource que funciona bien para mostrar todos los formatos de archivo gráficos admitidos, permite la rotación, voltear horizontalmente, voltear verticalmente, escalar y recortar. Todos estos parecen funcionar bien y puedo obtener el formato de pixel de WicImages, pero no puedo encontrar la manera de cambiar o establecer un formato de pixel de TWicImage.

Creé un diálogo para devolver WICPixelFormatGUID para ser utilizado como el formato de pixel para la transformación.

¿Alguien puede compartir algún código que demuestre cómo cambiar el formato de píxeles de un WicImage con IWICColorTransform u otro método de Wincodec?

Cuenta

Está a mediados de 2011 ahora ... así que para aquellos que quieran saber, probé esto y parece funcionar (usa TcxImage de Developer Express, pero sospecho que TImage también funcionará):

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;