
January 16th, 2007, 01:17 PM
|
|
Registered User
|
|
Join Date: Aug 2006
Posts: 11
Time spent in forums: 5 h 9 m 58 sec
Reputation Power: 0
|
|
|
Don't worry. I solved it myself
After much playing around, I got this. It may be useful for anyone else who is interested:
Code:
protected virtual void ProcessRequest(HttpListenerContext Context)
{
HttpListenerRequest Request = Context.Request;
HttpListenerResponse Response = Context.Response;
// This bit creates the image and is obviously unique to my app
int xx = Convert.ToInt32(Request.QueryString["x"]);
int yy = Convert.ToInt32(Request.QueryString["y"]);
DrawMap(buff,xx,yy,594,339,gBumps);
//Save out image as file
buff.Save("c:\\temp.png", System.Drawing.Imaging.ImageFormat.Png);
//Open image as byte stream to send to requestor
FileInfo fInfo = new FileInfo("c:\\temp.png");
long numBytes = fInfo.Length;
FileStream fStream = new FileStream("c:\\temp.png", FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fStream);
byte[] bOutput = br.ReadBytes((int)numBytes);
br.Close();
fStream.Close();
Response.ContentType = "image/png";
Response.ContentLength64 = bOutput.Length;
Stream OutputStream = Response.OutputStream;
OutputStream.Write(bOutput, 0, bOutput.Length);
OutputStream.Close();
}
|