-
July 4th, 2010, 07:54 PM
#1
[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
Last edited by Saeed; July 4th, 2010 at 10:32 PM.
-
July 4th, 2010, 10:48 PM
#2
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
-
July 5th, 2010, 04:45 AM
#3
Re: avoid stretching an image but in a fixed size
-
July 5th, 2010, 10:21 PM
#4
Re: avoid stretching an image but in a fixed size
Thanks Hanne;
Good work .
Cheers
-
July 6th, 2010, 01:14 AM
#5
Re: [RESOLVED] avoid stretching an image but in a fixed size
Glad I could help
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
|