Skip to content

Commit

Permalink
[Peek]Expand image format support for Image Previewer using local cap…
Browse files Browse the repository at this point in the history
…abilities (#35622)

* Use BitmapDecoder to query compatible file extensions.

* Delete spellcheck exceptions for removed file types

* Remove unused usings.
  • Loading branch information
daverayment authored Nov 22, 2024
1 parent 40acdea commit b81478e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 90 deletions.
24 changes: 3 additions & 21 deletions .github/actions/spell-check/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,9 @@ AQS
ARandom
ARCHITEW
ARemapped
ari
ARPINSTALLLOCATION
ARPPRODUCTICON
ARRAYSIZE
arw
asf
AShortcut
ASingle
Expand Down Expand Up @@ -261,7 +259,6 @@ critsec
Crossdevice
CRSEL
crx
crw
CSearch
CSettings
cso
Expand Down Expand Up @@ -303,8 +300,8 @@ DCOM
dcommon
dcomp
DComposition
dcr
dcs
DCR
DCs
ddd
DDEIf
DDevice
Expand Down Expand Up @@ -374,7 +371,6 @@ DRAWCLIPBOARD
DRAWFRAME
drawingcolor
dreamsofameaningfullife
drf
drivedetectionwarning
dshow
DSTINVERT
Expand Down Expand Up @@ -418,7 +414,6 @@ editkeyboardwindow
EDITSHORTCUTS
editshortcutswindow
EFile
eip
ekus
emmintrin
Emoji
Expand Down Expand Up @@ -592,7 +587,7 @@ Hiberboot
HIBYTE
hicon
HIDEWINDOW
hif
Hif
HIMAGELIST
himl
hinst
Expand Down Expand Up @@ -668,7 +663,6 @@ IGNOREUNKNOWN
IGraphics
iid
Iindex
iiq
IJson
Ijwhost
IKs
Expand Down Expand Up @@ -739,10 +733,8 @@ IWeb
IWIC
iwr
IYUV
jfi
jfif
jgeosdfsdsgmkedfgdfgdfgbkmhcgcflmi
jif
jjw
jobject
jpe
Expand All @@ -751,7 +743,6 @@ Jsons
jsonval
junja
jxr
kdc
keybd
KEYBDDATA
KEYBDINPUT
Expand Down Expand Up @@ -876,15 +867,13 @@ MAXIMIZEBOX
MAXSHORTCUTSIZE
maxversiontested
MBR
mdc
MDICHILD
MDL
mdtext
mdtxt
mdwn
MEDIASUBTYPE
mediatype
mef
MENUITEMINFO
MENUITEMINFOW
MERGECOPY
Expand Down Expand Up @@ -942,7 +931,6 @@ mpmc
MRM
MRT
mru
mrw
msc
mscorlib
msdata
Expand Down Expand Up @@ -1065,7 +1053,6 @@ NOZORDER
NPH
npmjs
NResize
nrw
nsunt
NTAPI
ntdll
Expand Down Expand Up @@ -1095,7 +1082,6 @@ opensource
openxmlformats
OPTIMIZEFORINVOKE
ORAW
ori
ORPHANEDDIALOGTITLE
ORSCANS
oss
Expand Down Expand Up @@ -1274,7 +1260,6 @@ QUERYENDSESSION
QUERYOPEN
QUEUESYNC
QUNS
raf
RAII
RAlt
Rasterize
Expand Down Expand Up @@ -1378,8 +1363,6 @@ runtimes
ruuid
rvm
rwin
rwl
rwz
sacl
safeprojectname
SAMEKEYPREVIOUSLYMAPPED
Expand Down Expand Up @@ -1513,7 +1496,6 @@ Srch
SRCINVERT
SRCPAINT
SResize
srf
srme
srre
srw
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

Expand All @@ -22,6 +23,7 @@
using Peek.FilePreviewer.Previewers.Helpers;
using Peek.FilePreviewer.Previewers.Interfaces;
using Windows.Foundation;
using Windows.Graphics.Imaging;

namespace Peek.FilePreviewer.Previewers
{
Expand Down Expand Up @@ -58,6 +60,12 @@ public ImagePreviewer(IFileSystemItem file)

private DispatcherQueue Dispatcher { get; }

private static readonly HashSet<string> _supportedFileTypes =
BitmapDecoder.GetDecoderInformationEnumerator()
.SelectMany(di => di.FileExtensions)
.Union([".svg", ".qoi"])
.ToHashSet(StringComparer.OrdinalIgnoreCase);

public static bool IsItemSupported(IFileSystemItem item)
{
return _supportedFileTypes.Contains(item.Extension);
Expand Down Expand Up @@ -199,74 +207,5 @@ await Dispatcher.RunOnUiThread(async () =>
});
});
}

private static readonly HashSet<string> _supportedFileTypes = new HashSet<string>
{
// 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",
};
}
}

0 comments on commit b81478e

Please sign in to comment.