@@ -1095,25 +1095,28 @@ private async Task<bool> LoadThumbnailAsync(ListedItem item, IStorageItem matchi
10951095 var thumbnailSize = LayoutSizeKindHelper . GetIconSize ( folderSettings . LayoutMode ) ;
10961096 // SingleItem returns image thumbnails in the correct aspect ratio for the grid layouts
10971097 // ListView is used for the details and columns layout
1098- var thumbnailMode = thumbnailSize < 96 ? ThumbnailMode . ListView : ThumbnailMode . SingleItem ;
1099-
11001098 // We use ReturnOnlyIfCached because otherwise folders thumbnails have a black background, this has the downside the folder previews don't work
1101- using StorageItemThumbnail thumbnail = matchingStorageItem switch
1099+ var ( thumbnailMode , thumbnailOptions ) = matchingStorageItem switch
11021100 {
1103- BaseStorageFile file => await FilesystemTasks . Wrap ( ( ) => file . GetThumbnailAsync ( thumbnailMode , thumbnailSize , ThumbnailOptions . ResizeThumbnail ) . AsTask ( ) ) ,
1104- BaseStorageFolder folder => await FilesystemTasks . Wrap ( ( ) => folder . GetThumbnailAsync ( ThumbnailMode . SingleItem , thumbnailSize , ThumbnailOptions . ReturnOnlyIfCached ) . AsTask ( ) ) ,
1105- _ => new ( null ! , FileSystemStatusCode . Generic )
1101+ BaseStorageFolder => ( ThumbnailMode . SingleItem , ThumbnailOptions . ReturnOnlyIfCached ) ,
1102+ BaseStorageFile when thumbnailSize < 96 => ( ThumbnailMode . ListView , ThumbnailOptions . ResizeThumbnail ) ,
1103+ _ => ( ThumbnailMode . SingleItem , ThumbnailOptions . ResizeThumbnail ) ,
11061104 } ;
11071105
1108- if ( thumbnail is not null && thumbnail . Size != 0 && thumbnail . OriginalHeight != 0 && thumbnail . OriginalWidth != 0 )
1106+ var result = await FileThumbnailHelper . GetIconAsync (
1107+ matchingStorageItem ,
1108+ thumbnailSize ,
1109+ thumbnailMode ,
1110+ thumbnailOptions ) ;
1111+
1112+ if ( result is not null )
11091113 {
11101114 await dispatcherQueue . EnqueueOrInvokeAsync ( async ( ) =>
11111115 {
1112- var img = new BitmapImage ( ) ;
1113- img . DecodePixelType = DecodePixelType . Logical ;
1114- img . DecodePixelWidth = ( int ) thumbnailSize ;
1115- await img . SetSourceAsync ( thumbnail ) ;
1116- item . FileImage = img ;
1116+ // Assign FileImage property
1117+ var image = await result . ToBitmapAsync ( ) ;
1118+ if ( image is not null )
1119+ item . FileImage = image ;
11171120 } , Microsoft . UI . Dispatching . DispatcherQueuePriority . Normal ) ;
11181121
11191122 return true ;
0 commit comments