我在 Windows 应用程序中遇到问题。我想更新一张图片,但它会产生异常:
“ GDI+ 中发生一般错误”
这是我的代码:
Dim ms As New MemoryStream
PicMeter.Image.Save(ms, PicMeter.Image.RawFormat) 'here exception occurs
Dim arr As Byte() = ms.GetBuffer()
ms.Close()
我在 Windows 应用程序中遇到问题。我想更新一张图片,但它会产生异常:
“ GDI+ 中发生一般错误”
这是我的代码:
Dim ms As New MemoryStream
PicMeter.Image.Save(ms, PicMeter.Image.RawFormat) 'here exception occurs
Dim arr As Byte() = ms.GetBuffer()
ms.Close()
改变
PicMeter.Image.Save(ms, PicMeter.Image.RawFormat)
至
PicMeter.Image.Save(ms, ImageFormat.RawFormat)
如果这没有帮助,是否有助于创建新图像并从那里保存?如此处建议:http ://www.dreamincode.net/forums/topic/49392-pictureboximage-save-error/
Dim ms As New MemoryStream
Dim bitmp As New Bitmap(PicMeter.Image)
bitmp.Save(ms, ImageFormat.RawFormat)
Dim arr As Byte() = ms.GetBuffer()
ms.Close()