1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
'--------------------------------------
' Zoom sur l'image
'--------------------------------------
Private Sub BtnZoomIn_Click()
Dim lLeft As Long, lTop As Long ', lWidth As Long, lHeight As Long
'*** Code de la source du forum ***
' ajoute 1 au facteur de zoom
'gZoom = gZoom + 1
' recalcul les dimensions de l'image
'gWidth = gWidthOrig \ gZoom
'gHeight = gHeightOrig \ gZoom
' rétablit l'image d'origine
'ClGDIP.ResetImage
' découpe l'image par rapport au centre qui ne change pas
'ClGDIP.CropImage gCenterX - gWidth / 2, gCenterY - gHeight / 2, gWidth, gHeight
' Mise à jour de l'image
'Me.Image0.PictureData = ClGDIP.GdiPlusToPictureData
'***********************************
'*** Code proposé par Arkham
' ajoute 1 au facteur de zoom
gZoom = gZoom + 0.1 '*** J'essaie ici d'avoir une meilleure précision du zoom, sans succès (j'ai aussi essayé de déclarer gzoom as double,
'*** gzoom prend bien la virgule mais l'image courante ne renvoie pas qu'une image zoomée par à-coups)
' recalcul les dimensions de l'image
If gWidthOrig > gHeightOrig Then
' Cas d'une image en paysage
gWidth = gWidthOrig / gZoom
gHeight = gWidth
Else
' Cas d'une image en portrait
gHeight = gHeightOrig / gZoom
gWidth = gHeight
End If
' Limite la taille à la taille d'origine
If gHeight > gHeightOrig Then gHeight = gHeightOrig
If gWidth > gWidthOrig Then gWidth = gWidthOrig
' Décalage à gauche et à droite
lLeft = (gWidthOrig - gWidth) / 2
lTop = (gHeightOrig - gHeight) / 2
' Rétablit l'image d'origine
ClGDIP.ResetImage
' Découpe l'image
ClGDIP.CropImage lLeft, lTop, gWidth, gHeight
' Mise à jour de l'image
Me.Image0.PictureData = ClGDIP.GdiPlusToPictureData
Me.Image1.PictureData = ClGDIP.GdiPlusToPictureData
Me.Image2.PictureData = ClGDIP.GdiPlusToPictureData
End Sub |
Partager