Skip to content

Commit

Permalink
Fix artifacting on firmware status icons under Mono
Browse files Browse the repository at this point in the history
  • Loading branch information
YoshiRulz committed Dec 25, 2024
1 parent 31dd2db commit 694aa86
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/BizHawk.Client.EmuHawk/FormBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ public class FormBase : Form
{
private const string PLACEHOLDER_TITLE = "(will take value from WindowTitle/WindowTitleStatic)";

/// <summary>removes transparency from an image by combining it with a solid background</summary>
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;
}

/// <summary>
/// Under Mono, <see cref="SystemColors.Control">SystemColors.Control</see> returns an ugly beige.<br/>
/// This method recursively replaces the <see cref="Control.BackColor"/> of the given <paramref name="control"/> (can be a <see cref="Form"/>) with <see cref="Color.WhiteSmoke"/>
Expand Down
8 changes: 7 additions & 1 deletion src/BizHawk.Client.EmuHawk/config/FirmwareConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 694aa86

Please sign in to comment.