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

Polygon using POINTS

Polygon API require POINT* and  i have POINTS*. what is the best way to solve this issue? are there a way to convert between both types in one step without looping through all the points? also i searched for Polygon API that accept POINTS*, but i got nothing.

thanks
0
zhkhan
Asked:
zhkhan
1 Solution
 
cupCommented:
What are POINTS?  It isn't a Win32 type.  

Where is it defined?  

What function is returning POINTS to you?
0
 
zhkhanAuthor Commented:
POINTS are defined in windef.h, as the following:

typedef struct tagPOINTS
{
#ifndef _MAC
    SHORT   x;
    SHORT   y;
#else
    SHORT   y;
    SHORT   x;
#endif
} POINTS, *PPOINTS, *LPPOINTS;

i am working in wince and trying to save memory, because my points count is huge, so prefer to use short instead of long for both x and y.
0
 
HappyCactusCommented:
I think there isn't, and it can't exist.
POINT and POINTS are different structures, so if you want to use a POINT you must convert it to POINTS. the loop is the only choice.
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
cupCommented:
Just looked it up: never knew POINTS existed.  I think POINTS is same as COORD, which is only used in console mode.

Do you want a filled polygon or just to draw a polygon.  If it is just to draw one, then you could use MoveTo and LineTo.  If you want a filled polygon, you'll probably need to convert from POINTS to POINT before drawing.

How tight is the memory: How many points are you using and how much memory do you have?  It needs to be in the 100s and 1000s before it is a worthwhile saving.  Not worth worrying about if it is a small number.

Storing in POINTS might be a false saving as everything needs to be converted to 32 bits when it goes into the registers for drawing so you might actually be using more memory by using POINTS rather than POINT.

eg Some might think that

for (char ii = 0; ii < 20; ++ii)
   x[ii] = 0;

generates less code than

for (int ii  = 0; ii < 20; ++ii)
   x[ii] = 0;

but it is the other way round because a lot of code is generated when indexing ii as a char - it has to be extended to 32 bits before it can be used as an index and that generates more code.
0
 
pgnatyukCommented:
What do you mean in one step? You need to make a function that will convert your type into an array of POINT. It is a loop. You can use for example, vector from STL and use an algorithm, for example, for_each.
http://msdn.microsoft.com/en-us/library/c4x1w65f(VS.80).aspx
http://support.microsoft.com/kb/156345
0
 
cupCommented:
I think he means casting or some built in conversion function.
0
 
zhkhanAuthor Commented:
ya thats exactly what i meant.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

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