jimday1982 Posted August 15, 2003 Posted August 15, 2003 I was wondering if anyone knows of a way to specify the size of an image on import into my program. For instance, if the user imports a 500 x 500 picture, i need it to fit my 100x100 picture box. I know about the autosize property and all that, but there are more operations that are going to be associated with the picture box that make autosize impossible to use. The code I have for importing the pictures is below. Thanks for your help!! Private Sub b101clicksub(ByVal sender As System.Object, ByVal e As System.EventArgs) With ofd51 .CheckFileExists = True .CheckPathExists = True .Filter = "Images|*.bmp;*.tiff;*.jpg;*.jpeg;*.png;" .Multiselect = False .ShowHelp = False .Title = "Select an Image" End With If ofd51.ShowDialog() = DialogResult.OK Then Dim tmpBMP As New Bitmap(ofd51.FileName) gp51.Image = tmpBMP End If End Sub Quote
*Experts* mutant Posted August 15, 2003 *Experts* Posted August 15, 2003 To scale an image use the GetThumbnailImage() method of the image: Dim b As new Bitmap("image path") b = b.GetThumbnailImage(width, height, New Image.GetThumbnailImageAbort(AddressOf tb), IntPtr.Zero) picturebox1.Image = b And then you must add a delegate for the third argument: Private Function tb() As Boolean 'you can call this function whatever you want Return False End Function Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.