GraphicsPath::GetPathPoints (PointF*,INT) 方法 (gdipluspath.h)

GraphicsPath::GetPathPoints 方法會取得這個路徑的點數組。 數位包含用來繪製路徑之線條和 Bézier 曲線的端點和控制點。

語法

Status GetPathPoints(
  PointF *points,
  INT    count
);

參數

points

指向接收數據點之 PointF 物件的陣列指標。 您必須為此陣列設定記憶體。 您可以呼叫 GraphicsPath::GetPointCount 方法,以判斷陣列的必要大小。 大小,以位元組為單位,應該是 GraphicsPath::GetPointCountsizeof(PointF)以 的傳回值。

count

整數,指定點陣列中的項目數目。 將此參數設定為 GraphicsPath::GetPointCount 方法的傳回值。

傳回值

Type:Status

如果方法成功,它會傳回Ok,這是 Status 列舉的元素。

如果方法失敗,它會傳回 Status 列舉的其中一個其他元素。

備註

GraphicsPath 物件具有點數位和類型的數位。 型別數位中的每個元素都是位元組,指定點類型,以及點陣列中對應元素的一組旗標。 PathPointType 列舉中會列出可能的點類型和旗標。

範例

下列範例會建立並繪製具有線條、矩形、橢圓形和曲線的路徑。 程序代碼會呼叫路徑的 GraphicsPath::GetPointCount 方法,以判斷儲存在路徑中的數據點數目。 程序代碼會配置足以接收數據點數位的緩衝區,並將該緩衝區的位址傳遞至 GraphicsPath::GetPathPoints 方法。 最後,程式代碼會繪製每個路徑的數據點。

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

   // Create a path that has a line, a rectangle, an ellipse, and a curve.
   GraphicsPath path;

   PointF points[] = {
      PointF(200, 200),
      PointF(250, 240),
      PointF(200, 300),
      PointF(300, 310),
      PointF(250, 350)};

   path.AddLine(20, 100, 150, 200);
   path.AddRectangle(Rect(40, 30, 80, 60));
   path.AddEllipse(Rect(200, 30, 200, 100));
   path.AddCurve(points, 5);

   // Draw the path.
   Pen pen(Color(255, 0, 0, 255));
   graphics.DrawPath(&pen, &path);

   // Get the path points.
   INT count = path.GetPointCount();
   PointF* dataPoints = new PointF[count];  
   path.GetPathPoints(dataPoints, count);

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

規格需求

需求
標頭 gdipluspath.h

另請參閱

GraphicsPath

GraphicsPath::GetPathData

GraphicsPath::GetPathTypes

GraphicsPath::GetPointCount

PathData

PathPointType

PointF

使用區域裁剪

建構和繪製路徑

建立路徑漸層

路徑