那你就利用imgedit控件实现,速度应该很快: Option Explicit '工程 部件 加载Kodak Image Edit Control Private Sub Command1_Click() Me.ImgEdit1.RotateRight End SubPrivate Sub Form_Load() Me.ImgEdit1.Image = "e:\mc\test.jpg" Me.ImgEdit1.Display End Sub
'函数声明 Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long Const srcopy = &HCC0020 Dim h As Integer Dim w As Integer Private Sub Form_Load() Picture2.Picture = LoadPicture(App.Path & "\a01.bmp") '导入图片 h = Picture1.Height w = Picture1.Width End Sub Private Sub Command1_Click() '旋转180度 Picture2.Picture = LoadPicture("") For j = 0 To h Step 1 For i = 0 To w Step 1 BitBlt Picture2.hDC, i, j, 1, 1, Picture1.hDC, w - i, h - j, srcopy Next i Next j End SubPrivate Sub Command2_Click() '顺时针旋转90度 Picture2.Picture = LoadPicture("") For i = h To 0 Step -1 For j = 0 To w Step 1 BitBlt Picture2.hDC, i, j, 1, 1, Picture1.hDC, w - j, h - i, srcopy Next j Next i End Sub Private Sub Command3_Click() '逆时针旋转90度 Picture2.Picture = LoadPicture("") For j = w To 0 Step -1 For i = 0 To h Step 1 BitBlt Picture2.hDC, i, j, 1, 1, Picture1.hDC, j, i, srcopy Next i Next j End SubPrivate Sub Command4_Click() '水平翻转 Picture2.Picture = LoadPicture("") For i = w To 0 Step -1 For j = 0 To h Step 1 BitBlt Picture2.hDC, i, j, 1, 1, Picture1.hDC, i, j, srcopy Next j Next i End SubPrivate Sub Command5_Click() '垂直翻转 Picture2.Picture = LoadPicture("") For j = 0 To h Step 1 For i = 0 To w Step 1 BitBlt Picture2.hDC, i, j, 1, 1, Picture1.hDC, w - i, h - j, srcopy Next i Next j End SubPrivate Sub Command6_Click() '复位 Picture2.Picture = LoadPicture("") For i = 0 To w Step 1 For j = 0 To h Step 1 BitBlt Picture2.hDC, i, j, 1, 1, Picture1.hDC, i, j, srcopy Next j Next i End SubPrivate Sub Command7_Click() End End Sub
窗体上放两个PICTUREBOX控件,两个COMMANDBOTTON 代码如下:Option Explicit Private Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long) As Long Private Declare Function SetPixelV Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As LongPrivate Sub Command1_Click() RltPic True Picture2.Refresh End SubSub RltPic(TrunLeft As Boolean) ' Dim X As Long Dim Y As Long Dim Hdc1 As Long Dim Hdc2 As Long With Picture1 Picture2.Width = .Height '交换长宽 Picture2.Height = .Width '交换长宽 Hdc1 = .hDC '获得句炳 Hdc2 = Picture2.hDC '获得句炳 If TrunLeft Then For X = 0 To .ScaleWidth - 1 For Y = 0 To .ScaleHeight - 1 SetPixelV Hdc2, Y, .ScaleWidth - X, GetPixel(Hdc1, X, Y) '转置图像 Next Next Else For X = 0 To .ScaleWidth - 1 For Y = 0 To .ScaleHeight - 1 SetPixelV Hdc2, .ScaleHeight - Y, X, GetPixel(Hdc1, X, Y) '转置图像 Next Next End If End With End SubPrivate Sub Command2_Click() RltPic False Picture2.Refresh End SubPrivate Sub Form_Load() Picture1.ScaleMode = 3 Picture2.ScaleMode = 3 End Sub按COMMAND1逆时针旋转,按COMMAND2顺时针旋转。 代码经过调试确认无误。
Option Explicit
'工程 部件 加载Kodak Image Edit Control
Private Sub Command1_Click()
Me.ImgEdit1.RotateRight
End SubPrivate Sub Form_Load()
Me.ImgEdit1.Image = "e:\mc\test.jpg"
Me.ImgEdit1.Display
End Sub
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Const srcopy = &HCC0020
Dim h As Integer
Dim w As Integer
Private Sub Form_Load()
Picture2.Picture = LoadPicture(App.Path & "\a01.bmp") '导入图片
h = Picture1.Height
w = Picture1.Width
End Sub
Private Sub Command1_Click() '旋转180度
Picture2.Picture = LoadPicture("")
For j = 0 To h Step 1
For i = 0 To w Step 1
BitBlt Picture2.hDC, i, j, 1, 1, Picture1.hDC, w - i, h - j, srcopy
Next i
Next j
End SubPrivate Sub Command2_Click() '顺时针旋转90度
Picture2.Picture = LoadPicture("")
For i = h To 0 Step -1
For j = 0 To w Step 1
BitBlt Picture2.hDC, i, j, 1, 1, Picture1.hDC, w - j, h - i, srcopy
Next j
Next i
End Sub
Private Sub Command3_Click() '逆时针旋转90度
Picture2.Picture = LoadPicture("")
For j = w To 0 Step -1
For i = 0 To h Step 1
BitBlt Picture2.hDC, i, j, 1, 1, Picture1.hDC, j, i, srcopy
Next i
Next j
End SubPrivate Sub Command4_Click() '水平翻转
Picture2.Picture = LoadPicture("")
For i = w To 0 Step -1
For j = 0 To h Step 1
BitBlt Picture2.hDC, i, j, 1, 1, Picture1.hDC, i, j, srcopy
Next j
Next i
End SubPrivate Sub Command5_Click() '垂直翻转
Picture2.Picture = LoadPicture("")
For j = 0 To h Step 1
For i = 0 To w Step 1
BitBlt Picture2.hDC, i, j, 1, 1, Picture1.hDC, w - i, h - j, srcopy
Next i
Next j
End SubPrivate Sub Command6_Click() '复位
Picture2.Picture = LoadPicture("")
For i = 0 To w Step 1
For j = 0 To h Step 1
BitBlt Picture2.hDC, i, j, 1, 1, Picture1.hDC, i, j, srcopy
Next j
Next i
End SubPrivate Sub Command7_Click()
End
End Sub
代码如下:Option Explicit
Private Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function SetPixelV Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As LongPrivate Sub Command1_Click()
RltPic True
Picture2.Refresh
End SubSub RltPic(TrunLeft As Boolean) '
Dim X As Long
Dim Y As Long
Dim Hdc1 As Long
Dim Hdc2 As Long
With Picture1
Picture2.Width = .Height '交换长宽
Picture2.Height = .Width '交换长宽
Hdc1 = .hDC '获得句炳
Hdc2 = Picture2.hDC '获得句炳
If TrunLeft Then
For X = 0 To .ScaleWidth - 1
For Y = 0 To .ScaleHeight - 1
SetPixelV Hdc2, Y, .ScaleWidth - X, GetPixel(Hdc1, X, Y) '转置图像
Next
Next
Else
For X = 0 To .ScaleWidth - 1
For Y = 0 To .ScaleHeight - 1
SetPixelV Hdc2, .ScaleHeight - Y, X, GetPixel(Hdc1, X, Y) '转置图像
Next
Next
End If
End With
End SubPrivate Sub Command2_Click()
RltPic False
Picture2.Refresh
End SubPrivate Sub Form_Load()
Picture1.ScaleMode = 3
Picture2.ScaleMode = 3
End Sub按COMMAND1逆时针旋转,按COMMAND2顺时针旋转。
代码经过调试确认无误。