473,499 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem writing bitmap image to HTTP response stream.

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
2 9862
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3561
by: CroDude | last post by:
Hi all! I have problems when writting bitmap to a byte array and after reading it back form byte to Bitmap object. What I do is this: First I throw Bitmap to a memory-stream and then I write it...
1
7119
by: jty202 | last post by:
I know alot of people have the problem with indexed pixel format. I hope someone can show me the solution to this.I am have problem with graphics with the following code giving the error: "A...
1
4663
by: Fahad Aijaz | last post by:
Hi, I am trying to display a Png image via ASP .NET. I get the image from the stream, creates the Bitmap, set the content type to Image/Png, but it give an error. If I set the content type to...
2
2570
by: Jeronimo Bertran | last post by:
Hello, I am using a rendering aspx page to display a database image on an Image control. When the database record is retrieved, I am saving the bitmap to a session variable for the rendering...
7
2283
by: Nathan Sokalski | last post by:
I am having a problem saving an image with the same name it originally had. I have two similar versions of my code, one in which I close the FileStream used to open the original image before saving,...
6
2514
by: Dave Harvey | last post by:
I have developed a standard .NET control which displays medical images and works fine in applications, but increasingly, my customers are wishing to use it in an ASP.NET environment, so I am...
23
5864
by: Peter | last post by:
I have a problem with a page show_image.asp that returns a jpg image under Windows XP Pro SP2. The page sets content type as: Response.ContentType = "image/jpg" While this works perfectly fine...
4
11125
by: MikeB | last post by:
Hello All, want to be able to pull images from the database and load them into a bitmap through a stream which I have working. I then want to take the bitmap and load it into a Image control...
5
1291
by: miladhatam | last post by:
hi i want to put the name of my site in corner of my images i've used from graphics and bitmap class and i have no problem with putting the text but it make problem with other works in my page...
0
7130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
4918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3090
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
295
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.