Browse Source

Fix X11IconLoader exception for icons < 128px (#20914)

pull/17825/merge
Julien Lebosquain 1 week ago
committed by GitHub
parent
commit
5a3e66e1f0
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      src/Avalonia.X11/X11IconLoader.cs

5
src/Avalonia.X11/X11IconLoader.cs

@ -40,14 +40,15 @@ namespace Avalonia.X11
_width = Math.Min(bitmap.PixelSize.Width, 128);
_height = Math.Min(bitmap.PixelSize.Height, 128);
var pixels = new uint[_width * _height];
var size = new PixelSize(_width, _height);
using (var rtb = new RenderTargetBitmap(new PixelSize(128, 128)))
using (var rtb = new RenderTargetBitmap(size))
{
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,
rtb.CopyPixels(new LockedFramebuffer((IntPtr)pPixels, size, _width * 4,
new Vector(96, 96), PixelFormat.Bgra8888, AlphaFormat.Premul, null));
}

Loading…
Cancel
Save