I am having a problem getting images of various formats to
display properly in an Image control on a webform.
The images are stored in a SQL Server database. I am
using the following technique to extract and display the
I created a new ASPX page whose sole job is to get image
from the database and stream it back to the calling page.
That said, here's the steps I am going through:
1) Query the database and retrieve the image data.
2) Cast the image data to a Byte array
3) Create a MemoryStream object using the byte array
created in step 2.
4) Create a new Bitmap object from the MemoryStream
5) Set Response.ContentType = "image/<format>" where
<format> = 'gif', 'jpeg', 'tiff', 'bmp', etc...
6) Finally stream the image to the caller: Bitmap.Save
(Response.OutputStream, ImageFormat.<format> where
<format> = one of the format options that matches the
format specified in the database for the image.
This works great for JPEG and GIF images. However, the
TIFF and BMP images are not displayed.
I have confirmed that the images are stored in the
database in the proper format. That is, if my database
says it's a TIFF, it's a TIFF. This was done using the
exact same technique outlined above (with the exception
that the image source isn't an aspx page), but in a
Am I missing something here?