Drawing Complex Polygons

Hi,

I have an application on Pocket PC running Microsoft Mobile 2003, developed using Embedded Visual C++ 3.0.

I need to draw a few complex polygons (Polygons with 'holes' in them) over a black and white bitmap on a device context.

In normal windows I would use FillRegion() after CreatePolyPolygonRegion(), or set the Polygon fill mode using SetPolyFillMode().

Unfortunately both these methods are unavailable in Windows CE.

Can anyone suggest a simple alternative?

Thanks in advance,

AT.
Attack_TraxAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nthnhungCommented:
You can do it manually as following:
- Create a buffer whose width and height are equal or more than the polygon
- Fill the buffer with  the following recursion
CRect rect(buffer.width, buffer.height)
For(int mY=rect.top;mY<rect.bottom,++mY)
  For (int mX=rect.left;mX<rect.right;++mX)
  {
    CPoint point(mX,mY);
    if (point is Inside the polygon)
    {
          Fill this point with the correspoding pixel of bitmap
    }
    else
    {
         Fill it with some color different from black and white (e.g red)
     }
  }
Once you finished preparing buffer, you just need to draw it on the device context.
 For (int mX=rect.left;mX<rect.right;++mX)
  {
    CPoint point(mX,mY);
    if (pixel is red)
    {
           do nothing
    }
    else // pixel color is the same as bitmap color
    {
          draw on Device context
     }
  }

With this method, you can draw as many polygons as you like. You just need to compute the buffer once after user changed polygon's size.
Hope it useful!
Regards.


 

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.