We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


allow user to draw a polygon region over 2D image

Medium Priority
Last Modified: 2012-06-21
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 ...

Watch Question

Which environment and what language do you want to use? I can give some pointers how to do it in Visual C++.

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.


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 :)



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

High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009
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)

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


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?
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009

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...


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



Great idea using Forms ..... has opened my mind to think out side of the box ... Thank You
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009

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.  =)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.