GraphicsPath.GetBoundsとは? わかりやすく解説

GraphicsPath.GetBounds メソッド ()

この GraphicsPath に外接する四角形を返します。

名前空間: System.Drawing.Drawing2D
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Function GetBounds As
 RectangleF
Dim instance As GraphicsPath
Dim returnValue As RectangleF

returnValue = instance.GetBounds
public RectangleF GetBounds ()
public:
RectangleF GetBounds ()
public RectangleF GetBounds ()
public function GetBounds () : RectangleF

戻り値
この GraphicsPath に外接する四角形を表す RectangleF。

解説解説
使用例使用例

次のコード例は、Windows フォームでの使用を意図してデザインされており、OnPaint イベント オブジェクトである PaintEventArgse が必要です。このコードは次のアクションを実行します。

右側に外接する四角形の方が (直線の幅が広いことを考慮して) 大きくなります。

Public Sub GetBoundsExample(ByVal
 e As PaintEventArgs)

    ' Create path number 1 and a Pen for drawing.
    Dim myPath As New GraphicsPath
    Dim pathPen As New Pen(Color.Black,
 1)

    ' Add an Ellipse to the path and Draw it (circle in start

    ' position).
    myPath.AddEllipse(20, 20, 100, 100)
    e.Graphics.DrawPath(pathPen, myPath)

    ' Get the path bounds for Path number 1 and draw them.
    Dim boundRect As RectangleF = myPath.GetBounds()
    e.Graphics.DrawRectangle(New Pen(Color.Red, 1), boundRect.X,
 _
    boundRect.Y, boundRect.Height, boundRect.Width)

    ' Create a second graphics path and a wider Pen.
    Dim myPath2 As New GraphicsPath
    Dim pathPen2 As New
 Pen(Color.Black, 10)

    ' Create a new ellipse with a width of 10.
    myPath2.AddEllipse(150, 20, 100, 100)
    myPath2.Widen(pathPen2)
    e.Graphics.FillPath(Brushes.Black, myPath2)

    ' Get the second path bounds.
    Dim boundRect2 As RectangleF = myPath2.GetBounds()

    ' Show the bounds in a message box.
    e.Graphics.DrawString("Rectangle2 Bounds: " +
 _
    boundRect2.ToString(), New Font("Arial",
 8), Brushes.Black, _
    20, 150)

    ' Draw the bounding rectangle.
    e.Graphics.DrawRectangle(New Pen(Color.Red, 1), boundRect2.X,
 _
    boundRect2.Y, boundRect2.Height, boundRect2.Width)
End Sub
public void GetBoundsExample(PaintEventArgs
 e)
{
             
    // Create path number 1 and a Pen for drawing.
    GraphicsPath myPath = new GraphicsPath();
    Pen pathPen = new Pen(Color.Black, 1);
             
    // Add an Ellipse to the path and Draw it (circle in start
             
    // position).
    myPath.AddEllipse(20, 20, 100, 100);
    e.Graphics.DrawPath(pathPen, myPath);
             
    // Get the path bounds for Path number 1 and draw them.
    RectangleF boundRect = myPath.GetBounds();
    e.Graphics.DrawRectangle(new Pen(Color.Red, 1),
        boundRect.X,
        boundRect.Y,
        boundRect.Height,
        boundRect.Width);
             
    // Create a second graphics path and a wider Pen.
    GraphicsPath myPath2 = new GraphicsPath();
    Pen pathPen2 = new Pen(Color.Black, 10);
             
    // Create a new ellipse with a width of 10.
    myPath2.AddEllipse(150, 20, 100, 100);
    myPath2.Widen(pathPen2);
    e.Graphics.FillPath(Brushes.Black, myPath2);
             
    // Get the second path bounds.
    RectangleF boundRect2 = myPath2.GetBounds();
             
    // Draw the bounding rectangle.
    e.Graphics.DrawRectangle(new Pen(Color.Red, 1),
        boundRect2.X,
        boundRect2.Y,
        boundRect2.Height,
        boundRect2.Width);
             
    // Display the rectangle size.
    MessageBox.Show(boundRect2.ToString());
}
public:
   void GetBoundsExample( PaintEventArgs^ e )
   {
      // Create path number 1 and a Pen for drawing.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      Pen^ pathPen = gcnew Pen( Color::Black,1.0f );

      // Add an Ellipse to the path and Draw it (circle in start
      // position).
      myPath->AddEllipse( 20, 20, 100, 100 );
      e->Graphics->DrawPath( pathPen, myPath );

      // Get the path bounds for Path number 1 and draw them.
      RectangleF boundRect = myPath->GetBounds();
      e->Graphics->DrawRectangle( gcnew Pen( Color::Red,1.0f ), boundRect.X,
 boundRect.Y, boundRect.Height, boundRect.Width );

      // Create a second graphics path and a wider Pen.
      GraphicsPath^ myPath2 = gcnew GraphicsPath;
      Pen^ pathPen2 = gcnew Pen( Color::Black,10.0f );

      // Create a new ellipse with a width of 10.
      myPath2->AddEllipse( 150, 20, 100, 100 );
      myPath2->Widen( pathPen2 );
      e->Graphics->FillPath( Brushes::Black, myPath2 );

      // Get the second path bounds.
      RectangleF boundRect2 = myPath2->GetBounds();

      // Draw the bounding rectangle.
      e->Graphics->DrawRectangle( gcnew Pen( Color::Red,1.0f ), boundRect2.X,
 boundRect2.Y, boundRect2.Height, boundRect2.Width );

      // Display the rectangle size.
      MessageBox::Show( boundRect2.ToString() );
   }
public void GetBoundsExample(PaintEventArgs
 e)
{
    // Create path number 1 and a Pen for drawing.
    GraphicsPath myPath = new GraphicsPath();
    Pen pathPen = new Pen(Color.get_Black(), 1);

    // Add an Ellipse to the path and Draw it (circle in start
    // position).
    myPath.AddEllipse(20, 20, 100, 100);
    e.get_Graphics().DrawPath(pathPen, myPath);

    // Get the path bounds for Path number 1 and draw them.
    RectangleF boundRect = myPath.GetBounds();

    e.get_Graphics().DrawRectangle(new Pen(Color.get_Red(), 1)
,
        boundRect.get_X(), boundRect.get_Y(), boundRect.get_Height(),
        boundRect.get_Width());

    // Create a second graphics path and a wider Pen.
    GraphicsPath myPath2 = new GraphicsPath();
    Pen pathPen2 = new Pen(Color.get_Black(), 10);

    // Create a new ellipse with a width of 10.
    myPath2.AddEllipse(150, 20, 100, 100);
    myPath2.Widen(pathPen2);
    e.get_Graphics().FillPath(Brushes.get_Black(), myPath2);

    // Get the second path bounds.
    RectangleF boundRect2 = myPath2.GetBounds();

    // Draw the bounding rectangle.
    e.get_Graphics().DrawRectangle(new Pen(Color.get_Red(), 1)
,
        boundRect2.get_X(), boundRect2.get_Y(), boundRect2.get_Height(),
        boundRect2.get_Width());

    // Display the rectangle size.
    MessageBox.Show(boundRect2.ToString());
} //GetBoundsExample
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
GraphicsPath クラス
GraphicsPath メンバ
System.Drawing.Drawing2D 名前空間

GraphicsPath.GetBounds メソッド (Matrix, Pen)

現在のパスが指定された Matrix によって変換され、指定された Pen で描画されるときに、この GraphicsPath に外接する四角形を返します。

名前空間: System.Drawing.Drawing2D
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Function GetBounds ( _
    matrix As Matrix, _
    pen As Pen _
) As RectangleF
Dim instance As GraphicsPath
Dim matrix As Matrix
Dim pen As Pen
Dim returnValue As RectangleF

returnValue = instance.GetBounds(matrix, pen)
public RectangleF GetBounds (
    Matrix matrix,
    Pen pen
)
public:
RectangleF GetBounds (
    Matrix^ matrix, 
    Pen^ pen
)
public RectangleF GetBounds (
    Matrix matrix, 
    Pen pen
)
public function GetBounds (
    matrix : Matrix, 
    pen : Pen
) : RectangleF

パラメータ

matrix

外接する四角形を計算する前に、このパスに適用される変換を指定する Matrix。パスは恒久的に変換されるわけではありません。変換は、外接する四角形を計算する処理の中だけで使用されます。

pen

GraphicsPath の描画に使用する Pen。

戻り値
この GraphicsPath に外接する四角形を表す RectangleF。

解説解説
使用例使用例
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
GraphicsPath クラス
GraphicsPath メンバ
System.Drawing.Drawing2D 名前空間

GraphicsPath.GetBounds メソッド (Matrix)

このパスが指定された Matrix に変換されたときに、この GraphicsPath に外接する四角形を返します。

名前空間: System.Drawing.Drawing2D
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Function GetBounds ( _
    matrix As Matrix _
) As RectangleF
Dim instance As GraphicsPath
Dim matrix As Matrix
Dim returnValue As RectangleF

returnValue = instance.GetBounds(matrix)
public RectangleF GetBounds (
    Matrix matrix
)
public:
RectangleF GetBounds (
    Matrix^ matrix
)
public RectangleF GetBounds (
    Matrix matrix
)
public function GetBounds (
    matrix : Matrix
) : RectangleF

パラメータ

matrix

外接する四角形を計算する前に、このパスに適用される変換を指定する Matrix。パスは恒久的に変換されるわけではありません。変換は、外接する四角形を計算する処理の中だけで使用されます。

戻り値
この GraphicsPath に外接する四角形を表す RectangleF。

解説解説
使用例使用例
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
GraphicsPath クラス
GraphicsPath メンバ
System.Drawing.Drawing2D 名前空間

GraphicsPath.GetBounds メソッド

この GraphicsPath に外接する四角形を返します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
GraphicsPath.GetBounds () この GraphicsPath に外接する四角形を返します。
GraphicsPath.GetBounds (Matrix) このパスが指定された Matrix に変換されたときに、この GraphicsPath に外接する四角形を返します。
GraphicsPath.GetBounds (Matrix, Pen) 現在のパスが指定された Matrix によって変換され、指定された Pen で描画されるときに、この GraphicsPath に外接する四角形を返します。
参照参照

関連項目

GraphicsPath クラス
GraphicsPath メンバ
System.Drawing.Drawing2D 名前空間



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「GraphicsPath.GetBounds」の関連用語

GraphicsPath.GetBoundsのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



GraphicsPath.GetBoundsのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS