Picture As PictureBox
Private Sub SizeImage(APicture As PictureBox, AImageSize As Picture, WidthImage As Single, HeightImage As Single)
On Error GoTo Onsote
APicture.Picture = LoadPicture("")
APicture.Width = WidthImage
APicture.Height = HeightImage
APicture.PaintPicture AImageSize, 0, 0, WidthImage, HeightImage
APicture.Refresh
Exit Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Sub Form_Initialize() Me.ScaleMode = vbPixels With Picture1 .ScaleMode = vbPixels .AutoSize = True .Picture = LoadPicture("d:\bateau.bmp") 'mets ton image à toi End With With Picture2 .AutoRedraw = True .ScaleMode = vbPixels End With End Sub Private Sub Command1_Click(Index As Integer) Dim coef As Integer coef = 5 ' ici le coeffricient à appliquer au "zoom" loupons Picture1, Picture2, coef End Sub Private Sub loupons(source As PictureBox, desti As PictureBox, coef As Integer) With desti .Cls .Width = source.Width * coef .Height = source.Height * coef End With desti.PaintPicture source.Picture, 0, 0, desti.Width, desti.Height End Sub
Private Declare Function GetObject Lib "gdi32.dll" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, ByRef lpObject As Any) As Long Private Type BITMAP bmType As Long bmWidth As Long bmHeight As Long bmWidthBytes As Long bmPlanes As Integer bmBitsPixel As Integer bmBits As Long End Type Private Sub Command1_Click() Dim bmp As BITMAP GetObject Picture1.Picture.Handle, Len(bmp), bmp MsgBox bmp.bmBits End Sub
Private coef As Single, source As PictureBox, desti As PictureBox Private Sub Form_Initialize() Me.ScaleMode = vbPixels With Picture1 .ScaleMode = vbPixels .AutoSize = True .Picture = LoadPicture("d:\bateau.bmp") 'mets ton image à toi End With With Picture2 .ScaleMode = vbPixels .AutoRedraw = False End With With HScroll1 .Max = 100 .Min = -100 .Value = 1 End With Set source = Picture1 Set desti = Picture2 coef = 1 End Sub Private Sub HScroll1_Change() If desti Is Nothing Then Exit Sub coef = IIf(HScroll1.Value >= 1, HScroll1.Value, (100 + HScroll1.Value) / 100) With desti .Cls .Width = source.Width * coef .Height = source.Height * coef DoEvents ' ce Doevents est là très important .PaintPicture source.Picture, 0, 0, desti.Width, desti.Height End With End Sub
Private coef As Single, source As PictureBox, desti As PictureBox Private Sub Form_Initialize() Me.ScaleMode = vbPixels With Picture1 .ScaleMode = vbPixels .AutoSize = True .Picture = LoadPicture("d:\bateau.bmp") 'mets ton image à toi End With With Picture2 .ScaleMode = vbPixels .AutoRedraw = False End With With HScroll1 .Max = 100 .Min = -100 .Value = 1 End With Set source = Picture1 Set desti = Picture2 coef = 1 End Sub Private Sub HScroll1_Change() coef = IIf(HScroll1.Value >= 1, HScroll1.Value, (100 + HScroll1.Value) / 100) Picture2_Paint End Sub Private Sub Picture2_Paint() If desti Is Nothing Then Exit Sub With desti .Cls .Width = source.Width * coef .Height = source.Height * coef .PaintPicture source.Picture, 0, 0, desti.Width, desti.Height End With End Sub
Coef = Coef * 0.1
Text1.text = Coef