|
-
Jan 3rd, 2003, 12:51 PM
#1
Thread Starter
Addicted Member
How to get an image in a picture box
how can i get an image from a url and put it in a picture box
for instance picturebox1 needs to have the image http://somewhere.com/img.gif how can i get it in there without having to save the image to my hard drive then placing it in the picture box?? thanks!!
-
Jan 3rd, 2003, 02:27 PM
#2
Frenzied Member
Dont gain the world and lose your soul
-
Jan 3rd, 2003, 06:53 PM
#3
Thread Starter
Addicted Member
do you got a link to one in vb.net or would you mind converting the code in c# to vb.net
-
Jan 3rd, 2003, 08:35 PM
#4
Frenzied Member
Sure. 
VB Code:
Imports System
Imports System.IO
Imports System.Net
Imports System.Text
'This import is required to gain access to the new namespace
Imports LoadImageFromWeb.ImageStream
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub btnLoadWebImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadWebImage.Click
'Loads a picture box with an image from a website
Const PATH_TO_IMAGE = "http://www.vbforums.com/images/ads/current.gif"
Dim xImage As ImageToDownload = New ImageToDownload(PATH_TO_IMAGE)
Dim xStream As MemoryStream = xImage.BeginDownload()
picFromWeb.Image = Image.FromStream(xStream)
End Sub
End Class
Namespace ImageStream
Public Class ImageToDownload
Dim sI2D_URL2Download As String
Const PREFIX = "http://"
Public Sub New(ByVal sURL As String)
Me.sI2D_URL2Download = sURL
End Sub
Public Function BeginDownload() As MemoryStream
Dim msImage As MemoryStream
Dim wcClient As WebClient = New WebClient()
If Not sI2D_URL2Download.ToLower().StartsWith("http://") Then sI2D_URL2Download = PREFIX + sI2D_URL2Download
msImage = New MemoryStream(wcClient.DownloadData(sI2D_URL2Download))
Return msImage
End Function
End Class
End Namespace
~Peter

-
Jan 6th, 2003, 12:59 AM
#5
Thread Starter
Addicted Member
Thanks a lot you are a big help!!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|