mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-04 14:08:32 +00:00
Initial Avalonia version
This commit is contained in:
parent
76b35d00a7
commit
66020793f8
11 changed files with 1750 additions and 0 deletions
45
MapControl/Avalonia/ImageLoader.Avalonia.cs
Normal file
45
MapControl/Avalonia/ImageLoader.Avalonia.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// Copyright © 2024 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Media.Imaging;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
public static partial class ImageLoader
|
||||
{
|
||||
public static IImage LoadImage(Uri uri)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IImage LoadImage(Stream stream)
|
||||
{
|
||||
return new Bitmap(stream);
|
||||
}
|
||||
|
||||
public static Task<IImage> LoadImageAsync(Stream stream)
|
||||
{
|
||||
return Task.FromResult(LoadImage(stream));
|
||||
}
|
||||
|
||||
public static Task<IImage> LoadImageAsync(string path)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var stream = File.OpenRead(path);
|
||||
|
||||
return LoadImage(stream);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue