Skip to content

Commit 0ab82de

Browse files
Try to find logo closest to 44x44
1 parent 3af296e commit 0ab82de

File tree

1 file changed

+10
-4
lines changed
  • Plugins/Flow.Launcher.Plugin.Program/Programs

1 file changed

+10
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -644,21 +644,27 @@ string TryToFindLogo(string uri, string path)
644644
);
645645

646646
var selected = logos.FirstOrDefault();
647-
647+
var closest = selected;
648+
int min = int.MaxValue;
648649
foreach(var logo in logos)
649650
{
650651

651652
var imageStream = File.OpenRead(logo);
652653
var decoder = BitmapDecoder.Create(imageStream, BitmapCreateOptions.IgnoreColorProfile, BitmapCacheOption.None);
653654
var height = decoder.Frames[0].PixelHeight;
654655
var width = decoder.Frames[0].PixelWidth;
655-
if(height == 44 && width == 44)
656+
int pixelCountDiff = Math.Abs(height * width - 1936); // 44*44=1936
657+
if(pixelCountDiff < min)
656658
{
657-
selected = logo;
658-
break;
659+
// try to find the closest to 44x44 logo
660+
closest = logo;
661+
if (pixelCountDiff == 0)
662+
break; // found 44x44
663+
min = pixelCountDiff;
659664
}
660665
}
661666

667+
selected = closest;
662668
if (!string.IsNullOrEmpty(selected))
663669
{
664670
return selected;

0 commit comments

Comments
 (0)