Revert MyBitmap.vb

This commit is contained in:
tangge233
2024-10-08 23:30:45 +08:00
parent 788f7c9a96
commit e6c1b192ce
@@ -64,14 +64,8 @@ Public Class MyBitmap
BitmapCache.Add(FilePathOrResourceName, Pic) BitmapCache.Add(FilePathOrResourceName, Pic)
End If End If
Else Else
Dim InputStream As Stream
If FilePathOrResourceName.StartsWithF("http") Then '在线图片(这里判断 https:\\ 或 http:\\ 会出问题)
Dim Client = New Net.WebClient()
InputStream = New MemoryStream(Client.DownloadData(FilePathOrResourceName))
Else
InputStream = New MemoryStream(File.ReadAllBytes(FilePathOrResourceName))
End If
'使用这种自己接管 FileStream 的方法加载才能解除文件占用 '使用这种自己接管 FileStream 的方法加载才能解除文件占用
Using InputStream As New FileStream(FilePathOrResourceName, FileMode.Open)
'判断是否为 WebP 文件头 '判断是否为 WebP 文件头
Dim Header(1) As Byte Dim Header(1) As Byte
InputStream.Read(Header, 0, 2) InputStream.Read(Header, 0, 2)
@@ -86,6 +80,7 @@ Public Class MyBitmap
Else Else
Pic = New System.Drawing.Bitmap(InputStream) Pic = New System.Drawing.Bitmap(InputStream)
End If End If
End Using
End If End If
Catch ex As Exception Catch ex As Exception
Pic = My.Application.TryFindResource(FilePathOrResourceName) Pic = My.Application.TryFindResource(FilePathOrResourceName)