Connecting Tech Pros Worldwide Forums | Help | Site Map

Problem writing bitmap image to HTTP response stream.

Guest
 
Posts: n/a
#1: Nov 18 '05
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. Justin Gengo
Guest
 
Posts: n/a
#2: Nov 18 '05

re: Problem writing bitmap image to HTTP response stream.


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
<buzlite@sympatico.ca> wrote in message
news:ekbIBvShEHA.2908@TK2MSFTNGP10.phx.gbl...[color=blue]
> 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
>
>[/color]


Joerg Jooss
Guest
 
Posts: n/a
#3: Nov 18 '05

re: Problem writing bitmap image to HTTP response stream.


buzlite@sympatico.ca wrote:[color=blue]
> 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);[/color]

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

Cheers,

--
Joerg Jooss
joerg.jooss@gmx.net
Closed Thread