• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 642
  • Last Modified:

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.
0
Attack_Trax
Asked:
Attack_Trax
1 Solution
 
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.


 
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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