From 45b0eb33b86f8298be902ba72483f28cc6a9c0ad Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 6 Mar 2026 01:29:59 +0500 Subject: [PATCH] X11IconLoader needs to scale the icon into our hardcoded size (#20817) --- src/Avalonia.X11/X11IconLoader.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.X11/X11IconLoader.cs b/src/Avalonia.X11/X11IconLoader.cs index a45c77e7c0..f0cd6f0192 100644 --- a/src/Avalonia.X11/X11IconLoader.cs +++ b/src/Avalonia.X11/X11IconLoader.cs @@ -41,9 +41,15 @@ namespace Avalonia.X11 _height = Math.Min(bitmap.PixelSize.Height, 128); var pixels = new uint[_width * _height]; - fixed (void* pPixels = pixels) - bitmap.CopyPixels(new LockedFramebuffer((IntPtr)pPixels, new PixelSize(_width, _height), _width * 4, - new Vector(96, 96), PixelFormat.Bgra8888, AlphaFormat.Premul, null)); + using (var rtb = new RenderTargetBitmap(new PixelSize(128, 128))) + { + using (var ctx = rtb.CreateDrawingContext(true)) + ctx.DrawImage(bitmap, new Rect(rtb.Size)); + + fixed (void* pPixels = pixels) + rtb.CopyPixels(new LockedFramebuffer((IntPtr)pPixels, new PixelSize(_width, _height), _width * 4, + new Vector(96, 96), PixelFormat.Bgra8888, AlphaFormat.Premul, null)); + } Data = new UIntPtr[_width * _height + 2]; Data[0] = new UIntPtr((uint)_width);