Load a byte[] into an Image at Runtime

后端 未结 4 1351
醉话见心
醉话见心 2021-01-11 13:09

I have a byte[] that is represented by an Image. I am downloading this Image via a WebClient. When the WebClient

4条回答
  •  日久生厌
    2021-01-11 13:28

    Create a BitmapImage from the MemoryStream as below:

    MemoryStream byteStream = new MemoryStream(bytes);
    BitmapImage image = new BitmapImage();
    image.BeginInit();
    image.StreamSource = byteStream;
    image.EndInit();
    

    And in XAML you can create an Image control and set the above image as the Source property.

提交回复
热议问题