[RESOLVED] avoid stretching an image but in a fixed size
I am displaying an Image in a fixed size section of screen say X and Y
If the picture happend to be smaller or bigger I use stretch to fit it in my area of control.
Now the area could be wider or taller and .tretch woudl make it look unproportinal.
Without any mathematical calculation that I m trying to avoid,
is there any way that VB6 could resize that image keeping the same aspect ration and only use the area X & Y.
of course that may mean i ll endup with some extra space unused at the bottom or on the right which is undeatndable.
But can this be done via image property and VB6 ?
a sample of the code:
Code:
Image1(j).Visible = True
Image1(j).Width = getValue(str0, "Width")
Image1(j).Height = getValue(str0, "Height")
Image1(j).Stretch = True
Image1(j).Top = Label6(j).Top + Label6(j).Height
Image1(j).Left = Label6(j).Left
Re: avoid stretching an image but in a fixed size
Nope,... You will need to use just a little bit of simple math...
pseudo code...
if height > width then
percentage = width / height
elseif width > height then
percentage = height / width
else
percentage = 1
endif
Okay, the above pseudo code shows you how to figure out your aspect ratio calculation so you won't "stretch" the short end (h or w) when resizing...
Good Luck
Re: avoid stretching an image but in a fixed size
Hello Saeed! :wave:
This may also be useful to you :
http://www.codeguru.com/forum/showthread.php?t=497592
Re: avoid stretching an image but in a fixed size
Thanks Hanne;
Good work .
Cheers
Re: [RESOLVED] avoid stretching an image but in a fixed size