Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Allow user to browse for an online image 1

Status
Not open for further replies.

AndyGroom

Programmer
May 23, 2001
972
0
0
GB
I've got a dialog box that allows the user to highlight an image and see a thumbnail of it and the dimensions. I need to extend this feature to allow users to enter the URL of an online image and show a thumbnail of it and the dimensions.

If I use a WebBrowser object to navigate to the image's URL, how can I save the resultant image locally so that I can use the existing engines to create a thumbnail and get the dimensions? I somehow need to get a handle to the bitmap shown within the webbrowser object such that I can copy it into a PictureBox or something...

Any ideas?

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Andy, not 100% sure if this is what you're after but you can get the file using WinHttpRequest:
Code:
Dim WinHttpReq as Object
Dim b() As Byte

Set WinHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")

    
    WinHttpReq.Open "GET", "[URL unfurl="true"]http://www.tek-tips.com/images/star.gif",[/URL] False  ' Send the HTTP Request.
    WinHttpReq.Send

    If WinHttpReq.Status = 200 Then

        Open "c:\star.gif" For Binary As #1
             b() = WinHttpReq.ResponseBody
             Put #1, 1, b()
        Close
    
        Picture1.Picture = LoadPicture("c:\star.gif") ' optional display image
    
    End If
Set WinHttpReq = Nothing
Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
That, my friend, is exactly what I'm after.

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
I posted an Inet variant of that about 8 years ago: thread222-93819 and then 'improved' about 6 years ago in thread222-708828 by eliminating the need to create a file on disk. And then got trumped by a solution that Hypetia found (also given in the latter thread)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top