Как преобразовать Byte [] в BitmapImage

Мне нужна помощь, у меня есть этот метод, чтобы получить BitmapImage из Byte []

public BitmapSource ByteToBitmapSource(byte[] image)
{
    BitmapImage imageSource = new BitmapImage();

    using (MemoryStream stream = new MemoryStream(image))
    {
        stream.Seek(0, SeekOrigin.Begin);
        imageSource.BeginInit();
        imageSource.StreamSource = stream;
        imageSource.CacheOption = BitmapCacheOption.OnLoad;
        imageSource.EndInit();
    }

    return imageSource;
}

imageSource.EndInit (); выдает ошибку «Мы не нашли компонент изображения, подходящий для завершения эта операция. "

16
задан Vladimir Vasilev 30 September 2014 в 12:40
поделиться