From b81478eb972d0b3c5252b0bc0034915afaf091f9 Mon Sep 17 00:00:00 2001 From: Dave Rayment Date: Fri, 22 Nov 2024 14:49:35 +0000 Subject: [PATCH] [Peek]Expand image format support for Image Previewer using local capabilities (#35622) * Use BitmapDecoder to query compatible file extensions. * Delete spellcheck exceptions for removed file types * Remove unused usings. --- .github/actions/spell-check/expect.txt | 24 +----- .../MediaPreviewer/ImagePreviewer.cs | 77 ++----------------- 2 files changed, 11 insertions(+), 90 deletions(-) diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index d7ca1f84fe..5a8c5e280c 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -69,11 +69,9 @@ AQS ARandom ARCHITEW ARemapped -ari ARPINSTALLLOCATION ARPPRODUCTICON ARRAYSIZE -arw asf AShortcut ASingle @@ -261,7 +259,6 @@ critsec Crossdevice CRSEL crx -crw CSearch CSettings cso @@ -303,8 +300,8 @@ DCOM dcommon dcomp DComposition -dcr -dcs +DCR +DCs ddd DDEIf DDevice @@ -374,7 +371,6 @@ DRAWCLIPBOARD DRAWFRAME drawingcolor dreamsofameaningfullife -drf drivedetectionwarning dshow DSTINVERT @@ -418,7 +414,6 @@ editkeyboardwindow EDITSHORTCUTS editshortcutswindow EFile -eip ekus emmintrin Emoji @@ -592,7 +587,7 @@ Hiberboot HIBYTE hicon HIDEWINDOW -hif +Hif HIMAGELIST himl hinst @@ -668,7 +663,6 @@ IGNOREUNKNOWN IGraphics iid Iindex -iiq IJson Ijwhost IKs @@ -739,10 +733,8 @@ IWeb IWIC iwr IYUV -jfi jfif jgeosdfsdsgmkedfgdfgdfgbkmhcgcflmi -jif jjw jobject jpe @@ -751,7 +743,6 @@ Jsons jsonval junja jxr -kdc keybd KEYBDDATA KEYBDINPUT @@ -876,7 +867,6 @@ MAXIMIZEBOX MAXSHORTCUTSIZE maxversiontested MBR -mdc MDICHILD MDL mdtext @@ -884,7 +874,6 @@ mdtxt mdwn MEDIASUBTYPE mediatype -mef MENUITEMINFO MENUITEMINFOW MERGECOPY @@ -942,7 +931,6 @@ mpmc MRM MRT mru -mrw msc mscorlib msdata @@ -1065,7 +1053,6 @@ NOZORDER NPH npmjs NResize -nrw nsunt NTAPI ntdll @@ -1095,7 +1082,6 @@ opensource openxmlformats OPTIMIZEFORINVOKE ORAW -ori ORPHANEDDIALOGTITLE ORSCANS oss @@ -1274,7 +1260,6 @@ QUERYENDSESSION QUERYOPEN QUEUESYNC QUNS -raf RAII RAlt Rasterize @@ -1378,8 +1363,6 @@ runtimes ruuid rvm rwin -rwl -rwz sacl safeprojectname SAMEKEYPREVIOUSLYMAPPED @@ -1513,7 +1496,6 @@ Srch SRCINVERT SRCPAINT SResize -srf srme srre srw diff --git a/src/modules/peek/Peek.FilePreviewer/Previewers/MediaPreviewer/ImagePreviewer.cs b/src/modules/peek/Peek.FilePreviewer/Previewers/MediaPreviewer/ImagePreviewer.cs index 9698e43f5a..47e488c4d3 100644 --- a/src/modules/peek/Peek.FilePreviewer/Previewers/MediaPreviewer/ImagePreviewer.cs +++ b/src/modules/peek/Peek.FilePreviewer/Previewers/MediaPreviewer/ImagePreviewer.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -22,6 +23,7 @@ using Peek.FilePreviewer.Models; using Peek.FilePreviewer.Previewers.Helpers; using Peek.FilePreviewer.Previewers.Interfaces; using Windows.Foundation; +using Windows.Graphics.Imaging; namespace Peek.FilePreviewer.Previewers { @@ -58,6 +60,12 @@ namespace Peek.FilePreviewer.Previewers private DispatcherQueue Dispatcher { get; } + private static readonly HashSet _supportedFileTypes = + BitmapDecoder.GetDecoderInformationEnumerator() + .SelectMany(di => di.FileExtensions) + .Union([".svg", ".qoi"]) + .ToHashSet(StringComparer.OrdinalIgnoreCase); + public static bool IsItemSupported(IFileSystemItem item) { return _supportedFileTypes.Contains(item.Extension); @@ -199,74 +207,5 @@ namespace Peek.FilePreviewer.Previewers }); }); } - - private static readonly HashSet _supportedFileTypes = new HashSet - { - // Image types - ".bmp", - ".gif", - ".jpg", - ".jfif", - ".jfi", - ".jif", - ".jpeg", - ".jpe", - ".png", - ".tif", // very slow for large files: no thumbnail? - ".tiff", // NEED TO TEST - ".dib", // NEED TO TEST - ".heic", - ".heif", - ".hif", // NEED TO TEST - ".avif", // NEED TO TEST - ".jxr", - ".wdp", - ".ico", // NEED TO TEST - ".thumb", // NEED TO TEST - ".webp", - - // Raw types - ".arw", - ".cr2", - ".crw", - ".erf", - ".kdc", // NEED TO TEST - ".mrw", - ".nef", - ".nrw", - ".orf", - ".pef", - ".raf", - ".raw", - ".rw2", - ".rwl", - ".sr2", - ".srw", - ".srf", - ".dcs", // NEED TO TEST - ".dcr", - ".drf", // NEED TO TEST - ".k25", - ".3fr", - ".ari", // NEED TO TEST - ".bay", // NEED TO TEST - ".cap", // NEED TO TEST - ".iiq", - ".eip", // NEED TO TEST - ".fff", - ".mef", - - // ".mdc", // Crashes in GetFullBitmapFromPathAsync - ".mos", - ".R3D", - ".rwz", // NEED TO TEST - ".x3f", - ".ori", - ".cr3", - - ".svg", - - ".qoi", - }; } }