mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 22:46:58 +00:00
Revert to using MemoryStream in WinUI ImageLoader
This commit is contained in:
parent
359e253d00
commit
7b404446d2
3 changed files with 17 additions and 29 deletions
|
|
@ -21,32 +21,35 @@ namespace MapControl
|
|||
{
|
||||
public static partial class ImageLoader
|
||||
{
|
||||
public static async Task<ImageSource> LoadImageAsync(BitmapDecoder decoder)
|
||||
#if false
|
||||
public static async Task<SoftwareBitmapSource> 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);
|
||||
return image;
|
||||
}
|
||||
#else
|
||||
public static async Task<WriteableBitmap> LoadImageAsync(BitmapDecoder decoder)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
#endif
|
||||
public static async Task<ImageSource> 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.
|
||||
// Alternatives are SoftwareBitmapSource or WriteableBitmap.
|
||||
#if USE_BITMAPIMAGE
|
||||
#if false
|
||||
var image = new BitmapImage();
|
||||
await image.SetSourceAsync(stream);
|
||||
return image;
|
||||
|
|
@ -60,22 +63,6 @@ namespace MapControl
|
|||
return LoadImageAsync(stream.AsRandomAccessStream());
|
||||
}
|
||||
|
||||
public static async Task<ImageSource> LoadImageAsync(IBuffer buffer)
|
||||
{
|
||||
using (var stream = new InMemoryRandomAccessStream())
|
||||
{
|
||||
await stream.WriteAsync(buffer);
|
||||
stream.Seek(0);
|
||||
|
||||
return await LoadImageAsync(stream);
|
||||
}
|
||||
}
|
||||
|
||||
public static Task<ImageSource> LoadImageAsync(byte[] buffer)
|
||||
{
|
||||
return LoadImageAsync(buffer.AsBuffer());
|
||||
}
|
||||
|
||||
public static async Task<ImageSource> LoadImageAsync(string path)
|
||||
{
|
||||
ImageSource image = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue