On a .aspx page I am creating a bmp using the System.Drawing namespace. When the bmp is finished I am sending it to the browser using:
using (MemoryStream ms = new MemoryStream())
{
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
byte[] buffer = ms.GetBuffer();
HttpContext.Current.Response.OutputStream.Write(buffer, 0, buffer.Length);
HttpContext.Current.Response.Flush();
}
This seems to simply send the bmp to the browser which renders it – but not as an html page. You can’t view source – it seems to be simply a bitmap.
I’d like the bmp to be sent to the browser but as the ‘content’ of the body tag of an html page.
Is the only way to do this to save (write) the bmp to disk and then use that file as the src of an image tag? Or is there a way of rendering it directly to the browswer but still as part of a html page?
The simplist solution is to use two pages like this:
a.aspx:
b.aspx: