Points contained within a path

G

Guest

In my app the user can draw an arbitrary path onto an image. Now I need to
determine all of the pixels that are contained within that path. Note that
the path can intersect itself and I can always assume that the path is
closed. Are there any articles, algorithms, tools, etc. that can assist with
determining which pixels are contained within the path?

Thanks,
Lance
 
C

Cor Ligthert

LjLevend,

Not that you should go there however there is maybe an interesting newsgroup
for your question.

microsof.public.dotnet.framework.drawing

Maybe you find your answer there from more persons than here?

Cor
"ljlevend"
 
D

David Browne

ljlevend said:
In my app the user can draw an arbitrary path onto an image. Now I need
to
determine all of the pixels that are contained within that path. Note
that
the path can intersect itself and I can always assume that the path is
closed. Are there any articles, algorithms, tools, etc. that can assist
with
determining which pixels are contained within the path?

Your closed path is a polygon. Filliing a polygon on the screen is an old
and throughly solved problem.

Here's some keywords to get you started on Google.

polygon fill algorithm
Scanline Fill Algorithm
Boundary fill Algorithm
Flood fill Algorithm


David
 
K

Ken Tucker [MVP]

Hi,

Take look at the graphicspath isvisible, pathdata, and pathpoints.

http://msdn.microsoft.com/library/d...gdrawing2dgraphicspathclassisvisibletopic.asp

http://msdn.microsoft.com/library/d...ngdrawing2dgraphicspathclasspathdatatopic.asp

http://msdn.microsoft.com/library/d...drawing2dgraphicspathclasspathpointstopic.asp

Ken
-------------------
In my app the user can draw an arbitrary path onto an image. Now I need to
determine all of the pixels that are contained within that path. Note that
the path can intersect itself and I can always assume that the path is
closed. Are there any articles, algorithms, tools, etc. that can assist
with
determining which pixels are contained within the path?

Thanks,
Lance
 
G

Guest

Thanks a lot for the topic ideas. I need to determine the points contained
in the polygon in real-time (as the user moves the polygon with the mouse) so
speed is a primary concern. The scanline algorithm sounds like the fastest,
but I couldn't find any samples in VB or C#. Do you know of any?

Thanks again,
Lance
 
D

David Browne

ljlevend said:
Thanks a lot for the topic ideas. I need to determine the points
contained
in the polygon in real-time (as the user moves the polygon with the mouse)
so
speed is a primary concern. The scanline algorithm sounds like the
fastest,
but I couldn't find any samples in VB or C#. Do you know of any?

If speed is of the utmost importance you might not want to use a canned
implementation anyway.

Just hook the mouse move event and trace one scanline: from the mouse's
current position to the edge.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top