Dim client As New System.Net.WebClient()
Dim stream As New System.IO.MemoryStream()
Dim data As Byte() = client.DownloadData("http://somewebsite/someimage.jpg")
client.Dispose()
stream.Write(data, 0, data.Length)
pictureBox.Image = Image.FromStream(stream)
After writing the data to the stream, the stream's position will be pointing at the end of the stream and before reading from the stream, you would normally need to set the position to the beginning of the stream (stream.Position = 0). As it turns out, Image.FromStream will do this internally, and restore the stream position after loading the image. - Fredrik Mörk
This is a super simple way of inserting an image on your form.
No comments:
Post a Comment