Assuming that converting the files all at once is not an option, you can convert them
on the fly. I wrote a little HttpHandler class that converts requests for .tif to .png
format on the fly. Works for any browser that supports .png. You could use .jpg or
whatever. Look up the IHttpHandler interface in help. You need to register the ASP.NET
dll with IIS as the handler for .tif requests, then have a web.config stanza that
calls your handler. It's all in the docs.
David
using System;
using System.Web;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
namespace XPSystems.Web.UI.Drawing
{
public class ImageHandler : IHttpHandler
{
public ImageHandler()
{
}
public bool IsReusable { get { return true; } }
public void ProcessRequest(HttpContext context)
{
context.Response.Clear();
// Get the complete path and file name of the image file
string filename = context.Request.PhysicalPath;
// Convert the image file into a .png file
Image newImage = new Bitmap(filename);
MemoryStream stream = new MemoryStream();
newImage.Save(stream, ImageFormat.Png);
stream.Seek(0, SeekOrigin.Begin);
// Return/Stream back the .png file
context.Response.ContentType = "image/x-png";
CopyStream(context.Response.OutputStream, stream);
}
private void CopyStream(Stream streamDest, Stream streamSrc)
{
const int size = 4096;
byte[] bytes = new byte[size];
int numBytes;
while ((numBytes = streamSrc.Read(bytes, 0, size)) > 0)
streamDest.Write(bytes, 0, numBytes);
}
}
}
-----Original Message-----
From: Ethan Smith [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 06, 2002 22:55
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET] Displaying .tif files
You can use a browser add-in to display the tiff file.
http://www.alternatiff.com/
http://www.innomage.com/interneTIFF.htm
-----Original Message-----
From: dotnet discussion [mailto:[EMAIL PROTECTED]] On Behalf Of
Pierre Greborio
Sent: Tuesday, May 07, 2002 1:17 AM
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET] Displaying .tif files
You cannot display a tiff image on an html page. The images types that
can be used are: gif, jpeg and png.
Pierre
-----------------------------------------------
Pierre Greborio
[EMAIL PROTECTED]
http://www.pierregreborio.it <http://www.pierregreborio.it/>
-----------------------------------------------
-----Original Message-----
From: dotnet discussion [mailto:[EMAIL PROTECTED]] On Behalf Of
Avinash Lakshman
Sent: Tuesday, May 07, 2002 4:41 AM
To: [EMAIL PROTECTED]
Subject: [DOTNET] Displaying .tif files
Hi All
I have a requirement where my C# web service returns a pointer to a file
which is a .tif image ( an image format like .gif or .jpeg ). I need to
display this in I.E. First of all is this possible ? Secondly, how do I
go about doing it ?
Please help.
Thanks
A
_____
Get your FREE download of MSN Explorer at http://explorer.msn.com
<http://g.msn.com/1HM105401/44> .
You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.
You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or
subscribe to other DevelopMentor lists at http://discuss.develop.com.
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.