Skip to content

Commit db9f38f

Browse files
authored
Fix: Improve sharpness of thumbnail previews (#10105)
1 parent 88d5ef3 commit db9f38f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Files.App/ViewModels/ItemViewModel.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,12 @@ private async Task LoadItemThumbnail(ListedItem item, uint thumbnailSize = 80, I
952952
// ListView is used for the details and columns layout
953953
var thumbnailMode = thumbnailSize < 80 ? ThumbnailMode.ListView : ThumbnailMode.SingleItem;
954954

955-
using StorageItemThumbnail Thumbnail = await FilesystemTasks.Wrap(() => matchingStorageFile.GetThumbnailAsync(thumbnailMode, thumbnailSize, ThumbnailOptions.ResizeThumbnail).AsTask());
955+
// ReturnOnlyIfCached forces the thumbnail to be cached before it's returned,
956+
// this prevents an issue where the user needs to refresh the current directory.
957+
// UseCurrentScale returns a sharp image
958+
var thumbnailOptions = ThumbnailOptions.ReturnOnlyIfCached | ThumbnailOptions.UseCurrentScale;
959+
960+
using StorageItemThumbnail Thumbnail = await FilesystemTasks.Wrap(() => matchingStorageFile.GetThumbnailAsync(thumbnailMode, thumbnailSize, thumbnailOptions).AsTask());
956961

957962
if (!(Thumbnail == null || Thumbnail.Size == 0 || Thumbnail.OriginalHeight == 0 || Thumbnail.OriginalWidth == 0))
958963
{

0 commit comments

Comments
 (0)