Guest hmcheung Posted September 7, 2003 Report Posted September 7, 2003 Hi, I've searched for quite a while but still can't find any luck in grabbing an image from web into a picturebox of my .NET CF application. :) I've read that we've to get a binary stream and then put it into a byte[], then create a second stream to in turn create a Bitmap, then assign this Bitmap to the picturebox. Is there any examples on that? I've tried a bit but I only get the 'Not Supported' error... thanks!
Guest NeilC_MVP Posted September 7, 2003 Report Posted September 7, 2003 To populate a PictureBox with an image from the World Wide Web, you will first need to retrieve the binary stream of the image from the web, then use it to create a new instance of the Bitmap class, which you then can assign to the picturebox's Image property. The code below does just that: string url = "http://smartphone.modaco.com/templates/midMoDaCoDude/images/smiles/icon_sad.gif"; HttpWebRequest req (HttpWebRequest)WebRequest.Create(url); try { HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); if(resp.StatusCode == HttpStatusCode.OK) { pictureBox1.Image = new Bitmap(resp.GetResponseStream()); } } finally { resp.Close(); } --Neil -- Neil Cowburn Microsoft Windows Embedded MVP (.NET Compact Framework) www.contentmaster.com | www.opennetcf.org
Guest hmcheung Posted September 8, 2003 Report Posted September 8, 2003 Yes this is it! thanks Neil ~ :) ;) :D
Guest Paul [MVP] Posted September 8, 2003 Report Posted September 8, 2003 Ad a nice topical example too! Nice one Neil! :) P
Guest graham Posted December 31, 2003 Report Posted December 31, 2003 Would such an application (ie, one that hits a URL in the manner described) work on an Orange E200 without being signed...? Or would it be deemed to be requiring "privileged" access because it was going out to the internet?
Guest NeilC_MVP Posted December 31, 2003 Report Posted December 31, 2003 Y'know, I've not tried this yet. Although, in theory it shouldn't require privileged rights or it would put a stop to Microsoft's efforts to demonstrate that smart devices (and Smartphone in particular) are first class XML Web Service clients.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now