It seems that header bytes are stored along with an image when it is embedded into an access database as a OLE Object and they are preventing me from writing the bytes stored to disc as it raises an exception ‘A generic error occurred in GDI+.’
How do you extract only the image bytes from a OLE Object stored in an access database and then save to disk?
photo = ((rs.Fields["photo"].Value == System.DBNull.Value) ?
null : (byte[])rs.Fields["photo"].Value)
...
if (photo != null)
{
MemoryStream stream = new MemoryStream(photo);
Image image = new Bitmap(stream);
stream.Close();
image.Save(@"C:\Temp\images\test", ImageFormat.Jpeg);
}
1 Answer