Solved

width and height for  HTML <IMG> tag from VB

Posted on 1997-06-17
8
310 Views
Last Modified: 2008-03-06
Does anybody know how I can determine the width/height
of a gif picture in the measurements that a Html browser
expects to see in
<IMG height="50" width="120" SRC=".......>
Please give me some code!!!
0
Comment
Question by:VB-tinkerer
  • 4
  • 4
8 Comments
 
LVL 7

Expert Comment

by:tward
ID: 1427398
If you have read the line in then simply use:

Position = Instr(1,TheLine,"height",0)
SpacePosition = Instr(Position, TheLine, " ", 0)

Height = Mid(TheLine, Position+8, SpacePosition-(Position+8))

This should get the height then do the same thing with some different numbers to get the width.
0
 

Author Comment

by:VB-tinkerer
ID: 1427399
I obviously didn't express myself very well.  What I want to do is
load a picture in VB and then determine the width number and the height number of the picture, so that I can use it in my html statement:

      <IMG height="50" width="120" SRC=".......>

In other words I want to be able to determine what the numbers should be so that I can write the above statement
0
 
LVL 7

Expert Comment

by:tward
ID: 1427400
Oh, can't you just load it into a picture box that has the autosize set to true, what happens is the picture box will shrink or expand to fit the image loaded into it, then just take the width and height from the size of the picturebox..?  I know VB 5.0's pictureboxes supports GIF and JPEG but you didn't state which version of VB you were using.
0
 

Author Comment

by:VB-tinkerer
ID: 1427401
I am quite familiar with the .width and .height properties of the picture box.  However none of the measurements available seem to correspond to the measurements required in the HTML pages.  I tried to find a conversion factor - but the conversion factor seems to be non-constant:

e.g.  Picture Term_Small.gif

                       VB                                   HTML
height            990                                   62
width            1470                                   94

Home.gif
height             705                                    47
width               420                                   24

As the original question states:  I want some code that gives me
the MEASUREMENTS THAT A HTML BROWSER EXPECTS TO SEE
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 7

Expert Comment

by:tward
ID: 1427402
Since the Picturebox give the values in twips by default take the
width/screen.twipsperpixelX
height/screen.twipsperpixelY

or set your form to be in Pixels ScaleMode.

The Height and Width of Images in HTML is needed in Pixels.
0
 

Author Comment

by:VB-tinkerer
ID: 1427403
Thanks - this seems to work fine.
If you know a faster way to do this (e.g. reading the .GIF file directly and getting the information from there) that would be great!!

Do you know how I now can award you the points?  I don't seem to have a rating possibility anymore?

Thanks again.
0
 
LVL 7

Accepted Solution

by:
tward earned 150 total points
ID: 1427404
You couldn't give the points because I only put that in as a comment.  I do have a book here that tells what the header is:

DB   GIF87a
DW  SCREEN_WIDTH
DW  SCREEN_DEPTH
DB  GLOBAL_FLAG_BYTE
DB  BACKGROUND_COLOR
DB  0

       COLOR MAP - GLOBAL_FLAG_BYTE tells you how many
                                there will be (First 3 bits of the Byte) you                                        need to add 1 to it and shift left 3 times.
                                Maximum value is  is 8 and one shifted left
                                by 8 is 256.
       LOCAL_DATA
                               DB ,
                               DW IMAGE_LEFT
                               DW IMAGE_TOP
                               DW IMAGE_WIDE
                               DW IMAGE_DEEP
                               DW LOCAL_FLAG_BYTE

IMAGE_WIDE and IMAGE_DEEP are what you would need.

This all seems complicated and I don't have much time mess with it but it comes from an older book called Bit-Mapped Graphics by Steve Rimmer (ISBN 0-8306-3558-0) The Copyright on the book I have is 1990 First Edition Six Printing.

They give examples in C and Assembly on how to decode a GIF as Well as BMP and TIFF Files.

0
 

Author Comment

by:VB-tinkerer
ID: 1427405
Thanks - I'll check that out later.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now