Share via


GraphicsPathIterator ::GetCount, méthode (gdipluspath.h)

La méthode GraphicsPathIterator ::GetCount retourne le nombre de points de données dans le chemin d’accès.

Syntaxe

INT GetCount();

Valeur de retour

Type : INT

Cette méthode retourne le nombre de points de données dans le chemin d’accès.

Remarques

Cet objet GraphicsPathIterator est associé à un objet GraphicsPath . Cet objet GraphicsPath a un tableau de points et un tableau de types. Chaque élément du tableau de types est un octet qui spécifie le type de point et un ensemble d’indicateurs pour l’élément correspondant dans le tableau de points. Les types de points et indicateurs possibles sont répertoriés dans l’énumération PathPointType .

Exemples

L’exemple suivant crée un objet GraphicsPath , puis ajoute un rectangle et une ellipse au chemin. Le code passe l’adresse de cet objet GraphicsPath à un constructeur GraphicsPathIterator pour créer un itérateur associé au chemin d’accès. Le code appelle la méthode GraphicsPathIterator ::GetCount de l’itérateur pour déterminer le nombre de points de données dans le chemin d’accès. L’appel à GraphicsPathIterator ::Enumerate récupère deux tableaux du chemin d’accès : un qui contient les points de données du chemin d’accès et l’autre qui contient les types de points du chemin d’accès. Une fois les points de données récupérés, le code appelle la méthode FillEllipse d’un objet pour dessiner chacun des points de données.


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;
}

Configuration requise

Condition requise Valeur
Client minimal pris en charge Windows XP, Windows 2000 Professionnel [applications de bureau uniquement]
Serveur minimal pris en charge Windows 2000 Server [applications de bureau uniquement]
Plateforme cible Windows
En-tête gdipluspath.h (inclure Gdiplus.h)
Bibliothèque Gdiplus.lib
DLL Gdiplus.dll

Voir aussi

Génération et dessin de tracés

GetPathData

Méthodes GetPathPoints

GetPathTypes

GetPointCount

Graphicspath

GraphicsPathIterator

GraphicsPathIterator ::CopyData

GraphicsPathIterator ::Énumérer

Chemins d’accès