Fill irregular area in image RRS feed

  • Question

  • Question:

    I have picturebox with an image. The image consists of various irregular shaped colored areas, divided by black boundary lines.

    When the user doubleclicks within an area I want to change the color of this area with another color.

    How do I start?

    Thanks again!


    Wednesday, March 1, 2006 7:50 PM

All replies

  • First step - throw away your picture box.  They are useless for anything more than showing an image.  You need to make your bitmap a member variable and draw it yourself in a paint handler, by using the graphics object passed into the paint event.

    Something like

    e.Graphics.DrawImage(0, 0, myBitmap)

    ( or some other overload of the DrawImage method )

    Then, you can get the color of the pixel you clicked on with GetPixel, but GDI had a flood fill method, and I believe there are some articles about on flood fill in GDI+.  Your easiest bet would e to call a flood fill on the pixel where the user clicked.


    Wednesday, March 1, 2006 9:22 PM