mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-20 22:05:07 +00:00
Updated MapsforgeTileSource
This commit is contained in:
parent
a1df4d39bb
commit
266f44a0fd
5 changed files with 83 additions and 57 deletions
|
|
@ -1,24 +1,43 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Platform;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MapControl.MapsforgeTiles
|
||||
{
|
||||
public partial class MapsforgeTileSource
|
||||
{
|
||||
private static Bitmap CreateImage(int[] pixels)
|
||||
public override async Task<IImage> LoadImageAsync(int zoomLevel, int column, int row)
|
||||
{
|
||||
var size = (int)Math.Sqrt(pixels.Length);
|
||||
Bitmap bitmap = null;
|
||||
|
||||
unsafe
|
||||
try
|
||||
{
|
||||
fixed (int* ptr = pixels)
|
||||
var pixels = tileRenderer.RenderTile(zoomLevel, column, row);
|
||||
|
||||
if (pixels != null)
|
||||
{
|
||||
return new Bitmap(PixelFormat.Bgra8888, AlphaFormat.Opaque, (nint)ptr,
|
||||
new PixelSize(size, size), new Vector(96d, 96d), size * 4);
|
||||
var size = TileRenderer.TileSize;
|
||||
|
||||
unsafe
|
||||
{
|
||||
fixed (int* ptr = pixels)
|
||||
{
|
||||
return new Bitmap(PixelFormat.Bgra8888, AlphaFormat.Opaque, (nint)ptr,
|
||||
new PixelSize(size, size), new Vector(96d, 96d), size * 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger?.LogError(ex, "LoadImageAsync");
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue