Re-size an image to fit

R

Rod Behr

Selecting a product from a combo box assigns a filename and path as a string
value to the .picture attribute of an image frame.

How would I go about programatically getting the dimensions of the image
file and re-sizing the frame to fit the image?
 
S

Stephen Lebans

The simplest method is to load your pic into the Image control and then
immediately resize the control via code like:

NameOfYourImageControl.Width = NameOfYourImageControl.ImageWidth
NameOfYourImageControl.Height = NameOfYourImageControl.ImageHeight
NameOfYourImageControl.SizeMode = acOLESizeZoom

But, for printing purposes, see the previous post of mine on this issue
below.

*Previous Post*
I have not tested this with bound OLE Frame controls, only with Image
controls, but the results should be the same. What it boils down to is
being able to ascertain the original dimensions of the image at
creation/scanning time. Set your Image control to these dimensions and
then the SizeMode prop to ZOOM.

Many image file formats do not contain this resolution information or
Access does not accurate interpret it. Also the ImageWidth and
ImageHeight props are not always accurate and can contain garbage
values.


It is possible to read the OLE object image dimensions programmatically
if required. Have a look here for the AutoSizeOLE sample:
http://www.lebans.com/oletodisk.htm


Here is a previous post of mine on this subject. It is not the one I was
looking for but Google is very slow at this moment. If you did a search
you would find a lot more detail on this subject from earlier posts of
mine.


Message 4 in thread
From: Stephen Lebans ([email protected])
Subject: Re: letters & signatures


View this article only
Newsgroups: comp.databases.ms-access
Date: 2002-06-11 19:45:15 PST


Once you load the Image into the Image control you can access the
control's ImageHeight and ImageWIdth properties to ascertain the size of
the Image. The issue here though is you really need to know at what
resolution the signatures were originally scanned at. I'll give you an
example:
1) Scanned at 300DPI
2) Saved as a Bitmap 600w x 300h
3) Load into Image control. Read ImageWidth and Height props.
4) 600/300 = 2 inches wide - 300/300 = 1 inch tall
5) ImageControl.Width = 1440 * 2
6) ImageControl.Height = 1440 * 1
7) ImageControl.SizeMode = acOLESizeZoom
8) Position the Image control as required.


1440 = Twips per Inch



--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top