1

I am making a paint program and the color of the PictureBox Graphics supports Brushes in FillShape and Pens in DrawShape.

If you have any solution please tell me how to convert Brush/Pens to Color? So I can also use ColorDialog for custom colors.

Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
Sudhir Sundar
  • 41
  • 1
  • 1
  • 9
  • 1
    Welcome to Stack Overflow! Please take a moment to read this *carefully*: [Ask]. Based on your question history, you are probably getting close to a Question ban or throttle, so do take some time to read the link. – Ňɏssa Pøngjǣrdenlarp May 20 '15 at 12:53

1 Answers1

1

I think what you want is to be able to create a brush or pen from a colour. In that case this should do it:

        'create a brush from a known colour
        Dim brush = New SolidBrush(Color.AliceBlue)
        'create a brush from a user defined colour
        Dim brush2 = New SolidBrush(Color.FromArgb(128, 128, 128))
        'create a pen from a known colour
        Dim pen = New Pen(Color.Red)
        'create a pen from a custom colour
        Dim pen2 = New Pen(Color.FromArgb(0, 128, 255))
        'create a pen from a brush
        Dim pen3 = New Pen(brush)

        'don't forget to dispose of your brushes/pens when finished
        brush.Dispose()
        brush2.Dispose()
        pen.Dispose()
        pen2.Dispose()
        pen3.Dispose()
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143