Skip to content

Commit

Permalink
[AdvancedPaste]Add all BitmapDecoder supported image filetypes to Ima…
Browse files Browse the repository at this point in the history
…geToText (#35600)

Adds support to ImageToText for all image filetypes supported by BitmapDecoder.
  • Loading branch information
daverayment authored Jan 13, 2025
1 parent 3ae3659 commit a665975
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace AdvancedPaste.Helpers;

internal static class DataPackageHelpers
{
private static readonly HashSet<string> ImageFileTypes = new(StringComparer.InvariantCultureIgnoreCase) { ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".ico", ".svg" };
private static readonly Lazy<HashSet<string>> ImageFileTypes = new(GetImageFileTypes());

private static readonly (string DataFormat, ClipboardFormat ClipboardFormat)[] DataFormats =
[
Expand Down Expand Up @@ -57,7 +57,7 @@ internal static async Task<ClipboardFormat> GetAvailableFormatsAsync(this DataPa
{
availableFormats |= ClipboardFormat.File;

if (ImageFileTypes.Contains(file.FileType))
if (ImageFileTypes.Value.Contains(file.FileType))
{
availableFormats |= ClipboardFormat.Image;
}
Expand Down Expand Up @@ -148,4 +148,9 @@ private static async Task<IRandomAccessStream> GetImageStreamAsync(this DataPack

return null;
}

private static HashSet<string> GetImageFileTypes() =>
BitmapDecoder.GetDecoderInformationEnumerator()
.SelectMany(di => di.FileExtensions)
.ToHashSet(StringComparer.InvariantCultureIgnoreCase);
}

0 comments on commit a665975

Please sign in to comment.