Public Function GetImage(ByVal strURL As String) As Image
'Requires:
' Imports System.net
' Imports System.IO
'Call:
' Using a picture box -
' PictureBox1.Image = GetImage(imagesourceURL)
' PictureBox1.Image = GetImage("http://www.aintitcool.com/media/konghorn.gif")
'Possible Uses:
' Retrieve and save a timed webcam image - such as the Mount St. Helens Volcano Cam.
' Save the image to a file with a timestamp in the file name, then play back.
Dim objStream As Stream = Nothing
Dim objRequest As HttpWebRequest = CType(WebRequest.Create(strURL), HttpWebRequest)
Dim objResponse As HttpWebResponse = CType((objRequest).GetResponse(), HttpWebResponse)
objStream = objResponse.GetResponseStream()
Return Image.FromStream(objStream)
End Function
|