GraphicsPathIterator::GetCount method (gdipluspath.h)

The GraphicsPathIterator::GetCount method returns the number of data points in the path.

Syntax

INT GetCount();

Return value

Type: INT

This method returns the number of data points in the path.

Remarks

This GraphicsPathIterator object is associated with a GraphicsPath object. That GraphicsPath object has an array of points and an array of types. Each element in the array of types is a byte that specifies the point type and a set of flags for the corresponding element in the array of points. Possible point types and flags are listed in the PathPointType enumeration.

Examples

The following example creates a GraphicsPath object and then adds a rectangle and an ellipse to the path. The code passes the address of that GraphicsPath object to a GraphicsPathIterator constructor to create an iterator that is associated with the path. The code calls the iterator's GraphicsPathIterator::GetCount method to determine the number of data points in the path. The call to GraphicsPathIterator::Enumerate retrieves two arrays from the path: one that holds the path's data points and one that holds the path's point types. After the data points have been retrieved, the code calls the FillEllipse method of a object to draw each of the data points.


VOID GetCountExample(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a path that has a rectangle and an ellipse.
   GraphicsPath path;
   path.AddRectangle(Rect(20, 20, 60, 30));
   path.AddEllipse(Rect(20, 70, 100, 50));

   // Create an iterator, and associate it with the path.
   GraphicsPathIterator iterator(&path);

   // Get the number of data points in the path.
   INT count = iterator.GetCount();

   // Get the data points.
   PointF* points = new PointF[count];
   BYTE* types = new BYTE[count];
   iterator.Enumerate(points, types, count);

   // Draw the data points.
   SolidBrush brush(Color(255, 255, 0, 0));
   for(INT j = 0; j < count; ++j)
      graphics.FillEllipse(
         &brush,
         points[j].X - 3.0f, 
         points[j].Y - 3.0f,
         6.0f,
         6.0f);

   delete points;
   delete types;
}

Requirements

Requirement Value
Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header gdipluspath.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

Constructing and Drawing Paths

GetPathData

GetPathPoints Methods

GetPathTypes

GetPointCount

GraphicsPath

GraphicsPathIterator

GraphicsPathIterator::CopyData

GraphicsPathIterator::Enumerate

Paths