Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load an image from a url into a PictureBox

I want to load an image into a PictureBox. This is the image I want to load: http://www.gravatar.com/avatar/6810d91caff032b202c50701dd3af745?d=identicon&r=PG

How do I do this?

like image 667
vishnu Avatar asked Nov 01 '10 16:11

vishnu


2 Answers

The PictureBox.Load(string url) method "sets the ImageLocation to the specified URL and displays the image indicated."

like image 183
stuartd Avatar answered Oct 15 '22 08:10

stuartd


Try this:

var request = WebRequest.Create("http://www.gravatar.com/avatar/6810d91caff032b202c50701dd3af745?d=identicon&r=PG");  using (var response = request.GetResponse()) using (var stream = response.GetResponseStream()) {     pictureBox1.Image = Bitmap.FromStream(stream); } 
like image 30
Pieter van Ginkel Avatar answered Oct 15 '22 09:10

Pieter van Ginkel