谢谢of123
还是不行。
这是我程序的关键代码:
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Picture1.PSet (x, y)
ReDim Preserve ap(n)
ap(n).x = x
ap(n).y = y
n = n + 1
End Sub
Private Sub Form_Load()
Picture1.ForeColor = vbRed '这两行没必要放在mousemove中
Picture1.DrawWidth = 5
End Sub
Private Sub Command1_Click()
With Picture1
W = .Width / 15
H = .Height / 15
.BackColor = vbBlack
hRgn = CreatePolygonRgn(ap(0), n, 1)
SetWindowRgn .hwnd, hRgn, True
'将图片框Pic裁剪为圆角矩形
SelectClipRgn .hdc, hRgn
.BackColor = vbBlack
End With
end sub
其它不值一提,请您再看看。
也就是所谓的抠图的啦。
区域已经选定,可是如何扣除来,放到另一个picture内,并且可以移动它呢?
目前用到的主要是这三个api
Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Private Declare Function SelectClipRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Long) As Long