//正常顯示圖片, 沒有變換uses GDIPAPI, GDIPOBJ;
procedure TForm1.FormPaint(Sender: TObject);
var
g: TGPGraphics;
img: TGPImage;
begin
g := TGPGraphics.Create(Canvas.Handle);
img := TGPImage.Create('c:\temp\test.png'); {測試文件要存在}
g.DrawImage(img, 0, 0, img.GetWidth, img.GetHeight);
img.Free;
g.Free;
end;
//效果圖:
//添加顏色變換uses GDIPAPI, GDIPOBJ;
procedure TForm1.FormPaint(Sender: TObject);
var
g: TGPGraphics;
img: TGPImage;
imgAtt: TGPImageAttributes;
const
ColorMatrix: TColorMatrix = (
(1.0, 0.0, 0.0, 0.0, 0.0),
(0.0, 1.0, 0.0, 0.0, 0.0),
(0.0, 0.0, 1.0, 0.0, 0.0),
(0.0, 0.0, 0.0, 1.0, 0.0),
(1.0, 0.0, 0.0, 0.0, 1.0));
begin
g := TGPGraphics.Create(Canvas.Handle);
img := TGPImage.Create('c:\temp\test.png'); {測試文件要存在}
imgAtt := TGPImageAttributes.Create;
imgAtt.SetColorMatrix(colorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeDefault);
g.DrawImage(
img,
MakeRect(0,0,img.GetWidth,img.GetHeight),
0,
0,
img.GetWidth,
img.GetHeight,
UnitPixel,
imgAtt);
imgAtt.Free;
img.Free;
g.Free;
end;
//效果圖:
這個話題還有很多內容, 先弄這個例子算是給 M. Rokkaei 的回答.