Re: Fill an irregular shape with color



Create a new GraphicsPath object and add lines as you like. You can add a
collection of points and create a closed shape such as your map example
using the AddLines method. Similarly you can add rectangles, ellipses and
other shapes.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.



"Sergio" <Sergio@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:80C7F0DE-AD0F-45AB-A924-8F56C75D405E@xxxxxxxxxxxxxxxx
Ok, so how do I get the GraphicsPath for the shape? I ask because the
shape
will always be different so I wouldn't be able to predefine the points.

"Bob Powell [MVP]" wrote:

Use a GraphicsPath to contain ther shape as a set of points and fill this
shape with the desired brush using Graphics.FillPath.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.



"Sergio" <Sergio@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2FDF5FD9-51A0-4D73-A51D-8B0779ABF92E@xxxxxxxxxxxxxxxx
Hello,
How do I fill an irregular shape with a given color in an image with
System.Drawing?

Let's say I have a map of North America and I want to paint the USA
with a
color given by my user. It's just like doing a fill with paint or
photoshop
right in the middle of the USA. Is there a way to do this with
System.Drawing?

I just want to know if it's possible and a possible explanation on how
to
do
it. I don't necessarily need the exact code for it.





.



Relevant Pages

  • Re: Custom Zoom & Performance
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ... the scaled pixel ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Printing graphics/text that span multiple pages
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ... You need to figure out how many pages you need and then render your ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Hotspots in graphic
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ... > What is the best way to draw that image on the screen? ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Drawing backgeound image slows down form performance
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ... > I have a windows form application that draws the background with a color ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Hotspots in graphic
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ... > What is the best way to draw that image on the screen? ...
    (microsoft.public.dotnet.framework.windowsforms.controls)