Skip to content

Commit 23bbc8c

Browse files
committed
show image from stream block
1 parent 6490907 commit 23bbc8c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Data/BinaryData/HDSPack/Extensions.vb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,16 @@ Public Module Extensions
139139
Return New StreamReader(pack.OpenBlock(file), encoding.CodePage).ReadToEnd
140140
End Function
141141

142+
<Extension>
143+
Public Function LoadStream(pack As StreamPack, file As StreamBlock) As MemoryStream
144+
Dim s As Stream = pack.OpenBlock(file)
145+
Dim ms As New MemoryStream
146+
Call s.CopyTo(ms)
147+
Call ms.Flush()
148+
Call ms.Seek(Scan0, SeekOrigin.Begin)
149+
Return ms
150+
End Function
151+
142152
''' <summary>
143153
''' Get in-memory stream buffer data from the archive
144154
''' </summary>
@@ -154,11 +164,7 @@ Public Module Extensions
154164
If pack.GetObject(filename) Is Nothing Then
155165
Return Nothing
156166
Else
157-
Dim s As Stream = pack.OpenBlock(filename)
158-
Dim ms As New MemoryStream
159-
Call s.CopyTo(ms)
160-
Call ms.Flush()
161-
Return ms
167+
Return pack.LoadStream(pack.GetObject(filename))
162168
End If
163169
End Function
164170
End Module

0 commit comments

Comments
 (0)