Jan 27th, 2003, 10:40 PM
#1
Thread Starter
Addicted Member
Picture Help ! (resovled)
I was wondering if anyone new how to grab an image from a URL. Lets say http://us.i1.yimg.com/us.yimg.com/i/ww/m6v9.gif that is just the yahoo.com top image. I want to take that image from the web and download it. The a user presses a button and the picturebox becomes that picture.
Or....
Say there is a form with a picture control, a text box, and a buttonm. The user types a url of a picture such as (http://us.i1.yimg.com/us.yimg.com/i/ww/m6v9.gif ) in the textbox and the presses the button. The picture gets loaded in the picture box.
Thanks for any help
Sean
Last edited by Stick; Jan 29th, 2003 at 01:16 AM .
Jan 27th, 2003, 10:45 PM
#2
Sleep mode
This from VBCodeBook ....
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
Jan 27th, 2003, 11:02 PM
#3
Thread Starter
Addicted Member
ahhh thanks but i need more help
I can't figure out how to make this work..
can anyone help
thanks
Jan 27th, 2003, 11:21 PM
#4
Sleep mode
umm, wait then ..........
Jan 28th, 2003, 12:03 AM
#5
Sleep mode
Attached Files
Jan 28th, 2003, 11:47 PM
#6
Thread Starter
Addicted Member
thanks..
I am stupid at vb..
I used to kinda know it now it is all BLAH!
thanks alot
Jan 29th, 2003, 12:02 AM
#7
Sleep mode
Jan 29th, 2003, 01:15 AM
#8
Thread Starter
Addicted Member
Jan 29th, 2003, 04:52 AM
#9
yay gay
in vb doing
dim MyClass as Class = new Class() isnt the same as
dim myClass as new Class()
?
\m/
\m/
Jan 29th, 2003, 01:08 PM
#10
Sleep mode
Originally posted by PT Exorcist
in vb doing
dim MyClass as Class = new Class() isnt the same as
dim myClass as new Class()
?
in this case , it seems same thing .
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