Get a Bitmap from  html

Posted on 2003-03-01
Medium Priority
Last Modified: 2013-12-03
Is there an way to get a Bitmap from a URL? (not to take a screenshot!)

Question by:MarkusKTC
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8047386

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")

Author Comment

ID: 8047424
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.


Expert Comment

ID: 8048842
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.

'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
          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.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 16

Expert Comment

ID: 8049018

Expert Comment

ID: 8900947
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?

Expert Comment

ID: 8904150
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.
LVL 49

Expert Comment

ID: 9001792
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

Accepted Solution

Mindphaser earned 0 total points
ID: 9109109
Force accepted

** Mindphaser - Community Support Moderator **

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question