By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,369 Members | 1,550 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,369 IT Pros & Developers. It's quick & easy.

Problem writing bitmap image to HTTP response stream.

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
<bu*****@sympatico.ca> wrote in message
news:ek**************@TK2MSFTNGP10.phx.gbl...
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

Nov 18 '05 #2

P: n/a
bu*****@sympatico.ca wrote:
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,

--
Joerg Jooss
jo*********@gmx.net
Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.