I need help, I have this method to get a BitmapImage from a Byte[]
public BitmapSource ByteToBitmapSource(byte[] image)
{
BitmapImage imageSource = new B
I've made something similar, but it's not with BitmapImage, hopes it can help...
First, I get the image from a path, so I get a BMP and cast into a byte[]:
private byte[] LoadImage(string szPathname)
{
try
{
Bitmap image = new Bitmap(szPathname, true);
MemoryStream ms = new MemoryStream();
image.Save(ms, ImageFormat.Bmp);
return ms.ToArray();
}catch (Exception){...}
return null;
}
I call this in my code like this:
byte[] bitmapData1 = LoadImage(@"C:\Users\toto\Desktop\test1.bmp");
And when I want to cast the byte[] into System.Windows.Controls.Image I do this:
protected virtual void OnByteArrayChanged(DependencyPropertyChangedEventArgs e)
{
try
{
// PropertyChanged method
BitmapImage bmpi = new BitmapImage();
bmpi.BeginInit();
bmpi.StreamSource = new MemoryStream(ByteArray);
bmpi.EndInit();
System.Windows.Controls.Image image1 = (get my image in my xaml);
image1.Source = bmpi;
}catch (Exception){...}
}