1,105,578 Community Members

drawing a shape and autofill it using colordialog [super urgent]

Member Avatar
kazekagerandy
Junior Poster in Training
58 posts since Feb 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

i am working on a virtual make-up software and the only thing i lack to totally finish it is the lipstick part. is there a way that i can trace the edges of the lips of the picture that im editing and fill its insides with colors from a colordialog that will serve as if it applied a lipstick. just like what they have on jkiwi that users will jut trace the edges of the lips and then the color will automatically be filled out and it can be changed by choosing a color in a dialogbox.

this is super urgent problem, please help me guys, i appreaciate a code answer rather than giving articles to read on, it is due to that im lacking time to read so long articles. thanks. :)

Unhnd_Exception
Deleted Member
 
0
 

What your trying to do is not all that all basic.

Here is the most basic example I can provide.

You will need to apply this with what you are doing.

This will draw a polygon and fill it. There are more things involved such as clip rectangles, cursors, and more. This should be a starting point for you.

Public Class Form1
    Private Lip As Point()
    Private IsLipClosed As Boolean

    Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown

        'If the point array is nothing or it is closed then
        'start a new shape.
        If Lip Is Nothing OrElse IsLipClosed Then
            Lip = New Point() {}
            IsLipClosed = False
        End If

        'If the point array has not made it back to the first
        'point then add this point.
        If IsLipClosed = False Then
            ReDim Preserve Lip(Lip.Length)
            Lip(UBound(Lip)) = e.Location
            PictureBox1.Invalidate()
        End If

        'If the current point is within 2 pixels of the first point 
        'then the point array has made it back to the first point
        'and is now a polygon.  Consider it done and closed.
        If (Lip.GetLength(0) > 1) AndAlso (e.X >= Lip(0).X - 2 And e.X <= Lip(0).X + 2) AndAlso (e.Y >= Lip(0).Y - 2 And e.Y <= Lip(0).Y + 2) Then
            IsLipClosed = True
        End If

    End Sub

    Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint

        'if the point array is not closed and it is greater than 1 point
        'then draw the lines.  If its closed then fill it.
        If Lip IsNot Nothing Then
            If IsLipClosed Then
                e.Graphics.FillPolygon(Brushes.Red, Lip)
            ElseIf Lip.GetLength(0) > 1 Then
                e.Graphics.DrawLines(Pens.Red, Lip)
            End If

        End If
    End Sub

End Class
Question Answered as of 3 Years Ago by Unhnd_Exception
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: