1

我有一个从图片框中获取的 System.Drawing.Graphics。

基本上我在存储到图片框中的背景图像上画了一些线条现在我希望保存一个包含背景图像的 png 并且所有内容都绘制在那里......

有没有办法做到这一点?提前致谢

4

3 回答 3

4

是的,在 PictureBox 的图像上使用Image.Save 方法:

pictureBox.Image.Save(fullnameOfYourImage, System.Drawing.Imaging.ImageFormat.Png);
于 2012-07-23T23:02:48.460 回答
1

如果您在 Paint 事件上绘制这些线条,那么您需要使用 BackgroundImage 创建一个 BitMap,并使用 Bitmap 的 Graphics 调用您的绘制函数,然后调用 Bitmap.Save()。

        Bitmap bmp = new Bitmap(MyPictureBox.BackgroundImage);
        var g = Graphics.FromImage(bmp);
        MyPictureBox.OnPaint(new System.Windows.Forms.PaintEventArgs(g, bmp.GetBounds());
于 2012-07-23T23:04:18.843 回答
0

很确定您可以转换为位图并保存吗?

见这篇文章:

将 System.Drawing.Graphics 保存为 png 或 bmp

于 2012-07-23T23:02:26.253 回答