0

我发现了这个类似的问题,我试图实施,但没有奏效。

如果有人想将图表另存为图像,我有一个创建图表的类并有第二个构造函数。但是,正在保存的图像只是表单背景,而不是图表。这是我的代码。

public ChartForm(String path)
    {
        InitializeComponent();
        SaveGraphAsImage(path);
    }

private void SaveChartAsImage(String path)
    {
        bmp = new Bitmap(this.Width, this.Height);
        this.DrawToBitmap(bmp, new Rectangle(0, 0, this.Width, this.Height));
        this.bmp.Save(path + this.Name, System.Drawing.Imaging.ImageFormat.Jpeg);
    }
4

2 回答 2

1

我通过在图表填充数据后保存图表图像来解决问题。

于 2012-09-28T17:51:00.763 回答
0

您不应该使用该DrawToBitmap()方法(这会在大控件上产生一些问题(异常)),因为Chart该类具有该SaveImage()方法。

//using System.Drawing.Imaging;
myChartControl.SaveImage(path + this.Name, ImageFormat.Jpeg);
于 2012-09-28T17:56:48.423 回答