Problem writing bitmap image to HTTP response stream.

G

Guest

Hello All,

I am writing a web application that reads a bitmap from a file and outputing
it to a HTTP response stream to return the image to the requesting client.
The image file is a regular bitmap file (filename.bmp)

I am experiencing some difficulties with writing a bitmap to a http response
stream.
I load the bitmap from a file. and i use the following snippet of code to
write to HTTP response stream

Bitmap bmp;
//...load bmp with bitmap data from file
Response.ContentType = "image/bmp";
bmp.Save (Response.OutputStream, ImageFormat.Bmp);

After this code is called, I get an Exception message, "A generic error
occurred in GDI+.".

I know that the bitmap is ok since I am able to save it back to file again
with:
bmp.Save("somefilename.bmp",ImageFormat.Bmp);

Would anyone be able to shed some light with this problem.


Thanks
 
S

S. Justin Gengo

Buzlite,

If you'd like I have an image manipulation project (Visual Studio.NET v.1.1)
that you may download from my website, www.aboutfortunate.com.

The project is free and includes all source code. It includes an interface
for uploading, manipulating, and then saving an image. During the
manipulation of the image the image is retrieved from an in memory stream
which is output using Response.Content type. Looking at the code there may
give you a clue as to what needs to be changed in your code.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
J

Joerg Jooss

Hello All,

I am writing a web application that reads a bitmap from a file and
outputing it to a HTTP response stream to return the image to the
requesting client. The image file is a regular bitmap file
(filename.bmp)

I am experiencing some difficulties with writing a bitmap to a http
response stream.
I load the bitmap from a file. and i use the following snippet of
code to write to HTTP response stream

Bitmap bmp;
//...load bmp with bitmap data from file
Response.ContentType = "image/bmp";
bmp.Save (Response.OutputStream, ImageFormat.Bmp);

You could try another API instead, e.g. HttpResponse.WriteFile().

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top