Set Image Control to Bitmap

M

MikeB

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 without haveing to save the
bitmap as a file. Is this possible? Currently, I just display the bitmap
by calling Bitmap.save however, if users do not know to click the image they
can not see the full size. If I can create a bitmap from the stream I know
the size so I can set the properties of a image control and then display the
bitmap in the image. Does this make since or am I going about this the
wrong way? So in a nutshell, I am pulling images from a DB and want to
display the full size without having to actuall save the image to a file.
Any pointers?

TIA
 
G

George Ter-Saakov

You can make an mypage.aspx page that returns bitmap (not HTML)
1. You need to set ContentType = "img/gif"; or (jpg)
2. You need to set ContentLength to the size of the image
3. Use Response.BinaryWrite to output the image. Or since Response is a
Stream you can do Bitmap.Save(Response);

in your HTML you write <img src="mypage.aspx">


PS: It's more efficient to use handler for that task. mypage.ashx. But aspx
will work too if you fill more comfortable with aspx.

George.
 

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

Top