Stuart Landreth
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER