Skip to content

Commit 3af296e

Browse files
Try to get 44x44 logo
1 parent 8ac873b commit 3af296e

File tree

1 file changed

+21
-5
lines changed
  • Plugins/Flow.Launcher.Plugin.Program/Programs

1 file changed

+21
-5
lines changed

Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -618,10 +618,10 @@ string TryToFindLogo(string uri, string path)
618618
var extension = Path.GetExtension(path);
619619
if (extension != null)
620620
{
621-
if (File.Exists(path))
622-
{
623-
return path; // shortcut, avoid enumerating files
624-
}
621+
//if (File.Exists(path))
622+
//{
623+
// return path; // shortcut, avoid enumerating files
624+
//}
625625

626626
var logoNamePrefix = Path.GetFileNameWithoutExtension(uri); // e.g Square44x44
627627
var logoDir = Path.GetDirectoryName(path); // e.g ..\..\Assets
@@ -639,10 +639,26 @@ string TryToFindLogo(string uri, string path)
639639
// Just ignore all qualifiers
640640
// select like logo.[xxx_yyy].png
641641
// https://learn.microsoft.com/en-us/windows/uwp/app-resources/tailor-resources-lang-scale-contrast
642-
var selected = files.FirstOrDefault(file =>
642+
var logos = files.Where(file =>
643643
Path.GetFileName(file).StartsWith(logoNamePrefix) && extension == Path.GetExtension(file)
644644
);
645645

646+
var selected = logos.FirstOrDefault();
647+
648+
foreach(var logo in logos)
649+
{
650+
651+
var imageStream = File.OpenRead(logo);
652+
var decoder = BitmapDecoder.Create(imageStream, BitmapCreateOptions.IgnoreColorProfile, BitmapCacheOption.None);
653+
var height = decoder.Frames[0].PixelHeight;
654+
var width = decoder.Frames[0].PixelWidth;
655+
if(height == 44 && width == 44)
656+
{
657+
selected = logo;
658+
break;
659+
}
660+
}
661+
646662
if (!string.IsNullOrEmpty(selected))
647663
{
648664
return selected;

0 commit comments

Comments
 (0)