1

I have a freehand shape, drawn on a PictureBox in a Windows Form. For example:

enter image description here

Now I need to determine whether a given point belongs to the shape.

As I know, I should have to make a Region object, then call its IsVisible() member function to find out the answer. I know how to do it on a region made by rectangles, arcs, circles, and so on, but my shape is free-hand, and I don't know how to set up a free-hand region.

Also, I have read the How to create a clickable irregularly-shaped region in c#, which is so useful, but I didn't grasp the point because I'm a newbie.

If this is a duplicate question, please note me to delete my question, though I have done my best to find out a solution, but I was out of luck.

P.N.: Thanks to TaW for his/her helpful and accepted answer.

dghadagh
  • 103
  • 1
  • 15
  • 2
    _it makes no help_ But it should!! Do look into `GraphicsPath` which should do what you need.. Forget about Regions, which are mostly needed for a) set operations or b) clipping control surfaces. Also: What is an 'Imagebox'? A `PictureBox` maybe? Alsway use the correct names!! ((Btw you could also create a Region from a GraphicsPath but this will not be necessary as GP has functions to determine if a point is inside or even on the GP path)) – TaW Feb 10 '19 at 12:35
  • @TaW Thank you so much for the corrections. I made that corrections. Thanks again :) – dghadagh Feb 10 '19 at 12:39
  • 3
    perhaps the difficulty you're having is how to obtain a `GraphicsPath` from a picture that has already been drawn, and is now a `Bitmap` (tracing). If your users draw the shape, record the points as they draw, then there is no need to trace from bitmap. – Cee McSharpface Feb 10 '19 at 12:47
  • @dlatikay Thanks for your help. – dghadagh Feb 10 '19 at 12:50
  • http://www.vcskicks.com/custom_shape_form_transperancy.php maybe it can help you – Giancarlo Melis May 24 '19 at 13:51

0 Answers0