BitmapImage在EndInit()上抛出NotSupportedException

时间:2016-07-25 23:58:48

标签: c# wpf image bitmapimage

我试图用基本的64字符串在WPF中创建一个Image,但是,每当我尝试为图像Source属性创建BitmapImage时,我都会得到一个NotSupportedException。

代码:

public ScreenCaptureWindow(string screenCaptureBase64) {
    InitializeComponent();
    byte[] imageBytes = Convert.FromBase64String(screenCaptureBase64);
    BitmapImage bitmapImage = new BitmapImage();
    bitmapImage.BeginInit();
    bitmapImage.StreamSource = new MemoryStream(imageBytes);
    bitmapImage.EndInit(); //Crashes here
    image.Source = bitmapImage;
}

Link to stacktrace

附件是异常详情的屏幕截图。

有什么想法吗?

enter image description here

0 个答案:

没有答案