fix: 不使用磁盘缓存
This commit is contained in:
@@ -64,13 +64,14 @@ Public Class MyBitmap
|
||||
BitmapCache.Add(FilePathOrResourceName, Pic)
|
||||
End If
|
||||
Else
|
||||
Dim InputStream As Stream
|
||||
If FilePathOrResourceName.StartsWithF("http") Then '在线图片(这里判断 https:\\ 或 http:\\ 会出问题)
|
||||
Dim tempFile = PathTemp & "Cache\MyImage\" & GetHash(FilePathOrResourceName)
|
||||
NetDownload(FilePathOrResourceName, tempFile, True)
|
||||
FilePathOrResourceName = tempFile
|
||||
Dim Client = New Net.WebClient()
|
||||
InputStream = New MemoryStream(Client.DownloadData(FilePathOrResourceName))
|
||||
Else
|
||||
InputStream = New MemoryStream(File.ReadAllBytes(FilePathOrResourceName))
|
||||
End If
|
||||
'使用这种自己接管 FileStream 的方法加载才能解除文件占用
|
||||
Using InputStream As New FileStream(FilePathOrResourceName, FileMode.Open)
|
||||
'判断是否为 WebP 文件头
|
||||
Dim Header(1) As Byte
|
||||
InputStream.Read(Header, 0, 2)
|
||||
@@ -85,7 +86,6 @@ Public Class MyBitmap
|
||||
Else
|
||||
Pic = New System.Drawing.Bitmap(InputStream)
|
||||
End If
|
||||
End Using
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Pic = My.Application.TryFindResource(FilePathOrResourceName)
|
||||
|
||||
Reference in New Issue
Block a user