This article has been excerpted from book "Graphics Programming with GDI+ ".Graphics objects are the heart of GDI+. They are represented by the Graphics class, which defines methods and properties to draw and fill graphics objects. Whenever an application needs to draw or paint something, it has to use the Graphics object. Hence, understanding the Graphics class, its methods, and its properties is very important. Specifically, in this article we will discuss the methods and properties of the Graphics class, and how to use them in real-world applications, including line charts, pie charts, and our GDI+Painter application. GDI+Painter is similar to the PaintBrush application, which allows you to draw simple graphics object such as lines, rectangles, and circles and save the images as bitmaps.Graphics Class PropertiesThe Graphics class provides a long list of properties (see Table 3.1) and methods.TABLE 3.1: Graphics properties
Clip
Gets and sets a Region type that limits the drawing region of the Graphics object.
ClipBounds
Returns a RectangeF structure that bounds the clipping region of this Graphics object. Supports read only access.
CompositingMode
Returns a value of type CompositingMode enumeration representing how composite images are drawn to the Graphics object.
CompositingQuality
Gets and sets the rendering quality (directly proportional to the visual quality of the output and inversely proportional to the rendering time) of composite images, represented by the CompositingQuality enumeration.
DpiX
Returns the horizontal resolution (dots per inch) of a Graphics object.
DpiY
Returns the vertical resolution (dots per inch) of a Graphics object.
InterpolationMode
Gets and sets the interpolation mode (which determines intermediate values between two endpoints), represented by the InterpolationMode enumerator.
IsClipEmpty
Returns a value indicating whether the clipping region of a Graphics object is empty. When there is no clipping this property return false.
IsVisibleClipEmpty
Returns a value indicating whether the visible clipping region of a Graphics object is empty.
PageScale
Gets and sets a value for scaling between world units and page units for this Graphics object.
PageUnit
Gets and sets a value that represents the unit of measure for page coordinates.
PixelOffsetMode
Gets and sets a value for the pixel offset mode (PixelOffsetMode enumeration).
RenderingOrigin
Represents the rendering origin of a Graphics object for dithering and hatch brushes.
SmoothingMode
Gets and sets the smoothing mode of a Graphics object (SmoothingMode enumeration). Does not affect text. Smoothing modes include high quality, high speed, and anti-aliasing.
TextContrast
Gets and sets the gamma correction value for rendering anti-aliased and ClearType text values, ranging from 0 to 12. The default is 4.
TextRenderingHint
Gets and sets the text rendering quality (TextRenderingHint enumeration). Affects only text drawn on the Graphics object.
Transform
Gets and sets the world transformation matrix (transformation is the process of converting graphics objects from one state to another). The transformation state is represented by a transformation matrix.
VisibleClipBounds
Gets and sets the visible clipping region of the Graphics object (the intersection of the clipping region of the Graphics object and the clipping region of the window).
DrawArc
Draws an arc (a portions of an ellipse specified by a pair of coordinates, a width, a height, and start and end angles).
DrawBezier
Draws a Bezier curve defined by four Point structures.
DrawBeziers
Draws a series of Bezier splines from an array of Point structures.
DrawClosedCurve
Draws a closed cardinal spline defined by an array of Point structures.
DrawCurve
Draws a cardinal spline through a specified array of Point structures.
DrawEllipse
Draws an ellipse defined by a bounding rectangle specified by a pair of coordinates, a height, and a width.
DrawIconUnstretched
Draws an image represented by the specified Icon object without scaling the image.
DrawImage
Draws the specified Image object at the specified location and with the original size.
DrawImageUnscaled
Draws the specified Image object with its original size at the location specified by a coordinate pair.
DrawLine
Draws a line connecting two points specified by coordinate pairs.
DrawLines
Draws a series of line segments that connect an array of Point structures.
DrawPath
Draws a GraphicsPath object.
DrawPie
Draws a pie shape specified by a coordinate pair, a width, a height, and two radial lines.
DrawPolygon
Draws a polygon defined by an array of Point structures.
DrawRectangle
Draws a rectangle specified by a coordinate pair, a width, and a height.
DrawRectangles
Draws a series of rectangles specified by an array of Rectangle structures.
DrawString
Draws the specified text string at the specified location using the specified Brush and Font objects.