Read MemoryStream - 加载图像\字节并读取它
好的,我有一个在其中绑定信息的图像,我想
现在从文件(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
最后将字节保存到文件
我尝试像这样使用它
Using FS As New IO.MemoryStream(image) 'image = byte( )
但不是工作
我该怎么做,在记忆中再读一遍,
谢谢
ok i have image that i bind info in it and i want to read the info
now from file (FileStream) its work
but i want to do it not from file so i need to use MemoryStream
here the example that work and how i do it now how i make it work with MemoryStream (with byte = My.Resources or 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
at the end save the byte to file
i try to use it like this
Using FS As New IO.MemoryStream(image) 'image = byte()
but not work
how i can do it read it again in memory
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这会将 ByteArray 转换为 MemoryStream 再转换为 Image
This will convert a ByteArray to MemoryStream to Image