//正常显示图片, 没有变换 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 的回答.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步