Хочет, чтобы преобразовать байты [], чтобы ImageSourceОшибка преобразования байт ImageSource
вот мой код обращенного в байтах
public object BufferFromImage(System.Windows.Media.ImageSource imageSource)
{
if (imageSource != null)
{
var image = (BitmapSource)imageSource;
BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(image));
using (var ms = new MemoryStream())
{
encoder.Save(ms);
return ms.ToArray();
}
}
else
{
return DBNull.Value;
}
}
кода для байт [], чтобы ImageSource
public ImageSource ByteToImage(byte[] imageData)
{
BitmapImage biImg = new BitmapImage();
MemoryStream ms = new MemoryStream(imageData);
biImg.BeginInit();
biImg.StreamSource = ms;
biImg.EndInit();
ImageSource imgSrc = biImg as ImageSource;
return imgSrc;
}
Этих дает мне эту ошибку:
An unhandled exception of type 'System.NotSupportedException' occurred in PresentationCore.dll
Additional information: No imaging component suitable to complete this operation was found.
Что вызывает это и как я могу его исправить?
[http://stackoverflow.com/ вопросы/22065815/как к обращенным байт-массив к ImageSource-для-окон-8-0-магазин-приложение] (http://stackoverflow.com/questions/22065815/how-to-convert-byte -array-to-imagesource-for-windows-8-0-store-application) – Eminem
Используйте эту ссылку для загрузки файла http://www.aspsnippets.com/Articles/Save-Files-to-SQL-Server -Database-using-FileUpload-Control.aspx –
http://stackoverflow.com/a/8901493/4513879 используйте эту ссылку также –