Link to home
Start Free TrialLog in
Avatar of Stuart Landreth
Stuart LandrethFlag for United Kingdom of Great Britain and Northern Ireland

asked on

scaling pictures

I have an image object (imgPicture) containing a picture of unknown orientation, on a resizable form (me), but of unknown size.

How can I stretch the image to fit the frame without distoring the aspect ratio.

In other words, if the image very tall, it would do this

+---+------+---+
|   |      |   |
|   |      |   |
|   |      |   |
+---+------+---+

If the image was very wide, it would do this

+--------------+
+--------------+
|              |
+--------------+
+--------------+

If the image was rougly the same aspect ratio as the frame, it would fit almost perfectly.

+--------------+
|              |
|              |
|              |
+--------------+


I have considered various solutions comparing picture widths, frame widths, ratios, multiplication of ratios, but all lead to some sort of cropping, or fail when the size of the frame is changed.

Is there a simple mathematical formula that can solve this.
Avatar of Stuart Landreth
Stuart Landreth
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

You'll need to paste this into notepad to see the diagrams, which I made in a fixed with font.
ASKER CERTIFIED SOLUTION
Avatar of Erick37
Erick37
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial