GraphicsPath::GetBounds(RectF*,constMatrix*,constPen*) 方法(gdipluspath.h)

GraphicsPath::GetBounds 方法會取得這個路徑的周框。

語法

Status GetBounds(
  RectF        *bounds,
  const Matrix *matrix,
  const Pen    *pen
);

參數

bounds

接收周框之 RectF 物件的指標。

matrix

自選。 Matrix 物件的指標,指定要在計算周框之前套用至此路徑的轉換。 此路徑不會永久轉換;轉換只會在計算周框的程序期間使用。 預設值為 NULL

pen

自選。 影響周框大小的 Pen 物件的指標。 當路徑是以此參數指定的手寫筆繪製時,以界限接收的周框會足夠大,以括住此路徑。 這可確保路徑會以周框括住,即使路徑是以寬畫筆繪製也一樣。 預設值為 NULL

傳回值

類型:狀態

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

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

言論

這個方法所傳回的矩形可能大於以指定畫筆繪製的路徑。 矩形會計算為允許尖角的畫筆的Miter限制,並允許畫筆的結束帽。

例子

下列範例會建立具有一個曲線和一個橢圓的路徑。 程序代碼會使用厚黃色畫筆和細黑色畫筆繪製路徑。 GraphicsPath::GetBounds 方法會接收厚黃色畫筆的位址,並計算路徑的周框。 然後程式代碼會繪製周框。


VOID GetBoundsExample(HDC hdc)
{
   Graphics graphics(hdc);
   Pen blackPen(Color(255, 0, 0, 0), 1);
   Pen yellowPen(Color(255, 255, 255, 0), 10);
   Pen redPen(Color(255, 255, 0, 0), 1);

   Point pts[] = {Point(120,120), 
                  Point(200,130), 
                  Point(150,200), 
                  Point(130,180)};

   // Create a path that has one curve and one ellipse.
   GraphicsPath path;
   path.AddClosedCurve(pts, 4);
   path.AddEllipse(120, 220, 100, 40);

   // Draw the path with a thick yellow pen and a thin black pen.
   graphics.DrawPath(&yellowPen, &path);
   graphics.DrawPath(&blackPen, &path);

   // Get the path's bounding rectangle.
   RectF rect;
   path.GetBounds(&rect, NULL, &yellowPen);
   graphics.DrawRectangle(&redPen, rect);  
}

Color(255, 0, 0, 0)Color(255, 255, 0,  0)

要求

要求 價值
標頭 gdipluspath.h

另請參閱

使用區域 進行裁剪

建構和繪製路徑

建立路徑漸層

GraphicsPath

矩陣

路徑

手寫筆

RectF