日期:2014-05-17  浏览次数:21048 次

Image.save报错的问题
我给一个类image对象传了路径,现在我有需要把这个对象的image保存到本地,保存时就一直报GDI+一般性错误

Test t=new Test();
t.img=Image.FileFrom("路径");

//下面我要把img存到其他位置
img.Save(savefile,
System.Drawing.Imaging.ImageFormat)//这句一直报GDI+一般性错误


我哪里弄错了

------解决方案--------------------
直接用Save(string)就好了。他会用原生的format
------解决方案--------------------
System.Drawing.Imaging.ImageFormat.Png ???
------解决方案--------------------
你那句编译不通过吧,应该这样。
image.Save("xxx", System.Drawing.Imaging.ImageFormat.Jpeg);

------解决方案--------------------
private void ConstructFromResourceSaveAsGif(PaintEventArgs e)
{

    // Construct a bitmap from the button image resource.
    Bitmap bmp1 = new Bitmap(typeof(Button), "Button.bmp");

    // Save the image as a GIF.
    bmp1.Save("c:\\button.gif", System.Drawing.Imaging.ImageFormat.Gif);

    // Construct a new image from the GIF file.
    Bitmap bmp2 = new Bitmap("c:\\button.gif");

    // Draw the two images.
    e.Graphics.DrawImage(bmp1, new Point(10, 10));
    e.Graphics.DrawImage(bmp2, new Point(10, 40));

    // Dispose of the image files.
    bmp1.Dispose();
    bmp2.Dispose();
}