-
An exception is thrown when trying to bind
Tried to bind public static async Task<BitmapImage> ImageFromBytes(this byte[] bytes)
{
var image = new BitmapImage();
using (var stream = new InMemoryRandomAccessStream())
{
await stream.WriteAsync(bytes.AsBuffer());
stream.Seek(0);
await image.SetSourceAsync(stream);
}
return image;
} And a few other options, but another exception is thrown already:
New to WinUI, I don't understand why it doesn't work |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
Instead of BitmapImage I generally use WriteableBitmap, like for example in the GetCaptureWriteableBitmap function in |
Beta Was this translation helpful? Give feedback.
-
Are the bytes raw pixel bytes or are they the contents of a bitmap file?
|
Beta Was this translation helpful? Give feedback.
Instead of BitmapImage I generally use WriteableBitmap, like for example in the GetCaptureWriteableBitmap function in
CMediaEngine.cs
(then Image.Source = WriteableBitmap to display it in an Image control)