How to scale the image to fix with picturebox
I have problem here, How to fix the image to the picture box, My picturebox change it size when loading the image. How to fix this size of image to fix with picturebox scale?
Quote:
Private Sub ListView3_ItemClick(ByVal item As MSComctlLib.ListItem)
Pesttable.MoveFirst
Pesttable.Move CLng(item.Index - 1)
sTarikh = item.Text
Command21.Enabled = True
Command22.Enabled = True
Form18.getID = Pesttable.Fields("id").Value
Text21.Text = Pesttable.Fields("Nama Perosak").Value & ""
Text23.Text = Pesttable.Fields("Nama Sintifik").Value & ""
Text24.Text = Pesttable.Fields("Tanda serangan").Value & ""
Picture2.Cls
Set Picture2 = Nothing 'clear the image
Picture2.AutoRedraw = True
Picture2.ScaleMode = vbPixels
On Error GoTo error3:
Picture2.PaintPicture LoadPicture(Pesttable.Fields("Gambar")), 0, 0, 200, 200
Exit Sub
error3:
If Err.Number = 481 Then
Dim strImagePath As String
strImagePath = App.Path & "\ancaman padi\NoImage.gif"
Picture2.Picture = LoadPicture(strImagePath)
Exit Sub
End If
End Sub
Re: How to scale the image to fix with picturebox
Quote:
Originally Posted by matrik02
I have problem here, How to fix the image to the picture box, My picturebox change it size when loading the image. How to fix this size of image to fix with picturebox scale?
You have the Autosize property set to true, that way the picturebox adjusts to the size of the picture.
Re: How to scale the image to fix with picturebox
My image is larger then the picturebox. So the image only display half..How to resize the image and retain the picturebox size? If I do autosize =true, the picturebox changes it size, I want to retain the picturebox size, just change the image size only to fix with picturebox size
Re: How to scale the image to fix with picturebox
Quote:
Originally Posted by matrik02
My image is larger then the picturebox. So the image only display half..How to resize the image and retain the picturebox size? If I do autosize =true, the picturebox changes it size, I want to retain the picturebox size, just change the image size only to fix with picturebox size
Unless you need the additional properties a picturebox supplies, why don't you use an Image? It has a Stretch property.
1 Attachment(s)
Re: How to scale the image to fix with picturebox
To resize the picture for a picturebox control you will need to use the StretchBlt API.
Re: How to scale the image to fix with picturebox
I have source code showing how to scale a image up or down
http://ess-image.com/Graphic/Image_P...ZoomImage.aspx
Re: How to scale the image to fix with picturebox
ess-image,
This is the second time I've seen this link to your .NET solution. This forum is for VB6 which means vb PRIOR to .net.
Now, I'm sure the OP would be happy to look at any VB6 solution you have.
Thanks
Re: How to scale the image to fix with picturebox
Hmmm, look at the date of the OP's post and the last post before today: Post #5, over a year old.
Re: How to scale the image to fix with picturebox