mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-31 22:00:12 +01:00
Update ImageLoader.WinUI.cs
This commit is contained in:
parent
adc34b6591
commit
359e253d00
|
|
@ -21,14 +21,23 @@ namespace MapControl
|
|||
{
|
||||
public static partial class ImageLoader
|
||||
{
|
||||
public static async Task<WriteableBitmap> LoadImageAsync(BitmapDecoder decoder)
|
||||
public static async Task<ImageSource> LoadImageAsync(BitmapDecoder decoder)
|
||||
{
|
||||
#if USE_SOFTWAREBITMAP
|
||||
var image = new SoftwareBitmapSource();
|
||||
var bitmap = await decoder.GetSoftwareBitmapAsync(
|
||||
BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied, new BitmapTransform(),
|
||||
ExifOrientationMode.IgnoreExifOrientation, ColorManagementMode.DoNotColorManage);
|
||||
|
||||
await image.SetBitmapAsync(bitmap);
|
||||
#else
|
||||
var image = new WriteableBitmap((int)decoder.PixelWidth, (int)decoder.PixelHeight);
|
||||
var pixelData = await decoder.GetPixelDataAsync(
|
||||
BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied, new BitmapTransform(),
|
||||
ExifOrientationMode.IgnoreExifOrientation, ColorManagementMode.DoNotColorManage);
|
||||
|
||||
pixelData.DetachPixelData().CopyTo(image.PixelBuffer);
|
||||
#endif
|
||||
return image;
|
||||
}
|
||||
|
||||
|
|
@ -37,8 +46,13 @@ namespace MapControl
|
|||
// 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.
|
||||
// Alternatives are SoftwareBitmapSource or WriteableBitmap.
|
||||
|
||||
#if USE_BITMAPIMAGE
|
||||
var image = new BitmapImage();
|
||||
await image.SetSourceAsync(stream);
|
||||
return image;
|
||||
#else
|
||||
return await LoadImageAsync(await BitmapDecoder.CreateAsync(stream));
|
||||
#endif
|
||||
}
|
||||
|
||||
public static Task<ImageSource> LoadImageAsync(Stream stream)
|
||||
|
|
|
|||
Loading…
Reference in a new issue