Load image

  • Thread starter Thread starter Roland Wolters
  • Start date Start date
R

Roland Wolters

Hi,

I need to build a webpage that shows the pages of a mutlipage tiff file. I
cannot load it directly into the System.Web.UI.WebControls.Image but I can
load it into a System.Drawing.Image. I can select a page with
SelectActiveFrame. Now how can I load this image in the webcontrol? Sure I
can save it first in a jpg or gif file and show that but is there a
directer way? Anyone a tip?

Hmm maybe in the same way as loading an image from a blob from a
databse.....


Greatings,

Roland
 
Images are not embedded in HTML documents. They are inserted into the layout
by the browser, which reads an img tag to find out where the image is.
Therefore, you don't load an image into a server control. You create an img
tag in the Control. As this s a dynamic image (not from a file), you need to
create an ASPX page that responds to a request by writing the image out to
the Response.OutputStream after setting the Response.ContentType to
"image/jpg" or whatever the correct MIME type is for the image. Then the img
tag in a Server Control on another Page can point to that ASPX page as the
src attribute of the img tag.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Hi, Roland Wolters,

Basically you should do the following:

Create a new aspx page. Remove any html from it, leave only the @Page
directive. In the class for that page in the Page_Load method open the tiff
file as System.Drawing.Image, call SelectActiveFrame selecting the
appropriate frame - depending on the query string or some Session variable
(it is up to you - how you decide to design it). Set the
Response.ContentType property to "image/tiff" (I may be wrong about the
exact string, you should check it). Call Save on the Image instance passing
the Response.OutputStream as the first parameter. Then *it is very
important* to Dispose the Image instance (if you code in C# you can use the
using(){} construct). Then call Response.End().

On the page that should display the image add an <img> and set the src
attribute to the aspx page (with the appropriate query string if you decide
to follow this design).

Hope this helps
Martin
 
Back
Top