select all pixels with same color ?

Hi …
Are there any way to make something like the this image
( select all the pixels that around the selected one and the with same color )

Thank you

Note :

Magic wand tool ( found it in Photoshop )

Make a 2 dimensional bool array, with the same width and height as your image. Then get the color at the pressed pixel. Then go through all pixels of the image, and compare the color to the desired one. If it is the same, or just slightly different, set the bool to true, else false.
after that you can check in your for example brush code, if the pixel is “selected”(true in the array) and only set the color if it is so.

Note: however, this checks for all the pixels, not just the connected ones. If you want that, I would use some pathfinding methods, to check with open and closed list, if the selected pixels are connected.(Hope this makes sense)

Magic wand tool is made basically the same way as flood fill.

http://www.codeproject.com/KB/GDI-plus/queuelinearfloodfill.aspx