var
bmp:Tbitmap;
begin
bmp := Tbitmap.Create;
try
bmp.Width:=Chart.Width;
bmp.Height:=Chart.Height;
bmp.Canvas.CopyMode:=cmSrcCopy;
bmp.Canvas.CopyRect(rect(Chart.Left,Chart.Top,Chart.Width,Chart.Height),Chart.Canvas.ReferenceCanvas,rect(Chart.Left,Chart.Top,Chart.Width,Chart.Height));
bmp.SaveToFile(filepath);
finally
bmp.Free;
end;
bmp:Tbitmap;
begin
bmp := Tbitmap.Create;
try
bmp.Width:=Chart.Width;
bmp.Height:=Chart.Height;
bmp.Canvas.CopyMode:=cmSrcCopy;
bmp.Canvas.CopyRect(rect(Chart.Left,Chart.Top,Chart.Width,Chart.Height),Chart.Canvas.ReferenceCanvas,rect(Chart.Left,Chart.Top,Chart.Width,Chart.Height));
bmp.SaveToFile(filepath);
finally
bmp.Free;
end;
本文介绍了一种使用 Delphi 将图表组件的内容保存为图片文件的方法。通过创建 TBitmap 对象并利用 Canvas 的 CopyRect 方法,可以将图表精确地复制到位图中,最后将此位图保存为指定路径下的文件。
3007

被折叠的 条评论
为什么被折叠?



