vb图片翻转代码。
3个回答
2013-12-11
展开全部
试试这个: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 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 Sub
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 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 Sub
2013-12-11
展开全部
用PaintPicture方法一句代码即可搞定,比如把Picture1的图片水平翻转后在Picture2中显示出来:Picture2.PaintPicture Picture1.Picture, 0, 0, Picture1.Width, Picture1.Height, Picture1.Width, 0, -Picture1.Width, Picture1.Height
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-12-11
展开全部
其实,vb自带有一个函数,paintpicture,和bitblt差不多!具体在msdn帮助里有例子!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询