Browse Source
X11IconLoader needs to scale the icon into our hardcoded size (#20817)
pull/20819/head
Nikita Tsukanov
3 weeks ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
9 additions and
3 deletions
-
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]; |
|
|
|
|
|
|
|
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) |
|
|
|
bitmap.CopyPixels(new LockedFramebuffer((IntPtr)pPixels, new PixelSize(_width, _height), _width * 4, |
|
|
|
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); |
|
|
|
|