From 0ab82de704e14690b3b1c55b8ed88e224d54da62 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Mon, 31 Oct 2022 20:03:34 +0800 Subject: [PATCH] Try to find logo closest to 44x44 --- .../Flow.Launcher.Plugin.Program/Programs/UWP.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs index 3d8b6a2f0..8ad13691c 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs @@ -644,7 +644,8 @@ namespace Flow.Launcher.Plugin.Program.Programs ); var selected = logos.FirstOrDefault(); - + var closest = selected; + int min = int.MaxValue; foreach(var logo in logos) { @@ -652,13 +653,18 @@ namespace Flow.Launcher.Plugin.Program.Programs var decoder = BitmapDecoder.Create(imageStream, BitmapCreateOptions.IgnoreColorProfile, BitmapCacheOption.None); var height = decoder.Frames[0].PixelHeight; var width = decoder.Frames[0].PixelWidth; - if(height == 44 && width == 44) + int pixelCountDiff = Math.Abs(height * width - 1936); // 44*44=1936 + if(pixelCountDiff < min) { - selected = logo; - break; + // try to find the closest to 44x44 logo + closest = logo; + if (pixelCountDiff == 0) + break; // found 44x44 + min = pixelCountDiff; } } + selected = closest; if (!string.IsNullOrEmpty(selected)) { return selected;