Creating an image from a URL.
This example shows how you can download and create an Image based on a URL.
Option Strict On
Option Explicit On
Imports System
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Net
Imports System.IO
Public Class WinApp
Inherits System.Windows.Forms.Form
<STAThread()> _
Shared Sub Main
Application.Run(new WinApp())
End Sub
Dim m_pb As PictureBox
Public Sub New
Me.Text = "This is my form"
m_pb = new PictureBox()
m_pb.Location = new Point(0,0)
m_pb.Image = GetURL("http://radio.weblogs.com/0110109/images/dotnet.gif")
m_pb.Size = m_pb.Image.Size
Me.ClientSize = m_pb.Image.Size
Me.Controls.add(m_pb)
End Sub
Private Function GetURL(url as String) As Bitmap
Dim wc As WebClient = new WebClient()
Dim strm As Stream = wc.OpenRead(url)
Dim bmp As BitMap = new Bitmap(strm)
strm.Close()
Return bmp
End Function
End Class