Fill an irregular shape with color - DOTNET

This is a discussion on Fill an irregular shape with color - DOTNET ; 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. ...

+ Reply to Thread
Results 1 to 4 of 4

Fill an irregular shape with color

  1. Default Fill an irregular shape with color

    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.

  2. Default Re: Fill an irregular shape with color

    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@discussions.microsoft.com> wrote in message
    news:2FDF5FD9-51A0-4D73-A51D-8B0779ABF92E@microsoft.com...
    > 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.




  3. Default Re: Fill an irregular shape with color

    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@discussions.microsoft.com> wrote in message
    > news:2FDF5FD9-51A0-4D73-A51D-8B0779ABF92E@microsoft.com...
    > > 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.

    >
    >
    >


  4. Default 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@discussions.microsoft.com> wrote in message
    news:80C7F0DE-AD0F-45AB-A924-8F56C75D405E@microsoft.com...
    > 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@discussions.microsoft.com> wrote in message
    >> news:2FDF5FD9-51A0-4D73-A51D-8B0779ABF92E@microsoft.com...
    >> > 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.

    >>
    >>
    >>




+ Reply to Thread

Similar Threads

  1. Re: Fill a Hollow Shape
    By Application Development in forum DOTNET
    Replies: 3
    Last Post: 09-08-2007, 03:19 AM
  2. I can't fill a shape with color!
    By Application Development in forum Adobe illustrator
    Replies: 6
    Last Post: 07-26-2007, 08:48 AM
  3. How to scale & copy in proportion an irregular shape?
    By Application Development in forum Adobe illustrator
    Replies: 3
    Last Post: 01-02-2007, 05:17 AM
  4. irregular shape video in picture-in-picture format
    By Application Development in forum Adobe Premiere
    Replies: 1
    Last Post: 01-05-2006, 03:41 PM
  5. Fill in a shape
    By Application Development in forum Graphics
    Replies: 2
    Last Post: 12-01-2005, 09:40 AM