mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Added ImageLoader.LoadImageAsync(IBuffer buffer)
This commit is contained in:
parent
d7eb26f9cd
commit
f3aad38814
|
|
@ -5,7 +5,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -66,14 +65,6 @@ namespace MapControl
|
|||
return image;
|
||||
}
|
||||
|
||||
public static async Task<ImageSource> LoadImageAsync(byte[] buffer)
|
||||
{
|
||||
using (var stream = new MemoryStream(buffer))
|
||||
{
|
||||
return await LoadImageAsync(stream);
|
||||
}
|
||||
}
|
||||
|
||||
internal class HttpResponse
|
||||
{
|
||||
public byte[] Buffer { get; }
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@ namespace MapControl
|
|||
return Task.FromResult(LoadImage(stream));
|
||||
}
|
||||
|
||||
public static async Task<ImageSource> LoadImageAsync(byte[] buffer)
|
||||
{
|
||||
using (var stream = new MemoryStream(buffer))
|
||||
{
|
||||
return await LoadImageAsync(stream);
|
||||
}
|
||||
}
|
||||
|
||||
public static Task<ImageSource> LoadImageAsync(string path)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
|
|
|
|||
|
|
@ -27,13 +27,8 @@ namespace MapControl
|
|||
var pixelData = await decoder.GetPixelDataAsync(
|
||||
BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied, new BitmapTransform(),
|
||||
ExifOrientationMode.IgnoreExifOrientation, ColorManagementMode.DoNotColorManage);
|
||||
var pixels = pixelData.DetachPixelData();
|
||||
|
||||
using (var pixelStream = image.PixelBuffer.AsStream())
|
||||
{
|
||||
await pixelStream.WriteAsync(pixels, 0, pixels.Length);
|
||||
}
|
||||
|
||||
pixelData.DetachPixelData().CopyTo(image.PixelBuffer);
|
||||
return image;
|
||||
}
|
||||
|
||||
|
|
@ -51,6 +46,22 @@ 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…
Reference in a new issue