mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-01-02 14:50:06 +01:00
GroundOverlay, ImageLoader
This commit is contained in:
parent
cd31f45feb
commit
733da9f231
|
|
@ -48,13 +48,20 @@ namespace MapControl
|
|||
|
||||
if (entry != null)
|
||||
{
|
||||
MemoryStream memoryStream;
|
||||
|
||||
// ZipArchive does not support multithreading, synchronously copy ZipArchiveEntry stream to MemoryStream.
|
||||
//
|
||||
using (var zipStream = entry.Open())
|
||||
using (var memoryStream = new MemoryStream((int)zipStream.Length))
|
||||
{
|
||||
zipStream.CopyTo(memoryStream); // CopyToAsync won't work with ZipArchive
|
||||
memoryStream = new MemoryStream((int)zipStream.Length);
|
||||
zipStream.CopyTo(memoryStream);
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
imageSource = await ImageLoader.LoadImageAsync(memoryStream);
|
||||
}
|
||||
|
||||
// Close Zip Stream before awaiting.
|
||||
//
|
||||
imageSource = await ImageLoader.LoadImageAsync(memoryStream);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,12 +31,9 @@ namespace MapControl
|
|||
HttpClient.DefaultRequestHeaders.Add("User-Agent", $"XAML-Map-Control/{typeof(ImageLoader).Assembly.GetName().Version}");
|
||||
}
|
||||
|
||||
public static async Task<ImageSource> LoadImageAsync(byte[] buffer)
|
||||
public static Task<ImageSource> LoadImageAsync(byte[] buffer)
|
||||
{
|
||||
using (var stream = new MemoryStream(buffer))
|
||||
{
|
||||
return await LoadImageAsync(stream);
|
||||
}
|
||||
return LoadImageAsync(new MemoryStream(buffer));
|
||||
}
|
||||
|
||||
public static async Task<ImageSource> LoadImageAsync(Uri uri, IProgress<double> progress = null)
|
||||
|
|
|
|||
|
|
@ -78,11 +78,9 @@ namespace MapControl
|
|||
|
||||
if (response?.Buffer != null)
|
||||
{
|
||||
using (var memoryStream = new MemoryStream(response.Buffer))
|
||||
using (var randomAccessStream = memoryStream.AsRandomAccessStream())
|
||||
using (var stream = new MemoryStream(response.Buffer).AsRandomAccessStream())
|
||||
{
|
||||
var decoder = await BitmapDecoder.CreateAsync(randomAccessStream);
|
||||
|
||||
var decoder = await BitmapDecoder.CreateAsync(stream);
|
||||
bitmap = await LoadWriteableBitmapAsync(decoder);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue