too many to add
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Microsoft.UI.Xaml.Media.Imaging;
|
||||
using Windows.Storage.Streams;
|
||||
|
||||
namespace Hyperbar.UI.Windows;
|
||||
|
||||
public class StreamToImageSourceConverter :
|
||||
ValueConverter<Stream, ImageSource>
|
||||
{
|
||||
protected override ImageSource? ConvertTo(Stream value,
|
||||
Type? targetType,
|
||||
object? parameter,
|
||||
string? language)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
IRandomAccessStream randomAccessStream =
|
||||
WindowsRuntimeStreamExtensions.AsRandomAccessStream(value);
|
||||
|
||||
BitmapImage bitmapImage = new();
|
||||
bitmapImage.SetSource(randomAccessStream);
|
||||
return bitmapImage;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user