mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Update ImageLoader.Avalonia.cs
This commit is contained in:
parent
4867d52013
commit
294e98c6aa
|
|
@ -54,28 +54,26 @@ namespace MapControl
|
||||||
images[1] is Bitmap image2 &&
|
images[1] is Bitmap image2 &&
|
||||||
image1.PixelSize.Height == image2.PixelSize.Height &&
|
image1.PixelSize.Height == image2.PixelSize.Height &&
|
||||||
image1.Format.HasValue &&
|
image1.Format.HasValue &&
|
||||||
image2.Format.HasValue &&
|
image1.Format == image2.Format &&
|
||||||
image1.Format.Value == image2.Format.Value &&
|
|
||||||
image1.AlphaFormat.HasValue &&
|
image1.AlphaFormat.HasValue &&
|
||||||
image2.AlphaFormat.HasValue &&
|
image1.AlphaFormat == image2.AlphaFormat)
|
||||||
image1.AlphaFormat.Value == image2.AlphaFormat.Value)
|
|
||||||
{
|
{
|
||||||
var bpp = image1.Format.Value == PixelFormat.Rgb565 ? 2 : 4;
|
var bpp = image1.Format.Value == PixelFormat.Rgb565 ? 2 : 4;
|
||||||
var size = new PixelSize(image1.PixelSize.Width + image2.PixelSize.Width, image1.PixelSize.Height);
|
var pixelSize = new PixelSize(image1.PixelSize.Width + image2.PixelSize.Width, image1.PixelSize.Height);
|
||||||
var stride1 = image1.PixelSize.Width * bpp;
|
var stride1 = bpp * image1.PixelSize.Width;
|
||||||
var stride = size.Width * bpp;
|
var stride = bpp * pixelSize.Width;
|
||||||
var buffer = new byte[stride * size.Height];
|
var bufferSize = stride * pixelSize.Height;
|
||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (byte* ptr = buffer)
|
fixed (byte* ptr = new byte[stride * pixelSize.Height])
|
||||||
{
|
{
|
||||||
var p = (nint)ptr;
|
var buffer = (nint)ptr;
|
||||||
|
|
||||||
image1.CopyPixels(new PixelRect(image1.PixelSize), p, buffer.Length, stride);
|
image1.CopyPixels(new PixelRect(image1.PixelSize), buffer, bufferSize, stride);
|
||||||
image2.CopyPixels(new PixelRect(image2.PixelSize), p + stride1, buffer.Length, stride);
|
image2.CopyPixels(new PixelRect(image2.PixelSize), buffer + stride1, bufferSize, stride);
|
||||||
|
|
||||||
image = new WriteableBitmap(image1.Format.Value, image1.AlphaFormat.Value, p, size, image1.Dpi, stride);
|
image = new WriteableBitmap(image1.Format.Value, image1.AlphaFormat.Value, buffer, pixelSize, image1.Dpi, stride);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue