Solved

width and height for  HTML <IMG> tag from VB

Posted on 1997-06-17
8
299 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 7

Expert Comment

by:tward
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks - I'll check that out later.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 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

16 Experts available now in Live!

Get 1:1 Help Now