اين هم يه کد براي flood fill کردن
يه کد براي flood fill کردن
:happy:
کد:
Private Declare Function ExtFloodFill Lib "Gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long, ByVal wFillType As Long) As Long
'variables used for drawing and filling
Dim X1, Y1
Dim draw
Dim temp
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'enable drawing
draw = 1
'if left mouse button, set up the line drawing
If Button = 1 Then
X1 = X
Y1 = Y
'if right mouse button, fill
ElseIf Button = 2 Then
'build a random fill color
Randomize
' Picture1.Cls
Picture1.FillColor = RGB(Int(Rnd * 255), Int(Rnd * 255), Int(Rnd * 255))
'call the dll using a temporary variable
ExtFloodFill Picture1.hdc, X, Y, Picture1.Point(X, Y), 1
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'if left mouse button, draw a line between the original point
'and the current one, but only if drawing is enabled
If Button = 1 Then
If draw = 1 Then
Picture1.Line (X1, Y1)-(X, Y)
X1 = X
Y1 = Y
End If
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
'disable drawing
draw = 0
End Sub