下面代码可以实现图片旋转,但速度不快.
Dim x As Integer, y As Integer
Dim X1 As Integer, Y1 As Integer
Dim X2 As Double, Y2 As Double
Dim X3 As Double, Y3 As Double
Dim JiaoDu As Double
Dim HuDu As Double
Dim PI As Double
PI = 3.1415926
JiaoDu = 45 ' 角 度
HuDu = JiaoDu * PI / 180 ' 弧 度
PicSource.ScaleMode = vbPixels
PicTarget.ScaleMode = vbPixels
For x = 0 To PicTarget.ScaleWidth
X1 = x - PicTarget.ScaleWidth 2
For y = 0 To PicTarget.ScaleHeight
Y1 = y - PicTarget.ScaleHeight 2
X2 = X1 * Cos(-HuDu) + Y1 * Sin(-HuDu)
Y2 = Y1 * Cos(-HuDu) - X1 * Sin(-HuDu)
X3 = X2 + PicSource.ScaleWidth 2
Y3 = Y2 + PicSource.ScaleHeight 2
If X3 > 0 And X3 < PicSource.ScaleWidth - 1 And Y3 > 0 And Y3 < PicSource.ScaleHeight - 1 Then
PicTarget.PSet (x, y), PicSource.Point(X3, Y3)
End If
Next y
Next x