XAML-Map-Control/MapsforgeTiles/WPF/MapsforgeTileSource.WPF.cs
2026-02-24 10:19:28 +01:00

34 lines
898 B
C#

using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace MapControl.MapsforgeTiles
{
public partial class MapsforgeTileSource
{
public override async Task<ImageSource> LoadImageAsync(int zoomLevel, int column, int row)
{
BitmapSource bitmap = null;
try
{
var pixels = RenderTile(zoomLevel, column, row);
if (pixels != null)
{
bitmap = BitmapSource.Create(TileSize, TileSize, 96d, 96d, PixelFormats.Bgra32, null, pixels, TileSize * 4);
bitmap.Freeze();
}
}
catch (Exception ex)
{
Logger?.LogError(ex, "LoadImageAsync");
}
return bitmap;
}
}
}