• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

Get a Bitmap from html

Is there an way to get a Bitmap from a URL? (not to take a screenshot!)

Thanks
0
MarkusKTC
Asked:
MarkusKTC
1 Solution
 
DocMCommented:

Dim strURL As String, urldata() As Byte

strURL = "URL of Bitmap"

On Error Resume Next
urldata() = Inet1.OpenURL(strURL, icByteArray)
Open "c:\tempBitmapFile.tmp" For Binary Access Write As #1

Put #1, , urldata()
Close #1

'Load Bitmap from file
Set Picture1.Picture = LoadPicture("c:\tempBitmapFile.tmp")
0
 
MarkusKTCAuthor Commented:
Sorry, My Question was not very precisios. I need a Bitmap from a whole web site like this, as you see it in the Browser.

I tried it with the Webbrowser in VB but i found no possibility (only Screenshot, Screen Api) to do this.

0
 
J-ManCommented:
I'm still not exactly clear on what you want.
If you want to get images from a web page see below.  If you want to copy exactly what the webbrowser displays into a bitmap than I suggest copying the browser object to the clipboard and then put it in a picturebox and save it.  I can probably show code for this if necessary.

'Code:
'Getting images from a web page.
'You need an Internet-Transfer-Control on your form (I'm assuming the InetTC name is Inet1.)
Dim strURL as String
Dim strHTML as String
Dim lIndex as Long
Dim strImageURL() as String
Dim lImageIndex as Long

'Set the URL address
strURL = "www.mywebpage.com/thewebpageaddress.htm" 'change string to desired webpage

'Setup the Inet Control
Inet1.URL = strURL
Inet1.Password = ""
Inet1.UserName = ""

'Get the HTML code (must have active net connection)
strHTML = Inet1.OpenURL 'This will load the webpage HTML code as a string.

'Parse the HTML code for image URLs
lImageIndex = 0
ReDim strImageURL(1)
For lIndex = 0 to (Len(strHTML) -1)
     'Find image URL (the HTML code will look something like <img src="www.mywebpage.com/thepage/theimage.bmp">)
     If Mid(strHTML, lIndex, 9) = "<img src=" then
          lIndex = lIndex+10 'I'm assuming the quotation mark is the next character, you might want to check.
          ReDim Preserve strImageURL(lImageIndex + 1)
          Do While (Mid(strHTML, lIndex ,1) <> chr(34)) 'chr(34) is the quote character
               strImageURL(lImageIndex) = strImageURL(lImageIndex) + Mid(strHTML, lIndex, 1)
               'might want something here to make sure you don't get stuck in the loop
          Loop
          lImageIndex = lImageIndex + 1
     End If
Next lIndex


'You should now have a list of image URLs in the strImageURL() array.  You could further parse this list for only .bmp files.
'lImageIndex will be the count of URLs in the array from 0 to lImageIndex-1
'This code can certainly be optimized.  Look at some of the string comparison functions, and maybe the For Each command.
'After you have a list of URLs you can use DocM's code to store and load the bmp.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Richie_SimonettiIT OperationsCommented:
Hearing...
0
 
CleanupPingCommented:
MarkusKTC:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
J-ManCommented:
I'd be cool with a split between DocM and myself.
We need elaboration from MarkusKTC to help any further.

P.S. Markus, if you found a different solution to your question, it would be nice to post it here.  I'm not sure if you can get points for answering your own question though.
0
 
DanRollinsCommented:
MarkusKTC, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Refund points and save as a 0-pt PAQ.
    *** thanks for the input J-Man, but neither post answers the question.

DanRollins -- EE database cleanup volunteer
0
 
MindphaserCommented:
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now