How to Put a Bitmap into an Image

T

Tina

I have a System.Drawing.Bitmap myImage;
I also have a webcontrols.Image on my web page.
I want to put the bitmap into the image but the image can only get it's
bitmap from ImageURL which can be a fileName or a webpage that writes. But
I don't want to have to write my bitmap to a file, I just want to put it
into the image.

Can this be done? It seams that an image control should be designed to that
it could accept a bitmap (duh) but I can't seem to make that happen.
Thanks,
T
 
M

Mark Fitzpatrick

You have the bitmap dump into the outputstream instead of a file. You would
use a page such as GenerateImage.aspx, maybe with a parameter to help you
determine which image to make such as when you're making a graph for product
sales by year. Then the image control, or any normal html image element, can
point to this GenerateImage.aspx page. With a bitmap, all you need to do is
call the Save method of the bitmap and pass to it the Response.OutputStream
property. That will dump it to the stream going to the browser. One thing to
keep in mind though, you can't have one bit of HTML in the
GenerateImage.aspx page itself. If you do it will end up mangling the
output. You just need your page directive at the tope and then put
everything else in codebehind.

The image control can't accept a bitmap because there is no way to do this
in HTML. If this were a windows form image, no problem, but with HTML
images, which the image control essentially is a custom wrapper for, you
can't embed any sort of binary data since the page is simple ASCII text.
 
T

Tina

Mark,
That is the way we have been doing it - using another aspx page to write to
the output stream. It works fine until you put the Image control into an
ATLAS UpdatePanel. Then it still works if the user is using I.E. 6. But if
the user is using I.E. 7 the picture doesn't change (although the aspect
ratio does change according to the new pictures aspect ration).

I was just hoping there was some way of getting around the "ATLAS bug" by
directly putting the object into the control.

thanks,
T
 

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,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top