bitmap onto a webpage

  • Thread starter Thread starter Microsoft
  • Start date Start date
M

Microsoft

I have a need to display a bitmap (chart) that has been created in code. In
the Windows I just place it in a picturebox. But no luck with a Web page
and I would like to be able to do it without writing the bmp to a file and
then putting it back into the web page.

Does anyone have an idea around this.

Bob Brand
 
You can look into system.drawing.image
save(Response.OutputStream, ImageFormat.Jpeg) method. You might want a bmp
format, but this "writes" the image out to a memory stream instead of disk.
 
You need to create an ASP.Net page to write the image to the browser. The
page can take a Bitmap object, and invoke the Save method to write the
Bitmap to the Response.OutputStream. The example below writes the image in
Jpeg Format. Note that you must set the Response.ContentType to the
appropriate MIME Type for the ImageFormat you use. This informs the browser
what MIME type it's getting, as the file extension (.aspx) won't help:

Response.ContentType = "image/jpg";
ImageObject.Save(Response.OutputStream, ImageFormat.Jpeg);

You can then reference your ASP.Net page in an Image tag in any page;

<img src="ShowImage.aspx">

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Neither a follower nor a lender be.
 
Back
Top