|
-
Jun 5th, 2000, 09:42 AM
#1
Thread Starter
New Member
I've only worked with VB for a relatively small amount of time, but I have a project that require me to display a graphic. The graphics vary in size, but I am displaying them in a 320 X 240 window. This size is required because of all other other data that needs to be on the window.
How do I resize the graphic, at runtime, to match the size of my display windows and maintain the original graphics porportions?
I hope someone can help me, thanks in advance.
Sean
-
Jun 5th, 2000, 11:53 PM
#2
New Member
This how I do it. It could probably be done simpler, but I'm
a complex person. Anyway you get the general idea.
Stick this where you load your image. I use this with an
image. Dunno if it does the same with a picture box or not.
----------------------------------------------------------
Dim ww As Integer
Dim hh As Integer
Dim yy As Double
Dim cc As Integer
Dim boxwidth as Integer
Dim boxheight as Integer
'Set stretch to false if you want small images to stay small.
Imagename.Visible = False 'So they don't see it resize.
Imagename.Picture = LoadPicture( whatever picture )
ww = Imagename.Width
hh = Imagename.Height
boxwidth = <desired width of of your Image box>
boxheight = <desired height of of your Image box>
'If the Image is bigger than the box, proportionately resize the Image.
If ww > boxwidth Or hh > boxheight Then
'Set stretch to true if default is False.
If ww > hh Then
yy = boxwidth / ww
Imagename.Width = boxwidth
cc = CInt(hh * yy)
Imagename.Height = cc
ElseIf hh > ww Then
yy = boxheight / hh
Imagename.Height = boxheight
cc = CInt(ww * yy)
Imagename.Width = cc
Else 'The height and width of the loaded image are the same.
Me.Image1.Height = boxheight
Me.Image1.Width = boxwidth
End If
End If
Imagename.Visible = True
[Edited by wchilde on 06-06-2000 at 11:56 AM]
-
Jun 6th, 2000, 02:29 AM
#3
Or you can use the PaintPicture method and set the Width and Height to whatever you want.
Code:
Picture2.PaintPicture Picture1.Picture, 0, 0, 320, 240
-
Jun 6th, 2000, 09:43 AM
#4
Thread Starter
New Member
Thank you wchilde. After looking at the code, I should have know that. I guess I was making it harder than it really was.
I thank you, my employer thanks you.
Sean
-
Jun 6th, 2000, 09:45 AM
#5
Thread Starter
New Member
I also want to thank you Megatron. I'm going to try both methods and see the effects.
Now if only I could eliminate all the other bugs scathered throughout this program.
Sean
-
Jun 7th, 2000, 02:16 AM
#6
Other bugs? I could try helping you out with some of them.
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
|