Is it possible to resize the bitmaps to fit the fixed size of the picture box without having to manually resize every bmp.
Thanks
Printable View
Is it possible to resize the bitmaps to fit the fixed size of the picture box without having to manually resize every bmp.
Thanks
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.
If you really need the picture to end up in a PictureBox control, then you can use the PaintPicture method to scale the image.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
Thank you
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
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
The AutoSize proeprty changes the size of the picturebox to match the bitmpa size, not the other way around.
- gaffa