将字节数组转换为图像 [英] Converting byte array to image
本文介绍了将字节数组转换为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用此函数将数据库中的字节数组转换回Image。 n所以我必须在图片框中显示它。
我在 ms 获得参数无效异常。请帮帮我。我现在受够了。
I am using this function to convert byte array in database to Image back. n so i have to display it in picture box.
I am getting "Parameter is not valid" exception at 'ms'. Please help me out. m fed up now.
Private Function ConvertBytes(ByVal mybytes() As Byte) As Image
Dim myimage As Image
Dim ms As System.IO.MemoryStream = New System.IO.MemoryStream(mybytes)
myimage = System.Drawing.Image.FromStream(ms)
Return myimage
End Function
推荐答案
可能不是那个代码 - 看起来很好 - 但你保存的方式数据到您的数据库。
看看这个:为什么我得到参数无效。我从数据库中读取图像时出现异常? [ ^ ] - 它的代码在C#中不是VB,但它非常清晰,非常非常适用!
The chances are that it's not that code - which looks fine - but the way you save the data to your DB instead.
Have a look at this: Why do I get a "Parameter is not valid." exception when I read an image from my database?[^] - it's code is in C# not VB, but it is pretty clear, and very, very applicable!
这篇关于将字节数组转换为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文