您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

GDI +在Bitmap.Save方法中发生一般错误

GDI +在Bitmap.Save方法中发生一般错误

文件构造位图对象或图像对象时,文件在对象的生存期内保持锁定状态。因此,您无法更改图像并将其保存回其原始位置。http://support.microsoft.com/?id=814675

GDI +,JPEG图像到MemoryStream中发生一般错误

Image.Save(..)抛出GDI +异常,因为内存流已关闭

http://alperguc.blogspot.in/2008/11/c-generic-error-occurred-in- gdi.html

只是从内存写入…

保存到“中间”内存流,应该可以

例如尝试这个-替换

    Bitmap newBitmap = new Bitmap(thumbBMP);
    thumbBMP.Dispose();
    thumbBMP = null;
    newBitmap.Save("~/image/thumbs/" + "t" + objPropBannerImage.ImageId, ImageFormat.Jpeg);

与类似:

string outputFileName = "...";
using (MemoryStream memory = new MemoryStream())
{
    using (FileStream fs = new FileStream(outputFileName, FileMode.Create, FileAccess.ReadWrite))
    {
        thumbBMP.Save(memory, ImageFormat.Jpeg);
        byte[] bytes = memory.ToArray();
        fs.Write(bytes, 0, bytes.Length);
    }
}
其他 2022/1/1 18:17:42 有628人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶