images using graphics class

  • Thread starter Thread starter Gav
  • Start date Start date
G

Gav

Hi all,

I'm trying to create a bitmap and then use outputstream to display the
picture:

objBitmap.Save(Response.OutputStream, ImageFormat.Jpeg);

It doesn't give me any errors although the web page comes up with lots of
characters in the page instead of a picture... I then added:

Response.ContentType= "image/jpeg";

I put this before the outputstream but it didn't make any difference, does
anybody know what I could be doing wrong?

Regards
Gav
 
Gav,

Is your page buffered? I seem to remember that if it is not, then the
headers would be already written, and you could not change the content type.

Hope this helps.
 
base.Response.ClearContent();
base.Response.ContentType = "image/jpeg";
objBitmap.Save(Response.OutputStream, ImageFormat.Jpeg);
// Important to cancel page HTML rendering:
base.Response.End();
 
Thanks for the help but I never could get this to work. I'm not sure why. I
think it may have something to do with the fact I'm trying to do it inside a
web user control (I'm not sure). But anyway I got around it by saving it to
a file and simply displaying the file.

Thanks again
Gav
 

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

Similar Threads


Back
Top