Graphics

System.Drawing.Graphics

Namespace: System.Drawing

Assembly: System.Drawing.Managed (4.0.0.0)

Encapsulates a GDI+ drawing surface.

public class Graphics : MarshalByRefObject, IDisposable

Properties

Clip

Region: Gets or sets a Region that limits the drawing region of this Graphics.

ClipBounds

RectangleF: Gets a RectangleF structure that bounds the clipping region of this Graphics.

CompositingMode

CompositingMode: Gets or sets a value that specifies how composited images are drawn to this Graphics.

CompositingQuality

CompositingQuality: Gets or sets the rendering quality of composited images drawn to this Graphics.

DpiX

Single: Gets the horizontal resolution of this Graphics.

DpiY

Single: Gets the vertical resolution of this Graphics.

InterpolationMode

InterpolationMode: Gets or sets the interpolation mode associated with this Graphics.

IsClipEmpty

Boolean: Gets a value indicating whether the clipping region of this Graphics is empty.

PageScale

Single: Gets or sets the scaling between world units and page units for this Graphics.

PageUnit

GraphicsUnit: Gets or sets the unit of measure used for page coordinates in this Graphics.

PixelOffsetMode

PixelOffsetMode: Gets or sets a value specifying how pixels are offset during rendering of this Graphics.

RenderingOrigin

Point: Gets or sets the rendering origin of this Graphics for dithering and for hatch brushes.

SmoothingMode

SmoothingMode: Gets or sets the rendering quality for this Graphics.

TextContrast

Int32: Gets or sets the gamma correction value for rendering text.

TextRenderingHint

TextRenderingHint: Gets or sets the rendering mode for text associated with this Graphics.

Transform

Matrix: Gets or sets a copy of the geometric world transformation for this Graphics.

GDI+ uses three coordinate spaces: world, page, and device. World coordinates are the coordinates used to model a particular graphic world and are the coordinates you pass to methods in the .NET Framework. Page coordinates refer to the coordinate system used by a drawing surface, such as a form or a control. Device coordinates are the coordinates used by the physical device being drawn on, such as a screen or a printer. The Transform property represents the world transformation, which maps world coordinates to page coordinates. Because the matrix returned and by the Transform property is a copy of the geometric transform, you should dispose of the matrix when you no longer need it.

VisibleClipBounds

RectangleF: Gets the bounding rectangle of the visible clipping region of this Graphics.

Methods

BeginContainer()

Saves a graphics container with the current state of this Graphics and opens and uses a new graphics container.

Returns: GraphicsContainer. The GraphicsContainer.

BeginContainer(dstRect, srcRect, unit)

Saves a graphics container with the current state of this Graphics and opens and uses a new graphics container with the specified scale transformation.

Parameter
Type
Description

dstRect

Rectangle structure that, together with the srcRect parameter, specifies a scale transformation for the container.

srcRect

Rectangle structure that, together with the dstRect parameter, specifies a scale transformation for the container.

unit

Member of the GraphicsUnit enumeration that specifies the units of measure for the dstRect

Returns: GraphicsContainer. The GraphicsContainer.

BeginContainer(dstRect, srcRect, unit)

Saves a graphics container with the current state of this Graphics and opens and uses a new graphics container with the specified scale transformation.

Parameter
Type
Description

dstRect

RectangleF structure that, together with the srcRect parameter, specifies a scale transformation for the container.

srcRect

RectangleF structure that, together with the dstRect parameter, specifies a scale transformation for the container.

unit

Member of the GraphicsUnit enumeration that specifies the units of measure for the dstRect

Returns: GraphicsContainer. The GraphicsContainer.

Clear(color)

Clears the entire drawing surface and fills it with the specified background color.

Parameter
Type
Description

color

Color structure that represents the background color of the drawing surface.

Dispose()

DrawArc(pen, x, y, width, height, startAngle, sweepAngle)

Draws an arc from the specified ellipse.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the arc.

x

The x-coordinate of the upper-left corner of the rectangle that defines the ellipse.

y

The y-coordinate of the upper-left corner of the rectangle that defines the ellipse.

width

Width of the rectangle that defines the ellipse.

height

Height of the rectangle that defines the ellipse.

startAngle

Angle in degrees measured clockwise from the x-axis to the starting point of the arc.

sweepAngle

Angle in degrees measured clockwise from the startAngle parameter to ending point of the arc.

DrawArc(pen, rect, startAngle, sweepAngle)

Draws an arc from the specified ellipse.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the arc.

rect

RectangleF structure that defines the boundaries of the ellipse.

startAngle

Angle in degrees measured clockwise from the x-axis to the starting point of the arc.

sweepAngle

Angle in degrees measured clockwise from the startAngle parameter to ending point of the arc.

DrawArc(pen, x, y, width, height, startAngle, sweepAngle)

Draws an arc from the specified ellipse.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the arc.

x

The x-coordinate of the upper-left corner of the rectangle that defines the ellipse.

y

The y-coordinate of the upper-left corner of the rectangle that defines the ellipse.

width

Width of the rectangle that defines the ellipse.

height

Height of the rectangle that defines the ellipse.

startAngle

Angle in degrees measured clockwise from the x-axis to the starting point of the arc.

sweepAngle

Angle in degrees measured clockwise from the startAngle parameter to ending point of the arc.

Throws:

DrawArc(pen, rect, startAngle, sweepAngle)

Draws an arc from the specified ellipse.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the arc.

rect

RectangleF structure that defines the boundaries of the ellipse.

startAngle

Angle in degrees measured clockwise from the x-axis to the starting point of the arc.

sweepAngle

Angle in degrees measured clockwise from the startAngle parameter to ending point of the arc.

DrawBezier(pen, x1, y1, x2, y2, x3, y3, x4, y4)

Draws a Bezier spline defined by four ordered pairs of coordinates that represent points.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the curve.

x1

The x-coordinate of the starting point of the curve.

y1

The y-coordinate of the starting point of the curve.

x2

The x-coordinate of the first control point of the curve.

y2

The y-coordinate of the first control point of the curve.

x3

The x-coordinate of the second control point of the curve.

y3

The y-coordinate of the second control point of the curve.

x4

The x-coordinate of the ending point of the curve.

y4

The y-coordinate of the ending point of the curve.

Throws:

DrawBezier(pen, pt1, pt2, pt3, pt4)

Draws a Bezier spline defined by four PointF structures.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the curve.

pt1

PointF structure that represents the starting point of the curve.

pt2

PointF structure that represents the first control point for the curve.

pt3

PointF structure that represents the second control point for the curve.

pt4

PointF structure that represents the ending point of the curve.

DrawBezier(pen, pt1, pt2, pt3, pt4)

Draws a Bezier spline defined by four Point structures.

Parameter
Type
Description

pen

Pen structure that determines the color, width, and style of the curve.

pt1

Point structure that represents the starting point of the curve.

pt2

Point structure that represents the first control point for the curve.

pt3

Point structure that represents the second control point for the curve.

pt4

Point structure that represents the ending point of the curve.

DrawBeziers(pen, points)

Draws a series of cubic Bezier curves from an array of points.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the curve.

points

Array of PointF structures that represent the points that determine the curve. The number of points in the array should be a multiple of 3 plus 1, such as 4, 7, or 10.

DrawBeziers(pen, points)

Draws a series of cubic Bezier curves from an array of points.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the curve.

points

Array of PointF structures that represent the points that determine the curve. The number of points in the array should be a multiple of 3 plus 1, such as 4, 7, or 10.

DrawClosedCurve(pen, points)

Draws a closed curve defined by an array of points.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the curve.

points

Array of PointF structures that define the spline.

DrawClosedCurve(pen, points, tension)

Draws a closed curve defined by an array of points.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the curve.

points

Array of PointF structures that define the spline.

tension

Value greater than or equal to 0.0F that specifies the tension of the curve.

DrawClosedCurve(pen, points)

Draws a closed curve defined by an array of points.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the curve.

points

Array of Point structures that define the spline.

DrawClosedCurve(pen, points, tension)

Draws a closed curve defined by an array of points.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the curve.

points

Array of Point structures that define the spline.

tension

Value greater than or equal to 0.0F that specifies the tension of the curve.

DrawCurve(pen, points)

Draws a curve defined by an array of points.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the curve.

points

An array of PointF structures that represents the points that define the curve.

DrawCurve(pen, points, tension)

Draws a curve defined by an array of points.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the curve.

points

An array of PointF structures that represents the points that define the curve.

tension

A value that specifies the amount that the curve bends between control points. Values greater than 1 produce unpredictable results.

DrawCurve(pen, points, offset, numberOfSegments)

Draws a curve defined by an array of points.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the curve.

points

An array of PointF structures that represents the points that define the curve.

offset

The index of the element in the points array that is used as the first point in the curve.

numberOfSegments

The number of segments used to draw the curve. A segment can be thought of as a line connecting two points.

DrawCurve(pen, points, offset, numberOfSegments, tension)

Draws a curve defined by an array of points.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the curve.

points

An array of PointF structures that represents the points that define the curve.

offset

The index of the element in the points array that is used as the first point in the curve.

numberOfSegments

The number of segments used to draw the curve. A segment can be thought of as a line connecting two points.

tension

A value that specifies the amount that the curve bends between control points. Values greater than 1 produce unpredictable results.

DrawCurve(pen, points)

Draws a curve defined by an array of points.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the curve.

points

An array of Point structures that represents the points that define the curve.

DrawCurve(pen, points, tension)

Draws a curve defined by an array of points.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the curve.

points

An array of Point structures that represents the points that define the curve.

tension

A value that specifies the amount that the curve bends between control points. Values greater than 1 produce unpredictable results.

DrawCurve(pen, points, offset, numberOfSegments)

Draws a curve defined by an array of points.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the curve.

points

An array of PointF structures that represents the points that define the curve.

offset

The index of the element in the points array that is used as the first point in the curve.

numberOfSegments

The number of segments used to draw the curve. A segment can be thought of as a line connecting two points.

DrawCurve(pen, points, offset, numberOfSegments, tension)

Draws a curve defined by an array of points.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the curve.

points

An array of Point structures that represents the points that define the curve.

offset

The index of the element in the points array that is used as the first point in the curve.

numberOfSegments

The number of segments used to draw the curve. A segment can be thought of as a line connecting two points.

tension

A value that specifies the amount that the curve bends between control points. Values greater than 1 produce unpredictable results.

DrawEllipse(pen, rect)

Draws the outline of an ellipse defined by a bounding rectangle.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the ellipse.

rect

RectangleF structure that defines the boundaries of the ellipse.

DrawEllipse(pen, x, y, width, height)

Draws the outline of an ellipse defined by a bounding rectangle.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the ellipse.

x

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

y

The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

width

Width of the bounding rectangle that defines the ellipse.

height

Height of the bounding rectangle that defines the ellipse.

DrawEllipse(pen, rect)

Draws the outline of an ellipse specified by a bounding Rectangle structure.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the ellipse.

rect

Rectangle structure that defines the boundaries of the ellipse.

DrawEllipse(pen, x, y, width, height)

Draws the outline of an ellipse defined by a bounding rectangle specified by coordinates for the upper-left corner of the rectangle, a height, and a width.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the ellipse.

x

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

y

The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

width

Width of the bounding rectangle that defines the ellipse.

height

Height of the bounding rectangle that defines the ellipse.

DrawImage(image, point)

Draws the specified image at the specified location.

Parameter
Type
Description

image

Image to draw.

point

Point structure that represents the location of the upper-left corner of the drawn image.

Throws:

DrawImage(image, x, y)

Draws the specified image, using its original physical size, at the location specified by a coordinate pair.

Parameter
Type
Description

image

Image to draw.

x

The x-coordinate of the upper-left corner of the drawn image.

y

The y-coordinate of the upper-left corner of the drawn image.

Throws:

DrawImage(image, rect)

Draws the specified Image at the specified location and with the specified size.

Parameter
Type
Description

image

Image to draw.

rect

Rectangle structure that specifies the location and size of the drawn image.

Throws:

DrawImage(image, x, y, width, height)

Draws the specified Image at the specified location and with the specified size.

Parameter
Type
Description

image

Image to draw.

x

The x-coordinate of the upper-left corner of the drawn image.

y

The y-coordinate of the upper-left corner of the drawn image.

width

Width of the drawn image.

height

Height of the drawn image.

Throws:

DrawImage(image, point)

Draws the specified Image, using its original physical size, at the specified location.

Parameter
Type
Description

image

Image to draw.

point

Point structure that represents the location of the upper-left corner of the drawn image.

Throws:

DrawImage(image, x, y)

Draws the specified image, using its original physical size, at the location specified by a coordinate pair.

Parameter
Type
Description

image

Image to draw.

x

The x-coordinate of the upper-left corner of the drawn image.

y

The y-coordinate of the upper-left corner of the drawn image.

Throws:

DrawImage(image, rect)

Draws the specified Image at the specified location and with the specified size.

Parameter
Type
Description

image

Image to draw.

rect

Rectangle structure that specifies the location and size of the drawn image.

Throws:

DrawImage(image, x, y, width, height)

Draws the specified Image at the specified location and with the specified size.

Parameter
Type
Description

image

Image to draw.

x

The x-coordinate of the upper-left corner of the drawn image.

y

The y-coordinate of the upper-left corner of the drawn image.

width

Width of the drawn image.

height

Height of the drawn image.

Throws:

DrawImage(image, destPoints)

Draws the specified portion of the specified Image at the specified location and with the specified size.

Parameter
Type
Description

image

Image to draw.

destPoints

Array of three PointF structures that define a parallelogram.

Throws:

DrawImage(image, destPoints)

Draws the specified portion of the specified Image at the specified location and with the specified size.

Parameter
Type
Description

image

Image to draw.

destPoints

Array of three PointF structures that define a parallelogram.

Throws:

DrawImage(image, x, y, srcRect, srcUnit)

Draws a portion of an image at a specified location.

Parameter
Type
Description

image

Image to draw.

x

The x-coordinate of the upper-left corner of the drawn image.

y

The y-coordinate of the upper-left corner of the drawn image.

srcRect

RectangleF structure that specifies the portion of the image object to draw.

srcUnit

Member of the GraphicsUnit enumeration that specifies the units of measure used by the srcRect parameter.

Throws:

DrawImage(image, x, y, srcRect, srcUnit)

Draws a portion of an image at a specified location.

Parameter
Type
Description

image

Image to draw.

x

The x-coordinate of the upper-left corner of the drawn image.

y

The y-coordinate of the upper-left corner of the drawn image.

srcRect

RectangleF structure that specifies the portion of the image object to draw.

srcUnit

Member of the GraphicsUnit enumeration that specifies the units of measure used by the srcRect parameter.

Throws:

DrawImage(image, destRect, srcRect, srcUnit)

Draws the specified portion of the specified Image at the specified location and with the specified size.

Parameter
Type
Description

image

Image to draw.

destRect

RectangleF structure that specifies the location and size of the drawn image. The image is scaled to fit the rectangle.

srcRect

RectangleF structure that specifies the portion of the image object to draw.

srcUnit

Member of the GraphicsUnit enumeration that specifies the units of measure used by the srcRect parameter.

Throws:

DrawImage(image, destRect, srcRect, srcUnit)

Draws the specified portion of the specified Image at the specified location and with the specified size.

Parameter
Type
Description

image

Image to draw.

destRect

Rectangle structure that specifies the location and size of the drawn image. The image is scaled to fit the rectangle.

srcRect

Rectangle structure that specifies the portion of the image object to draw.

srcUnit

Member of the GraphicsUnit enumeration that specifies the units of measure used by the srcRect parameter.

Throws:

DrawImage(image, destPoints, srcRect, srcUnit)

Draws the specified portion of the specified Image at the specified location and with the specified size.

Parameter
Type
Description

image

Image to draw.

destPoints

Array of three PointF structures that define a parallelogram.

srcRect

Rectangle structure that specifies the portion of the image object to draw.

srcUnit

Member of the GraphicsUnit enumeration that specifies the units of measure used to determine the source rectangle.

Throws:

DrawImage(image, destPoints, srcRect, srcUnit, imageAttr)

Draws the specified portion of the specified Image at the specified location and with the specified size.

Parameter
Type
Description

image

Image to draw.

destPoints

Array of three PointF structures that define a parallelogram.

srcRect

Rectangle structure that specifies the portion of the image object to draw.

srcUnit

Member of the GraphicsUnit enumeration that specifies the units of measure used to determine the source rectangle.

imageAttr

ImageAttributes that specifies recoloring and gamma information for the image object.

Throws:

DrawImage(image, destPoints, srcRect, srcUnit)

Draws the specified portion of the specified Image at the specified location and with the specified size.

Parameter
Type
Description

image

Image to draw.

destPoints

Array of three Point structures that define a parallelogram.

srcRect

Rectangle structure that specifies the portion of the image object to draw.

srcUnit

Member of the GraphicsUnit enumeration that specifies the units of measure used to determine the source rectangle.

Throws:

DrawImage(image, destPoints, srcRect, srcUnit, imageAttr)

Draws the specified portion of the specified Image at the specified location and with the specified size.

Parameter
Type
Description

image

Image to draw.

destPoints

Array of three Point structures that define a parallelogram.

srcRect

Rectangle structure that specifies the portion of the image object to draw.

srcUnit

Member of the GraphicsUnit enumeration that specifies the units of measure used to determine the source rectangle.

imageAttr

ImageAttributes that specifies recoloring and gamma information for the image object.

Throws:

DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit)

Draws the specified portion of the specified Image at the specified location and with the specified size.

Parameter
Type
Description

image

Image to draw.

destRect

Rectangle structure that specifies the location and size of the drawn image. The image is scaled to fit the rectangle.

srcX

The x-coordinate of the upper-left corner of the portion of the source image to draw.

srcY

The y-coordinate of the upper-left corner of the portion of the source image to draw.

srcWidth

Width of the portion of the source image to draw.

srcHeight

Height of the portion of the source image to draw.

srcUnit

Member of the GraphicsUnit enumeration that specifies the units of measure used to determine the source rectangle.

Throws:

DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, imageAttr)

Draws the specified portion of the specified Image at the specified location and with the specified size.

Parameter
Type
Description

image

Image to draw.

destRect

Rectangle structure that specifies the location and size of the drawn image. The image is scaled to fit the rectangle.

srcX

The x-coordinate of the upper-left corner of the portion of the source image to draw.

srcY

The y-coordinate of the upper-left corner of the portion of the source image to draw.

srcWidth

Width of the portion of the source image to draw.

srcHeight

Height of the portion of the source image to draw.

srcUnit

Member of the GraphicsUnit enumeration that specifies the units of measure used to determine the source rectangle.

imageAttr

ImageAttributes that specifies recoloring and gamma information for the image object.

Throws:

DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit)

Draws the specified portion of the specified Image at the specified location and with the specified size.

Parameter
Type
Description

image

Image to draw.

destRect

Rectangle structure that specifies the location and size of the drawn image. The image is scaled to fit the rectangle.

srcX

The x-coordinate of the upper-left corner of the portion of the source image to draw.

srcY

The y-coordinate of the upper-left corner of the portion of the source image to draw.

srcWidth

Width of the portion of the source image to draw.

srcHeight

Height of the portion of the source image to draw.

srcUnit

Member of the GraphicsUnit enumeration that specifies the units of measure used to determine the source rectangle.

Throws:

DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, imageAttr)

Draws the specified portion of the specified Image at the specified location and with the specified size.

Parameter
Type
Description

image

Image to draw.

destRect

Rectangle structure that specifies the location and size of the drawn image. The image is scaled to fit the rectangle.

srcX

The x-coordinate of the upper-left corner of the portion of the source image to draw.

srcY

The y-coordinate of the upper-left corner of the portion of the source image to draw.

srcWidth

Width of the portion of the source image to draw.

srcHeight

Height of the portion of the source image to draw.

srcUnit

Member of the GraphicsUnit enumeration that specifies the units of measure used to determine the source rectangle.

imageAttr

ImageAttributes that specifies recoloring and gamma information for the image object.

Throws:

DrawImageUnscaled(image, x, y)

Draws the specified image using its original physical size at the location specified by a coordinate pair.

Parameter
Type
Description

image

Image to draw.

x

The x-coordinate of the upper-left corner of the drawn image.

y

The y-coordinate of the upper-left corner of the drawn image.

Throws:

DrawImageUnscaled(image, x, y, width, height)

Draws a specified image using its original physical size at a specified location.

Parameter
Type
Description

image

Image to draw.

x

The x-coordinate of the upper-left corner of the drawn image.

y

The y-coordinate of the upper-left corner of the drawn image.

width

Not used.

height

Not used

Throws:

DrawImageUnscaled(image, point)

Draws a specified image using its original physical size at a specified location.

Parameter
Type
Description

image

Image to draw.

point

Point structure that specifies the upper-left corner of the drawn image.

Throws:

DrawImageUnscaled(image, rect)

Draws a specified image using its original physical size at a specified location.

Parameter
Type
Description

image

Image to draw.

rect

Rectangle that specifies the upper-left corner of the drawn image. The X and Y properties of the rectangle specify the upper-left corner. The Width and Height properties are ignored.

Throws:

DrawImageUnscaledAndClipped(image, rect)

Draws the specified image without scaling and clips it, if necessary, to fit in the specified rectangle.

Parameter
Type
Description

image

The Image to draw

rect

The Rectangle in which to draw the image.

Throws:

DrawLine(pen, x1, y1, x2, y2)

Draws a line connecting the two points specified by the coordinate pairs.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the line.

x1

The x-coordinate of the first point.

y1

The y-coordinate of the first point.

x2

The x-coordinate of the second point.

y2

The y-coordinate of the second point.

Throws:

DrawLine(pen, x1, y1, x2, y2)

Draws a line connecting the two points specified by the coordinate pairs.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the line.

x1

The x-coordinate of the first point.

y1

The y-coordinate of the first point.

x2

The x-coordinate of the second point.

y2

The y-coordinate of the second point.

Throws:

DrawLine(pen, pt1, pt2)

Draws a line connecting two PointF structures.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the line.

pt1

Point structure that represents the first point to connect.

pt2

Point structure that represents the second point to connect.

DrawLine(pen, pt1, pt2)

Draws a line connecting two PointF structures.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the line.

pt1

PointF structure that represents the first point to connect.

pt2

PointF structure that represents the second point to connect.

DrawLines(pen, points)

Draws a series of line segments that connect an array of points.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the line.

points

Array of Point structures that represent the points to connect.

DrawLines(pen, points)

Draws a series of line segments that connect an array of points.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the line.

points

Array of PointF structures that represent the points to connect.

DrawPath(pen, path)

Draws a GraphicsPath.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the path.

Throws:

DrawPie(pen, rect, startAngle, sweepAngle)

Draws the outline of a pie shape. The pie shape is a section of an ellipse. The ellipse is specified by a RectangleF structure. Two radial lines indicate the start and end of the pie slice.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the pie shape.

rect

RectangleF structure that represents the bounding rectangle that defines the ellipse from which the pie shape comes.

startAngle

Angle measured in degrees clockwise from the x-axis to the first side of the pie shape.

sweepAngle

Angle measured in degrees clockwise from the startAngle parameter to the second side of the pie shape.

DrawPie(pen, x, y, width, height, startAngle, sweepAngle)

Draws the outline of a pie shape. The pie shape is a section of an ellipse. The ellipse is specified by a coordinate pair, a width, and a height. Two radial lines indicate the start and end of the pie slice.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the pie shape.

x

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes.

y

The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes.

width

Width of the bounding rectangle that defines the ellipse from which the pie shape comes.

height

Height of the bounding rectangle that defines the ellipse from which the pie shape comes.

startAngle

Angle measured in degrees clockwise from the x-axis to the first side of the pie shape.

sweepAngle

Angle measured in degrees clockwise from the startAngle parameter to the second side of the pie shape.

Throws:

DrawPie(pen, rect, startAngle, sweepAngle)

Draws the outline of a pie shape. The pie shape is a section of an ellipse. The ellipse is specified by a Rectangle structure. Two radial lines indicate the start and end of the pie slice.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the pie shape.

rect

Rectangle structure that represents the bounding rectangle that defines the ellipse from which the pie shape comes.

startAngle

Angle measured in degrees clockwise from the x-axis to the first side of the pie shape.

sweepAngle

Angle measured in degrees clockwise from the startAngle parameter to the second side of the pie shape.

DrawPie(pen, x, y, width, height, startAngle, sweepAngle)

Draws the outline of a pie shape. The pie shape is a section of an ellipse. The ellipse is specified by a coordinate pair, a width, and a height. Two radial lines indicate the start and end of the pie slice.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the pie shape.

x

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes.

y

The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes.

width

Width of the bounding rectangle that defines the ellipse from which the pie shape comes.

height

Height of the bounding rectangle that defines the ellipse from which the pie shape comes.

startAngle

Angle measured in degrees clockwise from the x-axis to the first side of the pie shape.

sweepAngle

Angle measured in degrees clockwise from the startAngle parameter to the second side of the pie shape.

DrawPolygon(pen, points)

Draws the outline of a polygon defined by an array of points.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the polygon.

points

Array of PointF points that represent the coordinates of the corners of the polygon

DrawPolygon(pen, points)

Draws the outline of a polygon defined by an array of points.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the polygon.

points

Array of Point points that represent the coordinates of the corners of the polygon

DrawRectangle(pen, rect)

Draws the outline of a RectangleF rectangle specified by rect .

Parameter
Type
Description

pen

A Pen that determines the color, width, and style of the rectangle.

rect

A RectangleF structure that represents the rectangle to draw.

DrawRectangle(pen, rect)

Draws the outline of a Rectangle rectangle specified by rect .

Parameter
Type
Description

pen

A Pen that determines the color, width, and style of the rectangle.

rect

A Rectangle structure that represents the rectangle to draw.

DrawRectangle(pen, x, y, width, height)

Draws a rectangle specified by a coordinate pair, a width, and a height.

Parameter
Type
Description

pen

A Pen that determines the color, width, and style of the rectangle.

x

The x-coordinate of the upper-left corner of the rectangle to draw.

y

The y-coordinate of the upper-left corner of the rectangle to draw.

width

The width of the rectangle to draw.

height

The height of the rectangle to draw.

DrawRectangle(pen, x, y, width, height)

Draws a rectangle specified by a coordinate pair, a width, and a height.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the rectangle.

x

The x-coordinate of the upper-left corner of the rectangle to draw.

y

The y-coordinate of the upper-left corner of the rectangle to draw.

width

Width of the rectangle to draw.

height

Height of the rectangle to draw.

DrawRectangles(pen, rects)

Draws a series of rectangles specified by RectangleF structures.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the rectangles.

rects

Array of RectangleF structures that represent the rectangles to draw.

DrawRectangles(pen, rects)

Draws a series of rectangles specified by Rectangle structures.

Parameter
Type
Description

pen

Pen that determines the color, width, and style of the rectangles.

rects

Array of Rectangle structures that represent the rectangles to draw.

DrawString(s, font, brush, x, y)

Draws the specified text string at the specified x and y coordinates with the specified Brush and Font objects.

Parameter
Type
Description

s

String to draw.

font

Font that defines the text format of the string.

brush

Brush that determines the color and texture of the drawn text.

x

The x-coordinate of the upper-left corner of the drawn text.

y

The y-coordinate of the upper-left corner of the drawn text.

DrawString(s, font, brush, point)

Draws the specified text string at the specified location with the specified Brush and Font objects.

Parameter
Type
Description

s

String to draw.

font

Font that defines the text format of the string.

brush

Brush that determines the color and texture of the drawn text.

point

PointF structure that specifies the upper-left corner of the drawn text.

DrawString(s, font, brush, x, y, format)

Draws the specified text string at the specified location with the specified Brush and Font objects using the formatting attributes of the specified StringFormat.

Parameter
Type
Description

s

String to draw.

font

Font that defines the text format of the string.

brush

Brush that determines the color and texture of the drawn text.

x

The x-coordinate of the upper-left corner of the drawn text.

y

The y-coordinate of the upper-left corner of the drawn text.

format

StringFormat that specifies formatting attributes, such as line spacing and alignment, that are applied to the drawn text.

DrawString(s, font, brush, point, format)

Draws the specified text string at the specified location with the specified Brush and Font objects using the formatting attributes of the specified StringFormat.

Parameter
Type
Description

s

String to draw.

font

Font that defines the text format of the string.

brush

Brush that determines the color and texture of the drawn text.

point

PointF structure that specifies the upper-left corner of the drawn text.

format

StringFormat that specifies formatting attributes, such as line spacing and alignment, that are applied to the drawn text.

DrawString(s, font, brush, layoutRectangle)

Draws the specified text string in the specified rectangle with the specified Brush and Font objects.

Parameter
Type
Description

s

String to draw.

font

Font that defines the text format of the string.

brush

Brush that determines the color and texture of the drawn text.

layoutRectangle

RectangleF structure that specifies the location of the drawn text.

DrawString(s, font, brush, layoutRectangle, format)

Draws the specified text string in the specified rectangle with the specified Brush and Font objects using the formatting attributes of the specified StringFormat.

Parameter
Type
Description

s

String to draw.

font

Font that defines the text format of the string.

brush

Brush that determines the color and texture of the drawn text.

layoutRectangle

RectangleF structure that specifies the location of the drawn text.

format

StringFormat that specifies formatting attributes, such as line spacing and alignment, that are applied to the drawn text.

EndContainer(container)

Closes the current graphics container and restores the state of this Graphics to the state saved by a call to the BeginContainer method.

Parameter
Type
Description

container

GraphicsContainer that represents the container this method restores.

FillClosedCurve(brush, points)

Fills the interior of a closed curve defined by an array of points.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

points

Array of PointF structures that define the spline.

FillClosedCurve(brush, points, tension)

Fills the interior of a closed curve defined by an array of points.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

points

Array of PointF structures that define the spline.

tension

Value greater than or equal to 0.0F that specifies the tension of the curve.

FillClosedCurve(brush, points, fillMode)

Fills the interior of a closed curve defined by an array of points.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

points

Array of PointF structures that define the spline.

fillMode

Member of the FillMode enumeration that determines how the curve is filled.

FillClosedCurve(brush, points, fillMode, tension)

Fills the interior of a closed curve defined by an array of points.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

points

Array of PointF structures that define the spline.

fillMode

Member of the FillMode enumeration that determines how the curve is filled.

tension

Value greater than or equal to 0.0F that specifies the tension of the curve.

FillClosedCurve(brush, points)

Fills the interior of a closed curve defined by an array of points.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

points

Array of Point structures that define the spline.

FillClosedCurve(brush, points, tension)

Fills the interior of a closed curve defined by an array of points.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

points

Array of Point structures that define the spline.

tension

Value greater than or equal to 0.0F that specifies the tension of the curve.

FillClosedCurve(brush, points, fillMode)

Fills the interior of a closed curve defined by an array of points.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

points

Array of Point structures that define the spline.

fillMode

Member of the FillMode enumeration that determines how the curve is filled.

FillClosedCurve(brush, points, fillMode, tension)

Fills the interior of a closed curve defined by an array of points.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

points

Array of Point structures that define the spline.

fillMode

Member of the FillMode enumeration that determines how the curve is filled.

tension

Value greater than or equal to 0.0F that specifies the tension of the curve.

FillEllipse(brush, rect)

Fills the interior of an ellipse defined by a bounding rectangle specified by a Rectangle structure.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

rect

Rectangle structure that represents the bounding rectangle that defines the ellipse.

FillEllipse(brush, rect)

Fills the interior of an ellipse defined by a bounding rectangle specified by a RectangleF structure.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

rect

RectangleF structure that represents the bounding rectangle that defines the ellipse.

FillEllipse(brush, x, y, width, height)

Fills the interior of an ellipse defined by a bounding rectangle specified by a pair of coordinates, a width, and a height.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

x

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

y

The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

width

Width of the bounding rectangle that defines the ellipse.

height

Height of the bounding rectangle that defines the ellipse.

FillEllipse(brush, x, y, width, height)

Fills the interior of an ellipse defined by a bounding rectangle specified by a pair of coordinates, a width, and a height.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

x

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

y

The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

width

Width of the bounding rectangle that defines the ellipse.

height

Height of the bounding rectangle that defines the ellipse.

FillPath(brush, path)

Fills the interior of a GraphicsPath.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

path

GraphicsPath that represents the path to fill.

Throws:

FillPie(brush, rect, startAngle, sweepAngle)

Fills the interior of a pie section defined by an ellipse specified by a Rectangle structure and two radial lines.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

rect

Rectangle structure that represents the bounding rectangle that defines the ellipse from which the pie section comes.

startAngle

Angle in degrees measured clockwise from the x-axis to the first side of the pie section.

sweepAngle

Angle in degrees measured clockwise from the startAngle parameter to the second side of the pie section.

FillPie(brush, rect, startAngle, sweepAngle)

Fills the interior of a pie section defined by an ellipse specified by a RectangleF structure and two radial lines.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

rect

RectangleF structure that represents the bounding rectangle that defines the ellipse from which the pie section comes.

startAngle

Angle in degrees measured clockwise from the x-axis to the first side of the pie section.

sweepAngle

Angle in degrees measured clockwise from the startAngle parameter to the second side of the pie section.

FillPie(brush, x, y, width, height, startAngle, sweepAngle)

Fills the interior of a pie section defined by an ellipse specified by a pair of coordinates, a width, a height, and two radial lines.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

x

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie section comes.

y

The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie section comes.

width

Width of the bounding rectangle that defines the ellipse from which the pie section comes.

height

Height of the bounding rectangle that defines the ellipse from which the pie section comes.

startAngle

Angle in degrees measured clockwise from the x-axis to the first side of the pie section.

sweepAngle

Angle in degrees measured clockwise from the startAngle parameter to the second side of the pie section.

FillPie(brush, x, y, width, height, startAngle, sweepAngle)

Fills the interior of a pie section defined by an ellipse specified by a pair of coordinates, a width, a height, and two radial lines.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

x

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie section comes.

y

The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie section comes.

width

Width of the bounding rectangle that defines the ellipse from which the pie section comes.

height

Height of the bounding rectangle that defines the ellipse from which the pie section comes.

startAngle

Angle in degrees measured clockwise from the x-axis to the first side of the pie section.

sweepAngle

Angle in degrees measured clockwise from the startAngle parameter to the second side of the pie section.

FillPolygon(brush, points)

Fills the interior of a polygon defined by an array of points.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

points

Array of PointF points that represent the coordinates of the corners of the polygon

FillPolygon(brush, points)

Fills the interior of a polygon defined by an array of points.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

points

Array of PointF points that represent the coordinates of the corners of the polygon

FillRectangle(brush, rect)

Fills the interior of a rectangle specified by a RectangleF structure with a Brush.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

rect

Rectangle structure that represents the rectangle to fill.

FillRectangle(brush, rect)

Fills the interior of a rectangle specified by a Rectangle structure with a Brush,

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

rect

Rectangle structure that represents the rectangle to fill.

FillRectangle(brush, x, y, width, height)

Fills the interior of a rectangle specified by a pair of coordinates, a width, and a height with a Brush

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

x

The x-coordinate of the upper-left corner of the rectangle to fill.

y

The y-coordinate of the upper-left corner of the rectangle to fill.

width

Width of the rectangle to fill.

height

Height of the rectangle to fill.

FillRectangle(brush, x, y, width, height)

Fills the interior of a rectangle specified by a pair of coordinates, a width, and a height with a Brush

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

x

The x-coordinate of the upper-left corner of the rectangle to fill.

y

The y-coordinate of the upper-left corner of the rectangle to fill.

width

Width of the rectangle to fill.

height

Height of the rectangle to fill.

Throws:

FillRectangles(brush, rects)

Fills the interiors of a series of rectangles with a Brush.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

rects

An array of RectangleF rectangles to be filled.

FillRectangles(brush, rects)

Fills the interiors of a series of rectangles with a Brush.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

rects

An array of Rectangle rectangles to be filled.

FillRegion(brush, region)

Fills the interior of a Region.

Parameter
Type
Description

brush

Brush that determines the characteristics of the fill.

region

Region that represents the area to fill.

Throws:

Finalize()

Finalizes an instance of the Graphics class.

FromImage(image)

Creates an instance of the Graphics class from an existing Image.

Parameter
Type
Description

image

Image from which to create the new Graphics.

Returns: Graphics. This method returns a new Graphics for the specified Image.

MeasureString(text, font, width, format)

Measures the specified string when drawn with the specified Font and formatted with the specified StringFormat.

Parameter
Type
Description

text

String to measure.

font

Font that defines the text format of the string.

width

Maximum width of the string.

format

StringFormat that represents formatting information, such as line spacing, for the string.

Returns: SizeF. This method returns a SizeF structure that represents the size, in the units specified by the PageUnit property, of the string specified in the text parameter as drawn with the font parameter and the format parameter.

Throws:

MeasureString(text, font, layoutArea)

Measures the specified string when drawn with the specified Font within the specified layout area.

Parameter
Type
Description

text

String to measure.

font

Font defines the text format of the string.

layoutArea

SizeF structure that specifies the maximum layout area for the text.

Returns: SizeF. This method returns a SizeF structure that represents the size, in the units specified by the PageUnit property, of the string specified by the text parameter as drawn with the font parameter.

MeasureString(text, font, layoutArea, stringFormat)

Measures the specified string when drawn with the specified Font and formatted with the specified StringFormat.

Parameter
Type
Description

text

String to measure.

font

Font defines the text format of the string.

layoutArea

SizeF structure that specifies the maximum layout area for the text.

stringFormat

StringFormat that represents formatting information, such as line spacing, for the string.

Returns: SizeF. This method returns a SizeF structure that represents the size, in the units specified by the PageUnit property, of the string specified in the text parameter as drawn with the font parameter and the stringFormat parameter.

Throws:

MeasureString(text, font, origin, stringFormat)

Measures the specified string when drawn with the specified Font and formatted with the specified StringFormat.

Parameter
Type
Description

text

String to measure.

font

Font defines the text format of the string.

origin

PointF structure that represents the upper-left corner of the string.

stringFormat

StringFormat that represents formatting information, such as line spacing, for the string.

Returns: SizeF. This method returns a SizeF structure that represents the size, in the units specified by the PageUnit property, of the string specified in the text parameter as drawn with the font parameter and the stringFormat parameter.

Throws:

MeasureString(text, font, width)

Measures the specified string when drawn with the specified Font.

Parameter
Type
Description

text

String to measure.

font

Font that defines the format of the string.

width

Maximum width of the string in pixels.

Returns: SizeF. This method returns a SizeF structure that represents the size, in the units specified by the PageUnit property, of the string specified in the text parameter as drawn with the font parameter.

Throws:

MeasureString(text, font)

Measures the specified string when drawn with the specified Font.

Parameter
Type
Description

text

String to measure.

font

Font that defines the format of the string.

Returns: SizeF. This method returns a SizeF structure that represents the size, in the units specified by the PageUnit property, of the string specified in the text parameter as drawn with the font parameter.

Throws:

MeasureString(text, font, layoutArea, stringFormat, charactersFitted, linesFilled)

Measures the specified string when drawn with the specified Font and formatted with the specified StringFormat.

Parameter
Type
Description

text

String to measure.

font

Font defines the text format of the string.

layoutArea

SizeF structure that specifies the maximum layout area for the text.

stringFormat

StringFormat that represents formatting information, such as line spacing, for the string.

charactersFitted

Number of characters in the string.

linesFilled

Number of text lines in the string.

Returns: SizeF. This method returns a SizeF structure that represents the size of the string, in the units specified by the PageUnit property, of the text parameter as drawn with the font parameter and the stringFormat parameter.

RotateTransform(angle)

Applies the specified rotation to the transformation matrix of this Graphics.

Parameter
Type
Description

angle

Angle of rotation in degrees.

RotateTransform(angle, order)

Applies the specified rotation to the transformation matrix of this Graphics in the specified order.

Parameter
Type
Description

angle

Angle of rotation in degrees.

order

Member of the MatrixOrder enumeration that specifies whether the rotation is prepended or appended to the transformation matrix.

ScaleTransform(sx, sy)

Applies the specified scaling operation to the transformation matrix of this Graphics by prepending it to the object's transformation matrix.

Parameter
Type
Description

sx

Scale factor in the x direction.

sy

Scale factor in the y direction.

ScaleTransform(sx, sy, order)

Applies the specified scaling operation to the transformation matrix of this Graphics by prepending it to the object's transformation matrix.

Parameter
Type
Description

sx

Scale factor in the x direction.

sy

Scale factor in the y direction.

order

Member of the MatrixOrder enumeration that specifies whether the scaling operation is prepended or appended to the transformation matrix.

SetClip(rect)

Sets the clipping region of this Graphics to the rectangle specified by a RectangleF structure.

Parameter
Type
Description

rect

RectangleF structure that represents the new clip region.

SetClip(rect)

Sets the clipping region of this Graphics to the rectangle specified by a Rectangle structure.

Parameter
Type
Description

rect

Rectangle structure that represents the new clip region.

SetClip(graphicsPath)

Sets the clipping region of this Graphics to the specified GraphicsPath.

Parameter
Type
Description

graphicsPath

GraphicsPath that represents the new clip region.

SetClip(g)

Sets the clipping region of this Graphics to the Clip property of the specified Graphics.

Parameter
Type
Description

g

Graphics from which to take the new clip region.

SetClip(rect, combineMode)

Sets the clipping region of this Graphics to the result of the specified operation combining the current clip region and the rectangle specified by a RectangleF structure.

Parameter
Type
Description

rect

RectangleF structure to combine.

combineMode

Member from the CombineMode enumeration that specifies the combining operation to use.

SetClip(rect, combineMode)

Sets the clipping region of this Graphics to the result of the specified operation combining the current clip region and the rectangle specified by a Rectangle structure.

Parameter
Type
Description

rect

Rectangle structure to combine.

combineMode

Member from the CombineMode enumeration that specifies the combining operation to use.

SetClip(graphicsPath, combineMode)

Sets the clipping region of this Graphics to the result of the specified combining operation of the current clip region and the Clip property of the specified GraphicsPath.

Parameter
Type
Description

graphicsPath

GraphicsPath to combine.

combineMode

Member from the CombineMode enumeration that specifies the combining operation to use.

SetClip(g, combineMode)

Sets the clipping region of this Graphics to the result of the specified combining operation of the current clip region and the Clip property of the specified Graphics.

Parameter
Type
Description

g

Graphics that specifies the clip region to combine.

combineMode

Member from the CombineMode enumeration that specifies the combining operation to use.

SetClip(region, combineMode)

Sets the clipping region of this Graphics to the result of the specified operation combining the current clip region and the specified Region.

Parameter
Type
Description

region

Region to combine.

combineMode

Member from the CombineMode enumeration that specifies the combining operation to use.

TranslateTransform(dx, dy)

Changes the origin of the coordinate system by prepending the specified translation to the transformation matrix of this Graphics.

Parameter
Type
Description

dx

The x-coordinate of the translation.

dy

The y-coordinate of the translation.

TranslateTransform(dx, dy, order)

Changes the origin of the coordinate system by prepending the specified translation to the transformation matrix of this Graphics.

Parameter
Type
Description

dx

The x-coordinate of the translation.

dy

The y-coordinate of the translation.

order

Member of the MatrixOrder enumeration that specifies whether the translation is prepended or appended to the transformation matrix.

Last updated

Was this helpful?