From a2c472162b90575aa0895842c238190dd2e40326 Mon Sep 17 00:00:00 2001 From: ClemensFischer Date: Wed, 16 Aug 2023 22:18:01 +0200 Subject: [PATCH] Update ImageLoader.WinUI.cs --- MapControl/WinUI/ImageLoader.WinUI.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/MapControl/WinUI/ImageLoader.WinUI.cs b/MapControl/WinUI/ImageLoader.WinUI.cs index 326eda1f..fa13ca99 100644 --- a/MapControl/WinUI/ImageLoader.WinUI.cs +++ b/MapControl/WinUI/ImageLoader.WinUI.cs @@ -24,10 +24,20 @@ namespace MapControl { public static async Task LoadImageAsync(IRandomAccessStream stream) { + // WinUI BitmapImage produces visual artifacts with Bing Maps Aerial (or all JPEG?) + // images in a tile raster, where thin white lines may appear as gaps between tiles +#if WINUI + var image = new SoftwareBitmapSource(); + var decoder = await BitmapDecoder.CreateAsync(stream); + + using (var bitmap = await decoder.GetSoftwareBitmapAsync(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied)) + { + await image.SetBitmapAsync(bitmap); + } +#else var image = new BitmapImage(); - await image.SetSourceAsync(stream); - +#endif return image; } @@ -40,7 +50,7 @@ namespace MapControl { using (var stream = new MemoryStream(buffer)) { - // Must await method before closing the stream. + // Method call must be awaited before closing the stream. // return await LoadImageAsync(stream); }