mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
ImageLoader
This commit is contained in:
parent
dfe3201625
commit
55d1ee933c
|
|
@ -12,7 +12,7 @@ namespace MapControl
|
|||
{
|
||||
public static IImage LoadImage(Uri uri)
|
||||
{
|
||||
return null;
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public static IImage LoadImage(Stream stream)
|
||||
|
|
@ -25,17 +25,19 @@ namespace MapControl
|
|||
return Task.FromResult(LoadImage(stream));
|
||||
}
|
||||
|
||||
public static Task<IImage> LoadImageAsync(string path)
|
||||
public static async Task<IImage> LoadImageAsync(string path)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
IImage image = null;
|
||||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
return Task.FromResult<IImage>(null);
|
||||
using (var stream = File.OpenRead(path))
|
||||
{
|
||||
image = await LoadImageAsync(stream);
|
||||
}
|
||||
}
|
||||
|
||||
using (var stream = File.OpenRead(path))
|
||||
{
|
||||
return LoadImageAsync(stream);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
internal static async Task<IImage> LoadMergedImageAsync(Uri uri1, Uri uri2, IProgress<double> progress)
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@ namespace MapControl
|
|||
HttpClient.DefaultRequestHeaders.Add("User-Agent", $"XAML-Map-Control/{typeof(ImageLoader).Assembly.GetName().Version}");
|
||||
}
|
||||
|
||||
public static async Task<ImageSource> LoadImageAsync(byte[] buffer)
|
||||
{
|
||||
using (var stream = new MemoryStream(buffer))
|
||||
{
|
||||
return await LoadImageAsync(stream);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<ImageSource> LoadImageAsync(Uri uri, IProgress<double> progress = null)
|
||||
{
|
||||
ImageSource image = null;
|
||||
|
|
@ -67,14 +75,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; }
|
||||
|
|
|
|||
|
|
@ -32,17 +32,19 @@ namespace MapControl
|
|||
return Task.FromResult(LoadImage(stream));
|
||||
}
|
||||
|
||||
public static Task<ImageSource> LoadImageAsync(string path)
|
||||
public static async Task<ImageSource> LoadImageAsync(string path)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
ImageSource image = null;
|
||||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
return Task.FromResult<ImageSource>(null);
|
||||
using (var stream = File.OpenRead(path))
|
||||
{
|
||||
image = await LoadImageAsync(stream);
|
||||
}
|
||||
}
|
||||
|
||||
using (var stream = File.OpenRead(path))
|
||||
{
|
||||
return LoadImageAsync(stream);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
internal static async Task<ImageSource> LoadMergedImageAsync(Uri uri1, Uri uri2, IProgress<double> progress)
|
||||
|
|
|
|||
Loading…
Reference in a new issue