Skip to content

Commit

Permalink
Push
Browse files Browse the repository at this point in the history
  • Loading branch information
TopazTK committed Mar 24, 2021
1 parent 6f2b1a1 commit 773195b
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions OpenKh.Tools.ModsManager/ViewModels/ModViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,22 +202,24 @@ private static void LoadImage(string source, string fallback, Action<ImageSource

try
{
var uri = new Uri(source);
if (uri.Scheme == "file" && !File.Exists(uri.AbsolutePath))
if (!File.Exists(source))
{
if (!string.IsNullOrEmpty(fallback))
LoadImage(fallback, null, setter);
return;
}

var bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.UriSource = uri;
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.EndInit();
bitmapImage.Freeze();

Application.Current.Dispatcher.Invoke(() => setter(bitmapImage));
using (var fs = new FileStream(source, FileMode.Open))
{
var bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.StreamSource = fs;
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.EndInit();
bitmapImage.Freeze();

Application.Current.Dispatcher.Invoke(() => setter(bitmapImage));
}
}
catch
{
Expand Down

0 comments on commit 773195b

Please sign in to comment.