Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 853
  • Last Modified:

allow user to draw a polygon region over 2D image

I hope my Title was clear

Simply, I want to allow a user to create a colored region .... This could be done which ever way you feel is best of the following examples or suggest another way if you like

1> Allow user to click and place polygon points around an area creating the colored region area
NOTE: Opacity  of colored region should allow image beneath to still be seen.

2. Or, the user could click and drag a rectangle or square to desired size and shape over selected region ...

Or maybe you have a suggestion ...

0
vbMarkO
Asked:
vbMarkO
1 Solution
 
mjoachiamiakCommented:
Which environment and what language do you want to use? I can give some pointers how to do it in Visual C++.
0
 
VKCommented:
Do you need a (vb or vb.net ?) solution as the zone the question you have posted in implies?
Assuming you need a vb solution and you are dealing with pictureboxes, you may use the
region api to realize your task.
0
 
vbMarkOAuthor Commented:
My Bad, I thought I posted this as Visual Basic 2008 Express so no C++ or C# ..... straight VB 2008

OK for more details .... my image is in a Picture box ...

If you need any other info just ask away :)

Mark
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
vbMarkOAuthor Commented:
I am not sure what to ad to this to give it more attention but I will try ...

I have a WInform with a panel (Panel1) on it
Within the Panel1 is a Picturebox1
In the PB is a Map image ......

WHat I would like to do is be able to Draw out a region .... lik a polygon region or highlighted region of the image ....... I really like the idea of a polygonal low opacity region so that you can se what is under neath it but be allowed to manipulate the points or change the shape of the region ...

I think you would know what I am talking about .... but if I need to find an example I can ....

Oh by the way ... you are welcome to point me to a place where a Visual Basic 2008 example might be .... No C# please

vbMarkO
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Hi again vbMarkO,

Dragging a simple rectangle and allowing the map to show thru isn't that hard...but it gets a little trickier when you want to allow the user to resize/move them around.

Will this be used in the app that you are developing in the other question I am helping you with?  If so, should the user be able to add "marks" inside the colored region?

Food for thought...look at the solution I posted here:  (5th from the bottom)
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_23974537.html

0
 
vbMarkOAuthor Commented:
Yes, you are correct the user should be able to place marks/points within rectangle area

Ok, now about the other post solution .... the use of forms ...I assume this is the one you are referring to?

Very smart, loved the concept, I can see real advantages to this ...... do you feel it the better solution than drawing then?
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Alrighty...you have to make a design decision and there isn't a straight forward easy answer here....

VB.Net does support transparency but it comes in different flavors.  =\

(1) You can DRAW the transparent region onto your map but this is done by actually combining the map and the "overlay" into one NEW image.  The drawback here is that whenever you want to move and/or resize the region we have to start with the ORIGINAL image (have to store that somewhere) and combine it with the new position.  This is a costly operation and it may flicker ALOT as you resize/move the region.  Additionally, once the region is drawn, it will simply be an image which is unable to respond to user interaction.  We will have to manually do "hit-testing" as the mouse moves to see if we are over the region and change the mouse cursor and react accordingly.  This gets hard to manage real fast...especially since you have multiple types of "objects" in your space.  You have regions AND points to deal with.  It isn't impossible, though, and I have quite a few examples posted here at EE that you can play with.

It's important to note that CONTROLS do not support TRUE transparency in VB.Net.  If you were to use a PictureBox or Panel to represent your Region, and then attempt to overlay it on the map PictureBox (by placing it above/over), you can't get the Region to be transparent and show the map underneath.

You can, however, get a seperate WINDOW (form) to be transparent and show the window underneath.  This brings us to option #2.

(2) Use "floating" forms to house the regions and allow us true transparency.  The advantage here is that we get the moving and resizing of the regions for almost free as forms allow themselves to be moved and/or resized already.  There are disadvantages too though.  We have to make sure that the forms are moved whenever the main form is moved so that they stay over the correct spots.  Additionally we must make sure that the user doesn't move/resize them outside the main form area.  Finally, since they are actually forms, when the user clicks on them to place a "mark", we will have to pass on that message to the main form so it reacts as if it was directly clicked on.

As you can see...there isn't a perfect fit here.  The "crutch" being that the regions need to be transparent and .Net doesn't support that in a way that most developers like...
0
 
vbMarkOAuthor Commented:
Idle MInd ... I have been giving this a lot of thought ...

You said: "Alrighty...you have to make a design decision "

I am really impressed with the Form method .... and I will be going that way ....

But, the Design decision you mentioned was in fact what I did .... after really deliberating both methods I am opting not to implement this at this time though as I feel the need to get the main purpose of the app finish and that is to collect crime data for a given area and display it.

Thus I am accepting the Form method as the Solution ....

On a side note ..... this form method has given me ideas of other uses .... for different apps

Thank you for this input and sorry I was a little long in making this decision

vbMarkO
0
 
vbMarkOAuthor Commented:
Great idea using Forms ..... has opened my mind to think out side of the box ... Thank You
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
No worries about the length of time...that means nothing to me.  My concern was making sure you knew the pros/cons of the two different methods.  =)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now