?
Solved

width and height for  HTML <IMG> tag from VB

Posted on 1997-06-17
8
Medium Priority
?
340 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
[X]
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
  • 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
Industry Leaders: 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!

 

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
 
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 600 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

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!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

801 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