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);