|
-
Mar 3rd, 2018, 05:17 PM
#1
Thread Starter
Lively Member
Picture Aspect Ratio on load picture (Not resize)
Hi dear friends, I have a Picture previewer and I want to preview pictures in the ratio fit to the PictureBox, I used (Image1) to stretch the pictures but it is not cool for all pictures they lose the aspect ratio, How can I make it? How to make pictures fit to the PictureBox?
*******************
Picture below:
No.1: is a (Picture1) PictureBox, has not stretch!
No.2 is an (Image1) ImageBox, and stretched!

Please show me a way to solve this problem!
-
Mar 3rd, 2018, 10:24 PM
#2
Re: Picture Aspect Ratio on load picture (Not resize)
u calculate the ratio from the original picture, ratio = width / height
now, you can do in different ways, one way is to compare the ratio, assume you want a 4:3 ratio that means 1.333
if the ratio is below 1.333 we use the preview width as "base" while the height we do width / 1.333
if ratio is higher 1.333 we we the preview height as "base" while the width we do height * 1.333
-
Mar 4th, 2018, 10:30 AM
#3
Thread Starter
Lively Member
Re: Picture Aspect Ratio on load picture (Not resize)
 Originally Posted by baka
u calculate the ratio from the original picture, ratio = width / height
now, you can do in different ways, one way is to compare the ratio, assume you want a 4:3 ratio that means 1.333
if the ratio is below 1.333 we use the preview width as "base" while the height we do width / 1.333
if ratio is higher 1.333 we we the preview height as "base" while the width we do height * 1.333
Thank you dear baka, Can you show me in a clearer method (if it is possible with a simple project)? really this is not clear for me!
-
Mar 4th, 2018, 01:59 PM
#4
Re: Picture Aspect Ratio on load picture (Not resize)
to get you started:
Dim Ratio!
Ratio = Picture1.Width / Picture1.Height
Image1.Width = 1000
Image1.Height = 1000 / Ratio
if you want the Height to be "fixed" you do
Image1.Width = 1000 * Ratio
Image1.Height = 1000
---
You can change 1000 with the dimension you want.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|