首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

Image.save报错的有关问题

2013-10-06 
Image.save报错的问题我给一个类image对象传了路径,现在我有需要把这个对象的image保存到本地,保存时就一

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();
}

热点排行