bitmap onto a webpage

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
 
V

vMike

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.
 
K

Kevin Spencer

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top