O
Oriane
Hello there,
I try to handle bitmap images stored in an Image column in Sql Server. The
following code is ok when the image is of type Bitmap (*.bmp):
private ImageSource ConvertByteArrayToImageSource(byte[] bdIconeArray) {
ImageSource imgSource = null;
MemoryStream strm = new MemoryStream();
BitmapImage bitmap = new BitmapImage();
// Well-known work-around to make Northwind images work
int offset = 78;
strm.Write( bdIconeArray, offset, bdIconeArray.Length - offset );
// Read the image into the bitmap object
bitmap.BeginInit();
bitmap.StreamSource = strm;
bitmap.EndInit();
imgSource = bitmap;
return imgSource;
}
However, it doesn't work with png, jpg or Tiff image stored in the database.
Must the Offset be different ?
Oriane
I try to handle bitmap images stored in an Image column in Sql Server. The
following code is ok when the image is of type Bitmap (*.bmp):
private ImageSource ConvertByteArrayToImageSource(byte[] bdIconeArray) {
ImageSource imgSource = null;
MemoryStream strm = new MemoryStream();
BitmapImage bitmap = new BitmapImage();
// Well-known work-around to make Northwind images work
int offset = 78;
strm.Write( bdIconeArray, offset, bdIconeArray.Length - offset );
// Read the image into the bitmap object
bitmap.BeginInit();
bitmap.StreamSource = strm;
bitmap.EndInit();
imgSource = bitmap;
return imgSource;
}
However, it doesn't work with png, jpg or Tiff image stored in the database.
Must the Offset be different ?
Oriane