As to the removed data on the image types, we have a very optimistic proverb: "It's too late to start drinking mineral water when you have a kidney failure". Where have you been before? (Let me guess: not in this company? :-))
I'm afraid that someone will have a nice comfortable job of remembering what image type could have been possibly stored in the past, trying to look at the first byte to figure out the image types and using the most effective trial-and-error method of restoring of this sacral knowledge. To some extend, you can automate this intricate work by writing some method which would sequentially try to load the image as different formats until if does not fail. :-) But, on more serious note: if you just stored the full content of some image files in the database in full, the beginning of the file contains
metadata helping to load it properly.
Technically, it's pretty simple thing: you can use the
System.Drawing.Bitmap
class and create the instance with the constructor with a
Stream
argument:
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.aspx[
^],
http://msdn.microsoft.com/en-us/library/z7ha67kw.aspx[
^].
You will read the blob data from your database as an array of bytes, using ADO.NET
data reader. Please see this short tutorial:
http://www.akadia.com/services/dotnet_read_write_blob.html[
^].
The raw data in the form of byte array use used to initialize memory stream
System.IO.MemoryStream
,
http://msdn.microsoft.com/en-us/library/system.io.memorystream.aspx[
^].
This really short CodeProject article shows the sample code for it:
C# Image to Byte Array and Byte Array to Image Converter Class[
^].
Good luck,
—SA