XAML-Map-Control/MapsforgeTiles/WPF/MapsforgeTileSource.WPF.cs

34 lines
898 B
C#
Raw Normal View History

2026-02-19 17:20:09 +01:00
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;
2026-02-15 00:09:21 +01:00
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace MapControl.MapsforgeTiles
{
public partial class MapsforgeTileSource
{
2026-02-19 17:20:09 +01:00
public override async Task<ImageSource> LoadImageAsync(int zoomLevel, int column, int row)
2026-02-15 00:09:21 +01:00
{
2026-02-19 17:20:09 +01:00
BitmapSource bitmap = null;
try
{
2026-02-23 16:47:53 +01:00
var pixels = RenderTile(zoomLevel, column, row);
2026-02-19 17:20:09 +01:00
if (pixels != null)
{
2026-02-24 10:19:28 +01:00
bitmap = BitmapSource.Create(TileSize, TileSize, 96d, 96d, PixelFormats.Bgra32, null, pixels, TileSize * 4);
2026-02-19 17:20:09 +01:00
bitmap.Freeze();
}
}
catch (Exception ex)
{
Logger?.LogError(ex, "LoadImageAsync");
}
return bitmap;
2026-02-15 00:09:21 +01:00
}
}
}