Graphics Handling In C#

Graphics handling in Visual C#2005 is based on GDI+(GDI stands for Graphical Device Interface). A GDI+ allows you to display graphics on the screen or a printer without having to handle the details of a specific display device.
You make calls to methods supported by the GDI+ classes and those methods make the corresponding calls to individual device drivers as needed to handle the screen or printer. GDI+ support covers the following categories:
? 2D vector graphics

? Imaging

? Typography

2D Vector Graphics
Vector graphics are all about drawing basic shapes such as lines, curves, and other similar figures. In Visual C#2005, the drawing origin (0,0) is placed at the upper left corner of the drawing surface; the positive X-axis extends to the right and the positive Y-axis downwords, much like the way you had read text on a page (don’t forget that all the measurement are in pixels). Using that coordinate system , you can indicate to the vector graphics classes how you want your lines, ellipses, rectangles, and other figures to appear.
GDI+ also supports a Pen class that specifies just how you draw figures. In particular, you can customize pen s with which you can specify line color, line width, and line style. When you draw a figure – such as an ellipse – you must create and provide a Pen object that GDI+ will use to draw that ellipse.
In addition to the Pen class, GDI+ also supports a brush class that you can use to color the figures you have drawn. The brush class is actually an abstract class; instead of using it directly, you use one of the following classes derieved from it:
? HatchBrush

? LinearGradientBrush

? PathGradientBrush

? SolidBrush

? TextureBrush

Imagine trying to draw the kind of pictures you see in digital photographs or even icons with vector graphics – you could do it, but assembling such images from lines and curves would be just about impossible.
Instead, you store those kinds of images as bitmaps, which are simple arrays of points(although they may be compressed when stored on disk) corresponding to pixels on the screen. In other words, bitmaps stores the actual pixel settings needed to display the corresponding image.
Handling and working with such bitmaps is actually more complex than simply working with vector graphics, so GDI+ supports the Bitmap class, with all kinds of built-in methods to display and handle the images.
Typography is all about displaying text. GDI+ has a lot of support for typography, allowing you to display text I different forns, sizes, styles (such as italic and bold), and colors.
The typography supported by GDI+ also supports a technique called antialiasing, which makes text appear smoother on the screen, avoiding the jagged edges of text that used to be typical in the early days of personal computing.
Scroll to Top