C# Windows 8 Store (Metro, WinRT) Byte array to BitmapImage

后端 未结 2 2110
粉色の甜心
粉色の甜心 2020-12-16 14:04

I am working on a Windows 8 Metro app that applies filters to images. I have a web version of the app and wanted to port it. But as we all know WinRT doesn\'t have all the g

2条回答
  •  感情败类
    2020-12-16 15:03

    This is working for me,

        private async Task ByteArrayToBitmapImage(byte[] byteArray)
        {
            var bitmapImage = new BitmapImage();
    
            var stream = new InMemoryRandomAccessStream();
            await stream.WriteAsync(byteArray.AsBuffer());
            stream.Seek(0);
    
            bitmapImage.SetSource(stream);
            return bitmapImage;
        }
    

提交回复
热议问题