ui: show icon preview next to name during icon selection

This commit is contained in:
VewDev
2025-09-02 12:22:33 +02:00
parent 8e2f8f4413
commit 0bdd4ad091
3 changed files with 36 additions and 9 deletions

View File

@@ -60,15 +60,10 @@ namespace Ryujinx.Ava.UI.Controls
Stream activeIconStream = EmbeddedResources.GetStream(selectedIcon.FullPath);
if (activeIconStream != null)
{
// SVG files need to be converted to an image first
if (selectedIcon.FullPath.EndsWith(".svg", StringComparison.OrdinalIgnoreCase))
Bitmap logoBitmap = GetBitmapForLogo(selectedIcon);
if (logoBitmap != null)
{
Stream pngStream = ConvertSvgToPng(activeIconStream);
CurrentLogoBitmap.Value = new Bitmap(pngStream);
}
else
{
CurrentLogoBitmap.Value = new Bitmap(activeIconStream);
CurrentLogoBitmap.Value = logoBitmap;
}
}
}
@@ -82,6 +77,24 @@ namespace Ryujinx.Ava.UI.Controls
private void WindowIconChanged_Event(object _, ReactiveEventArgs<string> rArgs) => SetNewAppIcon(rArgs.NewValue);
public static Bitmap GetBitmapForLogo(ApplicationIcon icon)
{
Stream activeIconStream = EmbeddedResources.GetStream(icon.FullPath);
if (activeIconStream == null)
return null;
// SVG files need to be converted to an image first
if (icon.FullPath.EndsWith(".svg", StringComparison.OrdinalIgnoreCase))
{
Stream pngStream = ConvertSvgToPng(activeIconStream);
return new Bitmap(pngStream);
}
else
{
return new Bitmap(activeIconStream);
}
}
private static Stream ConvertSvgToPng(Stream svgStream)
{
int width = 256;