如果您将所有框架,形状和图片放在新的TPanel(我的样本中名为MainPanel)中,那么您可以使用:
procedure savePanelAsImage(fpPanel: tPanel; fpFileName: string);
var
img: TBitmap;
begin
img := TBitmap.Create;
try
img.Width := fpPanel.Width;
img.Height := fpPanel.Height;
fpPanel.PaintTo(img.Canvas, 0, 0);
img.SaveToFile(fpFileName);
finally
img.Free;
end
end;
Run Code Online (Sandbox Code Playgroud)
用法:
savePanelAsImage(MainPanel, 'd:\someFolder\image001.bmp');
Run Code Online (Sandbox Code Playgroud)
笔记:
为了获得更好的结果/灵活性,我建议为Delphi 使用Graphics32库(它支持图层,图像重新调整大小等).


| 归档时间: |
|
| 查看次数: |
3115 次 |
| 最近记录: |