Hi all,

Could the following be accomplished?


I have a image of a map of the world as the background image of a
form. The borders between countries are black lines. The countries
have no fill colour, the are white. Dependent on some data about a
countries I determine the fill colour of a country, say green. Is
there a way I can specify a coordinate one my image and have the area
(i.e. the country) in which that coordinate lies filled green? To
make
this work the area that is surrounded by black lines must be
recognized by the software as a closed shape, which is not trivial I
think. I have hopes that somewhere in .NET there is some pattern
recognition algorithm that does this trick for me.


Otherwise I probably will have to do a lot work defining all the
countries explicitly as polygons,,,,


Help would be very much appreciated!!


Regards,
Henk

Re: Dynamic colouring of areas of image by jonny

jonny
Fri Jul 25 08:11:06 CDT 2008

I don't think .Net API has this support, but what you want to
accomplish is exactly a classic algorithm in Computer Graphics --
Flood Fill.
take a look at this site and see if it fits your needs.
http://www.codeproject.com/KB/GDI-plus/floodfillincsharp.aspx

Hope it helps!

-Jonny

On Jul 24, 9:25=A0pm, h...@paralax.nl wrote:
> Hi all,
>
> Could the following be accomplished?
>
> I have a image of a map of the world as the background image of a
> form. The borders between countries are black lines. The countries
> have no fill colour, the are white. Dependent on some data about a
> countries I determine the fill colour of a country, say green. Is
> there a way I can specify a coordinate one my image and have the area
> (i.e. the country) in which that coordinate lies filled green? To
> make
> this work the area that is surrounded by black lines must be
> recognized by the software as a closed shape, which is not trivial I
> think. I have hopes that somewhere in .NET there is some pattern
> recognition algorithm that does this trick for me.
>
> Otherwise I probably will have to do a lot work defining all the
> countries explicitly as polygons,,,,
>
> Help would be very =A0much appreciated!!
>
> Regards,
> Henk


Re: Dynamic colouring of areas of image by Paul

Paul
Sun Jul 27 23:31:48 CDT 2008

You can create Regions from GraphicsPath. Then use Graphics.FillRegion. The problem is detecting all those closed line paths and converting them into GraphicsPaths.

If you could explode the world into individual closed line shapes you might be able to scan them one country at a time. Just hire someone to run PhotoShop for a week or so :+> Keep them all the same scale. Then you reassemble the country outlines as individual regions.

You have to create a region from a 2-color image.
http://forums.asp.net/p/1231528/2240411.aspx#2240411




-------- Original Message --------

> Hi all,
>
> Could the following be accomplished?
>
>
> I have a image of a map of the world as the background image of a
> form. The borders between countries are black lines. The countries
> have no fill colour, the are white. Dependent on some data about a
> countries I determine the fill colour of a country, say green. Is
> there a way I can specify a coordinate one my image and have the area
> (i.e. the country) in which that coordinate lies filled green? To
> make
> this work the area that is surrounded by black lines must be
> recognized by the software as a closed shape, which is not trivial I
> think. I have hopes that somewhere in .NET there is some pattern
> recognition algorithm that does this trick for me.
>
>
> Otherwise I probably will have to do a lot work defining all the
> countries explicitly as polygons,,,,
>
>
> Help would be very much appreciated!!
>
>
> Regards,
> Henk
>
>