We help IT Professionals succeed at work.

display TIFF image using ASP.net

bender007
bender007 asked
on
Tiff image not supported natively on IE, how can i display a Tiff image on a ASP.net page ? I have the Tiff stored in a DB as a BLOB.
Comment
Watch Question

Commented:
Create a new page with code similar to the following, except obviously taking the database field to display and parsing the BLOB into a Bitmap image rather than loading it from a file.
<%@ Page Language="C#" debug="true" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
 
<script language="C#" runat="server">
 
void Page_Load(Object sender, EventArgs e)
{
    Response.ContentType = "image/gif";
    new Bitmap("Image.tif").Save(Response.OutputStream, ImageFormat.Gif);
}
 
</script>

Open in new window

Author

Commented:
Your solution worked, thanks. But how do i assign the gif image to a webcontrol ?
icr

Commented:
Using the code attached, if you set the Url of the image to "ImageFromDb.aspx?ImagePath=test.tif" it should work. Of course you'd want to modify it from using the path to using some key in the database or whatever.
<%@ Page Language="C#" debug="true" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
 
<script language="C#" runat="server">
 
void Page_Load(Object sender, EventArgs e)
{
    Response.ContentType = "image/gif";
    new Bitmap(Request.QueryString("ImagePath")).Save(Response.OutputStream, ImageFormat.Gif);
}
 
</script>

Open in new window