Solved

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

Posted on 2009-05-06
6
5,367 Views
Last Modified: 2013-11-08
I have an image in System.Drawing.Image control

How can I show it in
System.Web.UI.WebControls
0
Comment
Question by:KaranGupta
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 39

Expert Comment

by:abel
ID: 24312085
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
 
LVL 21

Expert Comment

by:Tapan Pattanaik
ID: 24312091
hi  KaranGupta,

                        follow the below link.


http://forums.asp.net/t/578390.aspx
0
 

Author Comment

by:KaranGupta
ID: 24312102
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:KaranGupta
ID: 24312105
Hi tapanpattanaik

I have already seen that link but this is not useful.
0
 
LVL 39

Accepted Solution

by:
abel earned 500 total points
ID: 24312126
> 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
 
LVL 39

Expert Comment

by:abel
ID: 24312135
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Reactjs with .NET 3 78
Coding for the first time 9 70
Asp.Net Session Question 2 36
Using sample Autorize.net c# simple example 1 30
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question