Previous Section  < Day Day Up >  Next Section

8.4. Summary

GDI+ supports a wide range of graphics-related operations ranging from drawing to image manipulation. All require use of the Graphics object that encapsulates the drawing surface and provides methods for drawing geometric shapes and images to the abstract surface. The graphic is typically rendered to a form or control on the form to be displayed in a user interface.

The task of drawing is simplified by the availability of methods to create predefined geometric shapes such as lines, ellipses, and rectangles. These shapes are outlined using a Pen object that can take virtually any color or width, and can be drawn as a solid line or broken into a series of dashes, dots, and combinations of these. The shapes are filled with special brush objects such as SolidBrush, TextureBrush, LinearGradientBrush, and HatchBrush.

The Image and Bitmap classes are used in .NET to represent raster-based images. Most of the standard image formats桞MP, GIF, JPG, and PNG梐re supported. After an image is loaded or drawn, the Graphics.DrawImage method may be used to rotate, skew, mirror, resize, and crop images as it displays them to the Graphics object's surface.

When custom graphics are included in a form or control, it is necessary to respond to the Paint event, to redraw all or part of the graphics on demand. A program can force this event for a control by invoking the Control.Invalidate method.

    Previous Section  < Day Day Up >  Next Section