aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Ava/Ui/Controls/BitmapArrayValueConverter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Ava/Ui/Controls/BitmapArrayValueConverter.cs')
-rw-r--r--Ryujinx.Ava/Ui/Controls/BitmapArrayValueConverter.cs35
1 files changed, 35 insertions, 0 deletions
diff --git a/Ryujinx.Ava/Ui/Controls/BitmapArrayValueConverter.cs b/Ryujinx.Ava/Ui/Controls/BitmapArrayValueConverter.cs
new file mode 100644
index 00000000..7222d67b
--- /dev/null
+++ b/Ryujinx.Ava/Ui/Controls/BitmapArrayValueConverter.cs
@@ -0,0 +1,35 @@
+using Avalonia.Data.Converters;
+using Avalonia.Media;
+using Avalonia.Media.Imaging;
+using System;
+using System.Globalization;
+using System.IO;
+
+namespace Ryujinx.Ava.Ui.Controls
+{
+ public class BitmapArrayValueConverter : IValueConverter
+ {
+ public static BitmapArrayValueConverter Instance = new();
+
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value == null)
+ {
+ return null;
+ }
+
+ if (value is byte[] buffer && targetType == typeof(IImage))
+ {
+ MemoryStream mem = new(buffer);
+ return new Bitmap(mem);
+ }
+
+ throw new NotSupportedException();
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
+ }
+ }
+} \ No newline at end of file