Displaying Picture from Google Images into Picturebox using httpwebrequest ~ error
Hey guys/gals I have an app where I want to be able to view an image into a picture box by entering the URL of the image.
I keep get error of:
http://img522.imageshack.us/img522/6194/pciture.jpg
Here is my code:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim request As Net.HttpWebRequest = DirectCast(Net.HttpWebRequest.Create("http://www.google.com/imgres?q=how+to+make+pizza&um=1&hl=en&sa=N&biw=1152&bih=662&tbm=isch&tbnid=wPjdN6FblAIplM:&imgrefurl=http://italianfood.about.com/od/breadspizza/ss/pizzaovn_2.htm&docid=6hmsagY8r4juxM&imgurl=http://0.tqn.com/d/italianfood/1/0/9/E/doughbls.jpg&w=400&h=300&ei=VSmgTua3FMPk0QH4uN20BA&zoom=1&iact=rc&dur=31&sig=115939356797183712562&page=1&tbnh=132&tbnw=177&start=0&ndsp=15&ved=1t:429,r:3,s:0&tx=60&ty=129"), Net.HttpWebRequest)
Dim response As Net.HttpWebResponse = DirectCast(request.GetResponse, Net.HttpWebResponse)
Dim img As Image = Image.FromStream(response.GetResponseStream())
response.Close()
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
PictureBox1.Image = img
End Sub
End Class
Any idea on why this doesn't work?
If I use this address it works but nothing else....
http://www.google.co.uk/intl/en_uk/images/logo.gif
Re: Displaying Picture from Google Images into Picturebox using httpwebrequest ~ erro
SAVE ALL in this project and DEBUG it and then try to open DEBUGed file EXE
I think it will not give yyou errors...
Re: Displaying Picture from Google Images into Picturebox using httpwebrequest ~ erro
The problem is, your link is not just outputting an image, instead a webpage with the requested image in a jQuery popup or something like that.
If you used this link: http://0.tqn.com/d/italianfood/1/0/9/E/doughbls.jpg
It would have given you the image !
:wave:
Re: Displaying Picture from Google Images into Picturebox using httpwebrequest ~ erro
Works like a charm!!!! Thanks
Yeah I didn't think about the whole page trying to load..makes since now that I think about it!!!..
Thanks guys for the help.