How to display the internet image in picturebox using HttpWebRequest
Hi,
I am beginner, and try it a long time and can not find the solution...
Just want show the picture which in the internet...I will try using HttpWebRequest, because it will using in the mobile..
Thx
Re: How to display the internet image in picturebox using HttpWebRequest
you need to use the HttpWebResponse & then it's GetResponseStream
then you can create an image using Image.FromStream.
like this ....
VB Code:
[COLOR=Blue]Dim[/COLOR] request [COLOR=Blue]As[/COLOR] HttpWebRequest = [COLOR=Blue]DirectCast[/COLOR](HttpWebRequest.Create("http://www.google.co.uk/intl/en_uk/images/logo.gif"), HttpWebRequest)
[COLOR=Blue]Dim[/COLOR] response [COLOR=Blue]As[/COLOR] HttpWebResponse = request.GetResponse
[COLOR=Blue]Dim[/COLOR] img [COLOR=Blue]As[/COLOR] Image = Image.FromStream(response.GetResponseStream)
PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize
PictureBox1.Image = img
response.Close()
Re: How to display the internet image in picturebox using HttpWebRequest
Re: How to display the internet image in picturebox using HttpWebRequest
more one question:
How can I save the picture into the directory, using this method!!
Re: How to display the internet image in picturebox using HttpWebRequest
Theres also a codebank submission by kleinma that shows how to do it using the System.Net.Webclient...
http://www.vbforums.com/showthread.php?t=387841
Re: How to display the internet image in picturebox using HttpWebRequest
Thanks for your reply...
I need to use httpRequest to do it, because I need use in the pocket pc
Re: How to display the internet image in picturebox using HttpWebRequest
I'm using VB 2005 Basic Express.
I tried to enter this code, but I get the following error:
"Type 'HttpWebrequest' is not defined"
Do I need a different version to be able to use "HttpWebRequest"?
Thanks!
Re: How to display the internet image in picturebox using HttpWebRequest
Quote:
Originally Posted by Vmax1001
I'm using VB 2005 Basic Express.
I tried to enter this code, but I get the following error:
"Type 'HttpWebrequest' is not defined"
Do I need a different version to be able to use "HttpWebRequest"?
Thanks!
No, you probably just didn't fully qualify it with its namespace
Dim MyRequest as System.Net.HttpWebRequest
Re: How to display the internet image in picturebox using HttpWebRequest
Quote:
Originally Posted by simoms
more one question:
How can I save the picture into the directory, using this method!!
You can save a picture to file using the picturebox itself...
Lets say your picturebox is called Picturebox1...
VB Code:
picturebox1.Image.Save([i]File Name Here[/i])