|
-
Apr 25th, 2001, 03:12 PM
#1
Thread Starter
New Member
resizing bitmaps to fit the picture box
Is it possible to resize the bitmaps to fit the fixed size of the picture box without having to manually resize every bmp.
Thanks
-
Apr 25th, 2001, 05:14 PM
#2
Hyperactive Member
You can use an Image box to stretch a picture to fit any size you want, but you will need to know what the aspect ratio is of the original picture. It helps to load the picture into a hidden picturebox, then record the aspect ratio, set the image box to the same ratio with the stretch property set to true, then finally copy the image from the hidden PictureBox to the ImageBox, and it will show up as big or small as you want.
Code:
Private Sub Form_Load()
Dim PictureAspectRatio As Double
Picture1.Visible = False
Picture1.AutoSize = True
Picture1.Picture = LoadPicture("C:\WINDOWS\Desktop\TestImage.jpg")
PictureAspectRatio = Picture1.Width / Picture1.Height
Image1.Stretch = True
Image1.Width = Image1.Height * PictureAspectRatio
Image1.Picture = Picture1.Picture
End Sub
If you really need the picture to end up in a PictureBox control, then you can use the PaintPicture method to scale the image.
-
Apr 25th, 2001, 05:26 PM
#3
Thread Starter
New Member
-
Apr 25th, 2001, 05:44 PM
#4
If you do not want to use an additional Image, you could use the PaintPicture method.
Code:
Picture2.PaintPicture picSource, 0, 0, Picture2.Width, Picture2.Height
-
Apr 25th, 2001, 07:20 PM
#5
Hyperactive Member
Set the picture box's AutoSize property to True:
Private Sub Form_Load()
Picture1.AutoSize = True
End Sub
or do it with an Image instead (works better):
Private Sub Form_Load()
Image1.Stretch = True
End Sub
[vbcode]
' comment
Rem remark
[/vbcode]
-
Apr 25th, 2001, 08:34 PM
#6
The AutoSize proeprty changes the size of the picturebox to match the bitmpa size, not the other way around.
- gaffa
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
|