From 0c1ce8b4d7a202dbe86febaa8a26237d671d82c3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Oct 2025 23:16:21 +0000 Subject: [PATCH 1/4] Initial plan From dc945d57c3c2af10b7e5f722f2c2c880223c91b4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Oct 2025 23:20:15 +0000 Subject: [PATCH 2/4] Select largest frame when loading .ico files for MainImage preview Co-authored-by: TheJoeFin <7809853+TheJoeFin@users.noreply.github.com> --- .../Views/MainPage.xaml.cs | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Simple Icon File Maker/Simple Icon File Maker/Views/MainPage.xaml.cs b/Simple Icon File Maker/Simple Icon File Maker/Views/MainPage.xaml.cs index 4d59356..03d39be 100644 --- a/Simple Icon File Maker/Simple Icon File Maker/Views/MainPage.xaml.cs +++ b/Simple Icon File Maker/Simple Icon File Maker/Views/MainPage.xaml.cs @@ -278,7 +278,31 @@ private async Task LoadFromImagePath() try { - MagickImage image = new(ImagePath); + MagickImage image; + // For .ico files, load the largest frame instead of the first one + if (Path.GetExtension(ImagePath).Equals(".ico", StringComparison.InvariantCultureIgnoreCase)) + { + MagickImageCollection collection = new(ImagePath); + // Find the largest frame by area (width * height) + MagickImage? largestFrame = collection.Cast() + .OrderByDescending(img => (int)img.Width * (int)img.Height) + .FirstOrDefault(); + + if (largestFrame != null) + { + // Create a new image from the largest frame to avoid disposal issues + image = (MagickImage)largestFrame.Clone(); + } + else + { + // Fallback to the first frame if something goes wrong + image = new(ImagePath); + } + } + else + { + image = new(ImagePath); + } MainImage.Source = image.ToImageSource(); } catch (Exception ex) From 1c660c7bf0c74d01bea31b8d5dab039aed471fc7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Oct 2025 23:21:55 +0000 Subject: [PATCH 3/4] Add NearestNeighbor upscaling for images smaller than 512px Co-authored-by: TheJoeFin <7809853+TheJoeFin@users.noreply.github.com> --- .../Simple Icon File Maker/Views/MainPage.xaml.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Simple Icon File Maker/Simple Icon File Maker/Views/MainPage.xaml.cs b/Simple Icon File Maker/Simple Icon File Maker/Views/MainPage.xaml.cs index 03d39be..166a00b 100644 --- a/Simple Icon File Maker/Simple Icon File Maker/Views/MainPage.xaml.cs +++ b/Simple Icon File Maker/Simple Icon File Maker/Views/MainPage.xaml.cs @@ -303,6 +303,18 @@ private async Task LoadFromImagePath() { image = new(ImagePath); } + + // If the image is smaller than 512px, scale it up using NearestNeighbor + // to maintain sharp pixels when displayed + int smallerDimension = (int)Math.Min(image.Width, image.Height); + if (smallerDimension < 512 && smallerDimension > 0) + { + // Scale up to 512px using NearestNeighbor (point sampling) to keep pixels sharp + int targetSize = 512; + image.FilterType = FilterType.Point; // Point filter = NearestNeighbor + image.Resize(targetSize, targetSize); + } + MainImage.Source = image.ToImageSource(); } catch (Exception ex) From f8dea3749a0e954eadbc25e4edb4848c4b74f4c2 Mon Sep 17 00:00:00 2001 From: Joe Finney Date: Thu, 23 Oct 2025 21:52:19 -0500 Subject: [PATCH 4/4] Cast to uint for image --- .../Simple Icon File Maker/Views/MainPage.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simple Icon File Maker/Simple Icon File Maker/Views/MainPage.xaml.cs b/Simple Icon File Maker/Simple Icon File Maker/Views/MainPage.xaml.cs index 166a00b..adf37b3 100644 --- a/Simple Icon File Maker/Simple Icon File Maker/Views/MainPage.xaml.cs +++ b/Simple Icon File Maker/Simple Icon File Maker/Views/MainPage.xaml.cs @@ -312,7 +312,7 @@ private async Task LoadFromImagePath() // Scale up to 512px using NearestNeighbor (point sampling) to keep pixels sharp int targetSize = 512; image.FilterType = FilterType.Point; // Point filter = NearestNeighbor - image.Resize(targetSize, targetSize); + image.Resize((uint)targetSize, (uint)targetSize); } MainImage.Source = image.ToImageSource();