1 Attachment(s)
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!
Attachment 156939
Please show me a way to solve this problem!
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
Re: Picture Aspect Ratio on load picture (Not resize)
Quote:
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!
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.