Load large Thumbnail when load full image

This commit is contained in:
Hongtao Zhang 2022-11-25 13:51:07 -06:00
parent 65d4aeddea
commit 250627a27a
No known key found for this signature in database
GPG key ID: 75F655B91C7AC9BB
2 changed files with 7 additions and 9 deletions

View file

@ -23,6 +23,7 @@ namespace Flow.Launcher.Infrastructure.Image
private static readonly bool EnableImageHash = true;
public static ImageSource DefaultImage { get; } = new BitmapImage(new Uri(Constant.MissingImgIcon));
public const int SmallIconSize = 32;
public const int FullIconSize = 256;
private static readonly string[] ImageExtensions =
@ -217,7 +218,7 @@ namespace Flow.Launcher.Infrastructure.Image
else
{
type = ImageType.File;
image = GetThumbnail(path, ThumbnailOptions.None);
image = GetThumbnail(path, ThumbnailOptions.None, loadFullImage ? FullIconSize : SmallIconSize);
}
}
else
@ -234,12 +235,12 @@ namespace Flow.Launcher.Infrastructure.Image
return new ImageResult(image, type);
}
private static BitmapSource GetThumbnail(string path, ThumbnailOptions option = ThumbnailOptions.ThumbnailOnly)
private static BitmapSource GetThumbnail(string path, ThumbnailOptions option = ThumbnailOptions.ThumbnailOnly, int size = SmallIconSize)
{
return WindowsThumbnailProvider.GetThumbnail(
path,
Constant.ThumbnailSize,
Constant.ThumbnailSize,
size,
size,
option);
}

View file

@ -199,13 +199,10 @@ namespace Flow.Launcher.ViewModel
}
private async ValueTask LoadPreviewImageAsync()
private async Task LoadPreviewImageAsync()
{
var imagePath = Result.PreviewImage ?? Result.IcoPath;
var loadFullImage = (Path.GetExtension(imagePath) ?? "").Equals(".url", StringComparison.OrdinalIgnoreCase);
// We need to modify the property not field here to trigger the OnPropertyChanged event
//PreviewImage = await Task.Run(() => ImageLoader.Load(imagePath, true)).ConfigureAwait(false);
PreviewImage = await ImageLoader.LoadAsync(imagePath, loadFullImage).ConfigureAwait(false);
PreviewImage = await ImageLoader.LoadAsync(imagePath, true).ConfigureAwait(false);
}
public Result Result { get; }