将图像保存到图片时出现gdi +错误

时间:2013-06-03 20:48:21

标签: generics gdi+ bmp system.drawing.imaging

我想创建一个程序,将bmp文件保存到我的pictures \ test中。 由于一些未知的原因,我得到了 - “GDI +中发生了一般性错误。” 请帮助我理解为什么会发生这种情况。 我的代码是:

System.Drawing.Image img = Properties.Resources.pic;
        string path = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
        string path2 = path+@"\"+"test";
        img.Save(path2, System.Drawing.Imaging.ImageFormat.Bmp);

1 个答案:

答案 0 :(得分:0)

可以是任意数量的东西,但请尝试保存图像的副本:

System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(Properties.Resources.pic);
string path = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
string path2 = path+@"\"+"test";
bmp.Save(path2);