C# 如何将图表控件图片保存到文件中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10865006/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to save a Chart control picture to a file?
提问by Ivan
Having a chart displayed with a System.Windows.Forms.DataVisualization.Charting.Chartcontrol in a .Net 4.0 WinForms application, can I save its render into a picture file?
在System.Windows.Forms.DataVisualization.Charting.Chart.Net 4.0 WinForms 应用程序中显示带有控件的图表,我可以将其渲染保存到图片文件中吗?
采纳答案by CodeCaster
How about the Chart.SaveImage()method?
怎么样的Chart.SaveImage()方法?
回答by AvkashChauhan
You can use the code below by passing proper ChartImageFormat.*:
您可以通过传递正确的 ChartImageFormat.* 来使用下面的代码:
this.chart1.SaveImage("C:\mycode\mychart.png", ChartImageFormat.Png);
Also look this SO if you met any problem: Save Image Using .net Chartand Saving higher resolution charts without messing up the appearance
如果您遇到任何问题,也请查看此 SO: 使用 .net 图表保存图像并 保存更高分辨率的图表而不会弄乱外观

