-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43403e9
commit f9c824e
Showing
4 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Avalonia.Data.Converters; | ||
using Avalonia; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Avalonia.Media.Imaging; | ||
using Avalonia.Platform; | ||
|
||
namespace FrostyEditor.Utils | ||
{ | ||
/// <summary> | ||
/// <para> | ||
/// Converts a string path to a bitmap asset. | ||
/// </para> | ||
/// <para> | ||
/// The asset must be in the same assembly as the program. If it isn't, | ||
/// specify "avares://<assemblynamehere>/" in front of the path to the asset. | ||
/// </para> | ||
/// </summary> | ||
public class BitmapAssetValueConverter | ||
{ | ||
public static BitmapAssetValueConverter Instance = new BitmapAssetValueConverter(); | ||
|
||
public object? Convert(string? rawUri) | ||
{ | ||
if (rawUri is null) | ||
{ | ||
return null; | ||
} | ||
|
||
Uri uri = new Uri(rawUri); | ||
|
||
var asset = AssetLoader.Open(uri); | ||
|
||
return new Bitmap(asset); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters