Some advice, please. I'm just starting out in C#. I've managed to get some shapes created on a Windows form, and now I'd like to fill them with color. In the old C++ I studied years ago, there was a floodfill function that was really easy. It has been an unpleasant realization to find there's not a similar method available in regular old C#. Does anyone have advice for me, or some code, so I can implement filling without understanding GDI+, DirectX, or rest of the avalanche of acronyms that I've run into by researching this on the web? I need to fill irregular shapes, bounded by a certain color. Gradient and transparency control would be nice, but I'd settle for plain old solid fill right now, just to get a modicom of control over this. Any help, code or advice would be really appreciated.
A:
i used:
To get HDC http://msdn.microsoft.com/en-us/library/9z5820hw(VS.90).aspx
and to FloodFill http://www.pinvoke.net/default.aspx/gdi32/FloodFill.html
it worked
Andrey
2010-06-03 12:39:04
Thank you, Audrey. I'm looking over these sites. I self-taught,still a rank novice, groping my way through this stuff. Is this easy enough that an unskilled an uneducated newbie such as myself can grasp, in your opinion? Thanks, Jimmy
Jimmy
2010-06-03 12:49:40
@Jimmy yes, you can. just go step by step. Read article about P/Invoke, then read first link and take code from there. Then take second, to get HDC for Graphics you are painting on.
Andrey
2010-06-03 12:55:22
+2
A:
Take a look at the Graphics.FillXxxx() methods. The most flexible one is FillPath, it takes a GraphicsPath which in turn lets you define an arbitrary shape and fill it.
Hans Passant
2010-06-03 13:41:05
Thank you, Chris. This site looks really, really promising. I'll keep at it.
Jimmy
2010-06-03 13:51:51
A:
There is an article on how to flood fill in .Net at Code Project.
Dour High Arch
2010-06-04 21:26:28