From 694aa867ec5f73ea42910bd01f6ee67164140cd0 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Thu, 26 Dec 2024 00:56:16 +1000 Subject: [PATCH] Fix artifacting on firmware status icons under Mono --- src/BizHawk.Client.EmuHawk/FormBase.cs | 10 ++++++++++ src/BizHawk.Client.EmuHawk/config/FirmwareConfig.cs | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/BizHawk.Client.EmuHawk/FormBase.cs b/src/BizHawk.Client.EmuHawk/FormBase.cs index a0ca4c8b31e..e1220576230 100644 --- a/src/BizHawk.Client.EmuHawk/FormBase.cs +++ b/src/BizHawk.Client.EmuHawk/FormBase.cs @@ -13,6 +13,16 @@ public class FormBase : Form { private const string PLACEHOLDER_TITLE = "(will take value from WindowTitle/WindowTitleStatic)"; + /// removes transparency from an image by combining it with a solid background + public static Image FillImageBackground(Image img, Color c) + { + Bitmap result = new(width: img.Width, height: img.Height); + using var g = Graphics.FromImage(result); + g.Clear(c); + g.DrawImage(img, x: 0, y: 0, width: img.Width, height: img.Height); + return result; + } + /// /// Under Mono, SystemColors.Control returns an ugly beige.
/// This method recursively replaces the of the given (can be a ) with diff --git a/src/BizHawk.Client.EmuHawk/config/FirmwareConfig.cs b/src/BizHawk.Client.EmuHawk/config/FirmwareConfig.cs index ce8013f7466..1b69d4d6be4 100644 --- a/src/BizHawk.Client.EmuHawk/config/FirmwareConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/FirmwareConfig.cs @@ -145,7 +145,13 @@ public FirmwareConfig( = tbbOpenFolder.Image = Properties.Resources.Placeholder; // prep ImageList for ListView - foreach (var img in StatusIcons.Values) imageList1.Images.Add(img); + var iconList = StatusIcons.Values; + if (OSTailoredCode.IsUnixHost) // remove crusty artifacts + { + var bg = lvFirmware.BackColor; + iconList = iconList.Select(img => FormBase.FillImageBackground(img, bg)); + } + foreach (var img in iconList) imageList1.Images.Add(img); _listViewSorter = new ListViewSorter(-1);