Condividi tramite


Metodo GraphicsPathIterator::GetCount (gdipluspath.h)

Il metodo GraphicsPathIterator::GetCount restituisce il numero di punti dati nel percorso.

Sintassi

INT GetCount();

Valore restituito

Tipo: INT

Questo metodo restituisce il numero di punti dati nel percorso.

Commenti

Questo oggetto GraphicsPathIterator è associato a un oggetto GraphicsPath . L'oggetto GraphicsPath include una matrice di punti e una matrice di tipi. Ogni elemento nella matrice di tipi è un byte che specifica il tipo di punto e un set di flag per l'elemento corrispondente nella matrice di punti. I tipi di punti e i flag possibili sono elencati nell'enumerazione PathPointType .

Esempio

L'esempio seguente crea un oggetto GraphicsPath e quindi aggiunge un rettangolo e un puntini di sospensione al percorso. Il codice passa l'indirizzo dell'oggetto GraphicsPath a un costruttore GraphicsPathIterator per creare un iteratore associato al percorso. Il codice chiama il metodo GraphicsPathIterator::GetCount per determinare il numero di punti dati nel percorso. La chiamata a GraphicsPathIterator::Enumerate recupera due matrici dal percorso: una che contiene i punti dati del percorso e una che contiene i tipi di punto del percorso. Dopo aver recuperato i punti dati, il codice chiama il metodo FillEllipse di un oggetto per disegnare ognuno dei punti dati.


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

Requisiti

Requisito Valore
Client minimo supportato Windows XP, Windows 2000 Professional [solo app desktop]
Server minimo supportato Windows 2000 Server [solo app desktop]
Piattaforma di destinazione Windows
Intestazione gdipluspath.h (include Gdiplus.h)
Libreria Gdiplus.lib
DLL Gdiplus.dll

Vedi anche

Costruzione e creazione di percorsi

GetPathData

Metodi GetPathPoints

GetPathTypes

GetPointCount

GraphicsPath

GraphicsPathIterator

GraphicsPathIterator::CopyData

GraphicsPathIterator::Enumerate

Percorsi