dibujando a mano alzada
Publicado por Alonsito (4 intervenciones) el 28/09/2009 02:57:15
Hola gente necesito una ayuda cuando dibujo con el mano osea a MANO ALZADA y elijo un color para rellenarlo la primera ves lo pinta pero cuando quiero volver a dibujar el fondo se rellear con el color que eleji para pintar y luego recien dibuja porfavor me pueden ayudar FOREROS...
este es mi codigo..
Public X0, Y0, X1, Y1 As Long
Private Declare Function SelectObject _
Lib "gdi32" ( _
ByVal hdc As Long, _
ByVal hObject As Long) As Long
Private Declare Function CreateSolidBrush _
Lib "gdi32" ( _
ByVal crColor As Long) As Long
Private Declare Function DeleteObject _
Lib "gdi32" ( _
ByVal hObject As Long) As Long
Private Declare Function GetPixel _
Lib "gdi32" ( _
ByVal hdc As Long, _
ByVal X As Long, _
ByVal Y As Long) As Long
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
Const FLOODFILLSURFACE = 1
Dim Color As Long
Dim ColorActual As Long
Private Sub Init()
Color = vbWhite
With Picture1
.ScaleMode = vbPixels
.Refresh
.AutoRedraw = False
End With
End Sub
Private Sub Command1_Click()
CommonDialog1.ShowColor
Command1.BackColor = CommonDialog1.Color
Color = CommonDialog1.Color
End Sub
Private Sub Form_Load()
Init
End Sub
Private Sub Picture1_MouseDown( _
Button As Integer, _
Shift As Integer, _
X As Single, Y As Single)
Dim hBrush As Long
hBrush = CreateSolidBrush(Color)
With Picture1
Call SelectObject(.hdc, hBrush)
ColorActual = GetPixel(.hdc, X, Y)
Call ExtFloodFill(.hdc, X, Y, ColorActual, FLOODFILLSURFACE)
Call DeleteObject(hBrush)
End With
X0 = X
Y0 = Y
X1 = X
Y1 = Y
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Picture1.Line (X1, Y1)-(X, Y)
X1 = X
Y1 = Y
End If
End Sub
este es mi codigo..
Public X0, Y0, X1, Y1 As Long
Private Declare Function SelectObject _
Lib "gdi32" ( _
ByVal hdc As Long, _
ByVal hObject As Long) As Long
Private Declare Function CreateSolidBrush _
Lib "gdi32" ( _
ByVal crColor As Long) As Long
Private Declare Function DeleteObject _
Lib "gdi32" ( _
ByVal hObject As Long) As Long
Private Declare Function GetPixel _
Lib "gdi32" ( _
ByVal hdc As Long, _
ByVal X As Long, _
ByVal Y As Long) As Long
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
Const FLOODFILLSURFACE = 1
Dim Color As Long
Dim ColorActual As Long
Private Sub Init()
Color = vbWhite
With Picture1
.ScaleMode = vbPixels
.Refresh
.AutoRedraw = False
End With
End Sub
Private Sub Command1_Click()
CommonDialog1.ShowColor
Command1.BackColor = CommonDialog1.Color
Color = CommonDialog1.Color
End Sub
Private Sub Form_Load()
Init
End Sub
Private Sub Picture1_MouseDown( _
Button As Integer, _
Shift As Integer, _
X As Single, Y As Single)
Dim hBrush As Long
hBrush = CreateSolidBrush(Color)
With Picture1
Call SelectObject(.hdc, hBrush)
ColorActual = GetPixel(.hdc, X, Y)
Call ExtFloodFill(.hdc, X, Y, ColorActual, FLOODFILLSURFACE)
Call DeleteObject(hBrush)
End With
X0 = X
Y0 = Y
X1 = X
Y1 = Y
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Picture1.Line (X1, Y1)-(X, Y)
X1 = X
Y1 = Y
End If
End Sub
Valora esta pregunta
0