2010-04-02 8 views
26

TWicImage, IWicBitmap 및 IWicBitmapSource를 사용하여 지원되는 모든 그래픽 파일 형식을 표시하고 Rotation, Flip Horizontal, Flip Vertical, Scaleing 및 Clipping이 가능합니다. 이 모든 것들이 잘 작동하는 것처럼 보이고 WicImages 픽셀 포맷을 얻을 수는 있지만 TWicImage의 픽셀 포맷을 변경하거나 설정하는 방법을 알 수는 없습니다.Delphi 2010에서 TWICImage의 픽셀 포맷을 변경하는 방법

변환을위한 픽셀 포맷으로 사용할 WICPixelFormatGUID를 반환하는 대화 상자를 만들었습니다.

누구나 IWICColorTransform 또는 다른 Wincodec 메서드를 사용하여 WicImage의 pixelformat을 변경하는 방법을 보여주는 코드를 공유 할 수 있습니까?

지금 2011을 통해 자사의 중간 ... 나는이 시도하고 작동하는 것 같다 알고 싶어 수 사람들을 위해, 그래서 (이 개발자 Express에서 TcxImage를 사용하지만, 내가 TImage의뿐만 아니라 작동합니다 의심) :

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; 
+1

1 어쨌든, 포맷 없이도 ['WICConvertBitmapSource'] (http://msdn.microsoft.com/en-us/library/windows/desktop/ee719819 (v = vs.85) .aspx) 함수를 사용하면됩니다. 이것을위한 변환기. – TLama

+1

안녕하세요 Bill, 답변되지 않은 Delphi의 질문 맨 위로 대답하십시오. 내가 그것을 올바르게 읽으면 그것을 해결하고 당신의 질문에 답을하십시오. 답변을 답안지에 넣고 수락 할 수 있습니까? – bummi

+0

이제 11 월에 완료되지 않았습니다. 누군가가 그 사람을 위해 기여했다고 제안합니다. –

답변

2

Bummi와 Warren P는 내가 전에 추가 한 답변을 게시하도록 요청했습니다. 여기에 대한 대답입니다 : 나는이 시도하고 작동하는 것 같다 알고 싶어 수 사람들을 위해

은 (는 개발자 Express에서 TcxImage를 사용하지만, 나는 TImage의뿐만 아니라 작동합니다 의심) :

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; 
관련 문제