DeflateStream 解压数据时重复字节
我遇到了 DeflateStream 的问题——一些数据被重复写入,直到最后。
这是代码:
Dim bytesin As Byte() = ... ' An array of compressed bytes
Dim bytesout As Byte()
Dim count As Integer
Using ms As New MemoryStream(bytesin)
Using ds As New Compression.DeflateStream(ms, Compression.CompressionMode.Decompress)
Using outputStream As New MemoryStream()
Dim buffer As Byte() = New Byte(1024) {}
While InlineAssignHelper(count, ds.Read(buffer, 0, buffer.Length)) > 0
outputStream.Write(buffer, 0, count)
End While
bytesout = outputStream.ToArray
End Using
End Using
End Using
Dim fs As FileStream = File.OpenWrite("fws.swf")
fs.Write(bytesout, 0, bytesout.Length)
fs.Flush()
fs.Close()
Private Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T
target = value
Return value
End Function
你如何解释这一点?
https://i.sstatic.net/d2ffF.png
更新
我尝试使用 Ionic.Zlib.ZlibStream 和 Ionic.Zlib.DeflateStream ,但得到了同样奇怪的结果。
I have encountered a problem with DeflateStream -- some of the data is being written repeatedly, to the end.
Here is the code:
Dim bytesin As Byte() = ... ' An array of compressed bytes
Dim bytesout As Byte()
Dim count As Integer
Using ms As New MemoryStream(bytesin)
Using ds As New Compression.DeflateStream(ms, Compression.CompressionMode.Decompress)
Using outputStream As New MemoryStream()
Dim buffer As Byte() = New Byte(1024) {}
While InlineAssignHelper(count, ds.Read(buffer, 0, buffer.Length)) > 0
outputStream.Write(buffer, 0, count)
End While
bytesout = outputStream.ToArray
End Using
End Using
End Using
Dim fs As FileStream = File.OpenWrite("fws.swf")
fs.Write(bytesout, 0, bytesout.Length)
fs.Flush()
fs.Close()
Private Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T
target = value
Return value
End Function
How could you explain this?
https://i.sstatic.net/d2ffF.png
UPDATE
I tried with Ionic.Zlib.ZlibStream and Ionic.Zlib.DeflateStream and I have got the same strange result.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论