好的,我有一个图像,我在其中绑定了信息,我想读取信息
现在从文件(FileStream)它的工作
但我想做它不是从文件,所以我需要使用MemoryStream
下面是工作的例子,以及我现在如何使用MemoryStream(byte=My.Resources或PictureBox1.image)
Using FS As New IO.FileStream(image, IO.FileMode.Open)
FS.Seek(0, IO.SeekOrigin.End)
While Not FS.ReadByte = Asc("|")
FS.Position -= 2
End While
Dim s As String = Nothing
While Not FS.Position = FS.Length - 4
s &= Chr(FS.ReadByte.ToString)
End While
Dim Ext As String = Nothing
FS.Seek(0, IO.SeekOrigin.End)
While Not FS.ReadByte = Asc("*")
FS.Position -= 2
End While
While Not FS.Position = FS.Length
Ext &= Chr(FS.ReadByte.ToString)
End While
FS.Seek(FS.Length - ((s.Length + s) + 5), IO.SeekOrigin.Begin)
While Not FS.Position = FS.Length - (s.Length + 5)
Dim Data As Byte() = New Byte(FS.Position) {}
FS.Read(Data, 0, Data.Length)
FS.Close()
End While
最后将字节保存到文件
我试着像这个一样使用它
使用FS作为新IO.MemoryStream(image)'image=字节()
但不工作
我该怎么做在内存中再次读取
感谢
这将把ByteArray转换为MemoryStream再转换为Image
Public Function byteArrayToImage(byteArrayIn As Byte()) As Image
Dim ms As New MemoryStream(byteArrayIn)
Dim returnImage As Image = Image.FromStream(ms)
Return returnImage
End Function