Fix artifacting on firmware status icons under Mono

This commit is contained in:
YoshiRulz 2024-12-26 00:56:16 +10:00
parent 31dd2dbd2f
commit 694aa867ec
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
2 changed files with 17 additions and 1 deletions

View File

@ -13,6 +13,16 @@ namespace BizHawk.Client.EmuHawk
{
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"/>

View File

@ -145,7 +145,13 @@ namespace BizHawk.Client.EmuHawk
= 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);