views:

81

answers:

1

I have an .aspx file that outputs an image using the following methods:

 Server.MapPath("somefile.png")
 Response.ContentType = "image/png";
 Response.WriteFile(fileURI);

I have a function that rotates the image by 0-360 degrees and returns it as a bitmap.

How can I take this in-memory bitmap and then write it out to the client as a PNG?

+2  A: 
var m = new MemoryStream();
bitmap.Save(m, ImageFormat.Png);
//might want to set correct mime type here.
Response.BinaryWrite(m.ToArray());
Response.End();
David Kemp
You mean Response.BinaryWrite.
configurator
@configurator - fixed. Thanks - been doing too much ASP.NET MVC ;)
David Kemp