- Private Sub Command1_Click()
- Rotation Picture1, Picture2, 90, 10 'apeller du sub| picture1 = image a tourner, picture2= image de fin, 90 = la rotation en degrer, 10 la precision
- End Sub
-
- Sub Rotation(Picture1 As PictureBox, Picture2 As PictureBox, Angle As Long, Precision As Long)
- Picture1.AutoRedraw = True
- Picture2.AutoRedraw = True
- r = Atn(1) * 4 / 180
- If Picture1.Width > Picture1.Height Then
- Picture2.Width = Picture1.Width + (Picture1.Width / 2)
- Picture2.Height = Picture1.Width + (Picture1.Width / 2)
- Else
- Picture2.Width = Picture1.Height + (Picture1.Height / 2)
- Picture2.Height = Picture1.Height + (Picture1.Height / 2)
- End If
- centrex1 = Picture1.ScaleWidth / 2
- centrey1 = Picture1.ScaleHeight / 2
- centrex2 = Picture2.ScaleWidth / 2
- centrey2 = Picture2.ScaleHeight / 2
- For y = 0 To Picture1.ScaleHeight Step Precision
- For x = 0.0001 To Picture1.ScaleWidth Step Precision
- p = Picture1.Point(x, y)
- wx = x - centrex1
- wy = y - centrey1
- a = Atn(wy / wx) / r + Angle
- If x > centrex1 Then a = a + 180
- t = Sqr(wx * wx + wy * wy)
- DoEvents
- rx = centrex2 - Cos(a * r) * t
- ry = centrey2 - Sin(a * r) * t
- Picture2.PSet (rx, ry), p
- Next
- Next
- End Sub
-
Private Sub Command1_Click()
Rotation Picture1, Picture2, 90, 10 'apeller du sub| picture1 = image a tourner, picture2= image de fin, 90 = la rotation en degrer, 10 la precision
End Sub
Sub Rotation(Picture1 As PictureBox, Picture2 As PictureBox, Angle As Long, Precision As Long)
Picture1.AutoRedraw = True
Picture2.AutoRedraw = True
r = Atn(1) * 4 / 180
If Picture1.Width > Picture1.Height Then
Picture2.Width = Picture1.Width + (Picture1.Width / 2)
Picture2.Height = Picture1.Width + (Picture1.Width / 2)
Else
Picture2.Width = Picture1.Height + (Picture1.Height / 2)
Picture2.Height = Picture1.Height + (Picture1.Height / 2)
End If
centrex1 = Picture1.ScaleWidth / 2
centrey1 = Picture1.ScaleHeight / 2
centrex2 = Picture2.ScaleWidth / 2
centrey2 = Picture2.ScaleHeight / 2
For y = 0 To Picture1.ScaleHeight Step Precision
For x = 0.0001 To Picture1.ScaleWidth Step Precision
p = Picture1.Point(x, y)
wx = x - centrex1
wy = y - centrey1
a = Atn(wy / wx) / r + Angle
If x > centrex1 Then a = a + 180
t = Sqr(wx * wx + wy * wy)
DoEvents
rx = centrex2 - Cos(a * r) * t
ry = centrey2 - Sin(a * r) * t
Picture2.PSet (rx, ry), p
Next
Next
End Sub