在没有下载的网址中设置图像框中的图像

时间:2013-02-12 18:21:15

标签: vb.net image url

我正在vb.net上写一个程序来收听广播。

如何制作,以便我可以加载互联网图像,而不必将其永久下载到硬盘。因为如果我这样做

PictureBox1.BackgroundImage = "http://www.bbc.co.uk/radio1/chart/assets/a/aviciivsnickyromero/single/icouldbetheonenicktim/artwork/26948.jpg"

但它会说错误2'String'类型的值无法转换为'System.Drawing.Image'。

1 个答案:

答案 0 :(得分:13)

将其下载到内存中的流。

Dim tClient as WebClient = new WebClient

Dim tImage as Bitmap = Bitmap.FromStream(New MemoryStream(tClient.DownloadData(url)))

PictureBox1.Image = tImage