Google got exact place for me here, but the food was not yet ready to be fed. It is really annoying to see large number of GDI+ System.Drawing Exceptions. So, here is what I stopped at fighting the those exceptions-
protected void Page_Load(object sender, EventArgs e)
{
//Get the stream
Stream input = (Stream)Request.InputStream;
Bitmap bmp = new Bitmap(input);
// Clear current content and set returned content type
Response.Clear();
Response.ContentType = "image/jpeg";
// Save to the Response.OutputStream object
bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
bmp.Dispose();
Response.End();
}
I get, 'Parameter not valid' on line 6. Doesn't seem to work. Any ideas?
ReplyDeleteI see this could be a memory leak issue.
ReplyDeleteIf you're on .Net 4.0 framework, try resetting current location in the stream-
MemoryStream ms = new MemoryStream();
Request.InputStream.CopyTo(ms);
ms.Seek(0, SeekOrigin.Begin);
Bitmap bmp = new Bitmap(ms);