求vb的picture1怎么让图片旋转的代码
1个回答
展开全部
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 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 Sub Private 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 Sub Private 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 Sub Private 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 Sub 不知道这样行不行 这是简单的固定角度的旋转的
追问
大哥,你写代码的时候是不用分行的吗?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询