【发布时间】: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