Here's my situation: I have a console application that creates screenshots of webpages in a bitmap format and then saves it to a database as a byte array.
Then I have a Generic Handler that basically gets the byte array and then returns the image (it is set as the html image source). Here is the code:
public void ProcessRequest(HttpContext context)
{
int id = Convert.ToInt32(context.Request.QueryString["Id"]);
context.Response.ContentType = "image/jpeg";
MemoryStream strm = new MemoryStream(getByteArray(id));
byte[] buffer = new byte[4096];
int byteSeq = strm.Read(buffer, 0, 4096);
while (byteSeq > 0)
{
context.Response.OutputStream.Write(buffer, 0, byteSeq);
byteSeq = strm.Read(buffer, 0, 4096);
}
}
public Byte[] getByteArray(int id)
{
EmailEntities e = new EmailEntities();
return e.Email.Find(id).Thumbnail;
}
(I did not write that code myself)
The Image although is of course still returned as a bitmap and is far too big in size. Which is why I wanted to return it as a compressed jpg or png, as long as it is small.
So my question to you: What possibilities are there to do this without having to save the image to the filesystem directly?
Thanks in advance for your responses.