convert System.Drawing.Image to System.Web.UI.WebControls.Image

I have an image in System.Drawing.Image control

How can I show it in
System.Web.UI.WebControls
KaranGuptaAsked:
Who is Participating?
 
abelConnect With a Mentor Commented:
> Now I want to load this image to the Image web control How can I do that
you cannot. The webcontrol takes a link to an image (which is why I suggested to store it locally). The other alternative is to create a HttpRequestHandler that creates this image on-the-fly and serves it as a link to your Image web control.

A web page is toally different then a winforms application. It's components work by just laying themselves out on the canvas of the HTML page. And HTML cannot do images, it can only do urls to images. Which is what the Image web control does: it renders itself to the html page as an img tag with a src attribute, which must be present on the server. That "present on the server" can arranged "on the fly" if need be, but then you need a HttpRequestHandler.
0
 
abelCommented:
My choice of action would be (assuming they are not in the same application, because you seem to be mixing ASP.NET with WinForms) is to save the Drawing.Image to disk as JPG or PNG and to add that as a link to the Web.UI.WebControls.Image.
0
 
Tapan PattanaikSenior EngineerCommented:
hi  KaranGupta,

                        follow the below link.


http://forums.asp.net/t/578390.aspx
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
KaranGuptaAuthor Commented:
Hi abel

My requirement is not to save the image on disk

Actually My scenario is I have an image.

I have converted the image into byte[] using this code

Bitmap bmp = new Bitmap("c:\\empty.jpg");        
        byte[] rawData;
        using (MemoryStream ms = new MemoryStream())
        {
            bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            rawData = ms.GetBuffer();
        }

Now I want to load this image to the Image web control How can I do that
0
 
KaranGuptaAuthor Commented:
Hi tapanpattanaik

I have already seen that link but this is not useful.
0
 
abelCommented:
There are many such code examples on the net (google for request handler image). One such examples is this one, it includes a step-by-step on how to configure IIS: http://www.c-sharpcorner.com/UploadFile/desaijm/HTTPHandlersForImages11152005062705AM/HTTPHandlersForImages.aspx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.