mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-04 22:18:56 +00:00
ImageLoader
This commit is contained in:
parent
789fc98789
commit
07548efb93
4 changed files with 32 additions and 24 deletions
|
|
@ -13,7 +13,7 @@ namespace MapControl
|
|||
{
|
||||
public static IImage LoadImage(Uri uri)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
return new Bitmap(AssetLoader.Open(uri));
|
||||
}
|
||||
|
||||
public static IImage LoadImage(Stream stream)
|
||||
|
|
@ -21,6 +21,11 @@ namespace MapControl
|
|||
return new Bitmap(stream);
|
||||
}
|
||||
|
||||
public static IImage LoadImage(string path)
|
||||
{
|
||||
return File.Exists(path) ? new Bitmap(path) : null;
|
||||
}
|
||||
|
||||
public static Task<IImage> LoadImageAsync(Stream stream)
|
||||
{
|
||||
return Thread.CurrentThread.IsThreadPoolThread ?
|
||||
|
|
@ -28,19 +33,11 @@ namespace MapControl
|
|||
Task.Run(() => LoadImage(stream));
|
||||
}
|
||||
|
||||
public static async Task<IImage> LoadImageAsync(string path)
|
||||
public static Task<IImage> LoadImageAsync(string path)
|
||||
{
|
||||
IImage image = null;
|
||||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
using (var stream = File.OpenRead(path))
|
||||
{
|
||||
image = await LoadImageAsync(stream);
|
||||
}
|
||||
}
|
||||
|
||||
return image;
|
||||
return Thread.CurrentThread.IsThreadPoolThread ?
|
||||
Task.FromResult(LoadImage(path)) :
|
||||
Task.Run(() => LoadImage(path));
|
||||
}
|
||||
|
||||
internal static async Task<IImage> LoadMergedImageAsync(Uri uri1, Uri uri2, IProgress<double> progress)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue