【问题标题】:A generic error occurred in GDI+ when saving image second time第二次保存图像时 GDI+ 中出现一般错误
【发布时间】:2017-06-27 02:13:05
【问题描述】:

我有一些代码在我第一次使用 PictureBox 上传图像并保存到数据库中的 byte[] 时工作正常,但是一旦我从数据库加载相同的图像并进入同一个 PictureBox 并尝试通过以下方式保存它在那一刻将图像转换为字节,它向我抛出了一个错误“GDI+ 中发生了一般错误。”

byte[] imageToByte = null;
using (var ms = new MemoryStream())
{
   System.Drawing.Image image = ProductImage.Image;
   image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
   imageToByte = ms.ToArray();
}

第 5 行:当我要保存图像时,第二次抛出错误。

【问题讨论】:

    标签: .net arrays image-processing memorystream


    【解决方案1】:

    在与自己进行大量头脑风暴后,我刚刚将“.BMP”更改为“.PNG”,这对我来说是可行的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多