GraphicsPath::GetBounds(RectF*,constMatrix*,constPen*) method (gdipluspath.h)
The GraphicsPath::GetBounds method gets a bounding rectangle for this path.
Syntax
Status GetBounds(
RectF *bounds,
const Matrix *matrix,
const Pen *pen
);
Parameters
bounds
Pointer to a RectF object that receives the bounding rectangle.
matrix
Optional. Pointer to a Matrix object that specifies a transformation to be applied to this path before the bounding rectangle is calculated. This path is not permanently transformed; the transformation is used only during the process of calculating the bounding rectangle. The default value is NULL.
pen
Optional. Pointer to a Pen object that influences the size of the bounding rectangle. The bounding rectangle received in bounds will be large enough to enclose this path when the path is drawn with the pen specified by this parameter. This ensures that the path is enclosed by the bounding rectangle even if the path is drawn with a wide pen. The default value is NULL.
Return value
Type: Status
If the method succeeds, it returns Ok, which is an element of the Status enumeration.
If the method fails, it returns one of the other elements of the Status enumeration.
Remarks
The rectangle returned by this method might be larger than necessary to enclose the path as drawn by the specified pen. The rectangle is calculated to allow for the pen's miter limit at sharp corners and to allow for the pen's end caps.
Examples
The following example creates a path that has one curve and one ellipse. The code draws the path with a thick yellow pen and a thin black pen. The GraphicsPath::GetBounds method receives the address of the thick yellow pen and calculates a bounding rectangle for the path. Then the code draws the bounding rectangle.
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)
Requirements
Requirement | Value |
---|---|
Header | gdipluspath.h |