Results 1 to 5 of 5
  1. #1
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Finding the size of an image (VBA Office 2000)-MULTI-F

    I have a multipage control on a form, and wish to use its .picture property to display a graphic. The main glitch is to get the multipage and the form to wrap snuggly around the picture.

    What I've done so far is to pull the picture into an autosizing image box, hidden under the multipage, then set the height & width of the multipage and the form to those of the image control. This is only half satisfactory for these reasons:

    1. The picture is sometimes too big for the image control, so gets cropped.

    2. The height of the multi and the form include the tabs, titlebar, frame etc. So far I've been accounting for these by trial & error, adding 10%, 12% etc. But I fear this may not be dependable.

    I would appreciate any advice from anyone who has had experience wrapping controls around images. I was hoping to find an API call to get the metrics (height, width) of the JPEG image before sizing/drawing the controls, but have not been able to find one.

    thanks

    Alan

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Finding the size of an image (VBA Office 2000)-MULTI-F

    Yes, where does Explorer (in Windows 2000) get the information in the Summary tab of the properties dialog? Judging by how slow it is to come up, I suspect it is running the image through some program, perhaps the associated Photo Editor, to get it. If the speed is acceptable to you, we just need to figure out the interface...
    Attached Images Attached Images

  4. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding the size of an image (VBA Office 2000)

    Well, having done a bit of hunting since this post, I imagine it's not from a simple API routine. The JPEG format is unlike bmp, gif,... in that the data/info is stored in delimited segments. This means that there's no particular place to look for, say, height & width. You have to locate the right segment, then the right offset, then pull the byte values. I have written a routine to do this (which doesn't work <img src=/S/smile.gif border=0 alt=smile width=15 height=15>) and can post if of interest (when working).

    I found this proposed solution to my problem, but could not get it to work:
    ------------------------
    ' before this get the file name and put it into: Myfile
    ' create an Image control and set the Visible property to False
    ' and the Stretch prperty to false
    ' call the object Image1

    Image1.Picture = LoadPicture(MyFile)
    h% = Image1.Height
    w% = Image1.Width
    -------------------------
    It was for VB, and VBA doesn't seem to have this "stretch" property. Played round with some other properties, but no joy [img]/forums/images/smilies/sad.gif[/img]

    This one has been an interesting challenge!

    Alan

  5. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Finding the size of an image (VBA Office 2000)

    Look for the SizeMode property.
    Charlotte

  6. #5
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding the size of an image (VBA Office 2000)

    Hi Charlotte

    I've tried (I believe) all combinations & permutations of Properties to no avail. Surely you don't mean that silly little PictureSizeMode - fmPictureSizeModeStretch? No, I'm sure that wouldn't... well, I'm sure it didn't work like that yesterday. Somebody must have changed it overnight <img src=/S/smile.gif border=0 alt=smile width=15 height=15>.

    At least I learned quite a bit about JPEG on the way, and playing with a binary stream! Such is life. Thanks Charlotte.

    Alan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •