Visual Basic .NET/GDI+

Graphics object
A System.Drawing.Graphics object represents a drawing surface.

To get a Graphics object for a PictureBox control, use the .Graphics property of the PaintEventArgs parameter in the PictureBox's Paint event.

To load an image and then draw on it, use Graphics.FromImage

The .Save method can be used to save the Bitmap to a file or a Stream. Note: Bitmap objects created from a file keep the file open and are linked to the file while the object is in use. You will need to copy the file into a MemoryStream first if you do not want the Bitmap object to be linked to the file.

Drawing Methods
Use methods such as Graphics.DrawLine and Graphics.DrawString to draw lines and text

Measurement
Graphics.MeasureString can be used to measure how tall or wide a piece of text will be when output with .DrawString.

Simple scaling
Use the Graphics.PageUnit property as a simple way to change the coordinate system. More complicated transformations and scaling are described below.

World, Page and Device coordinate systems
When you supply coordinates to VB.NET graphics functions, these coordinates are part of the World Coordinate system. The units of the World coordinate system are defined by you, but the default is Pixels.

The World Transformation converts your World coordinates to Page coordinates. Page coordinates can use different units, but are device independent. The idea is that a distance expressed in Page coordinates will be the same if viewed on a monitor, or printed on a page.

The Page Transformation converts Page Coordinates to Device Coordinates. In other words, the Page Transformation ensures that the graphics output looks the same no matter what device the image is sent to. Device Coordinates are usually Pixels.

You can specify a translation matrix to convert the points you specify into the final output. This transformation can translate (offset), scale, rotate or skew the final output. This transformation is called an Affine Transformation.

Converting from Twips
Previous versions of Visual Basic used Twips as the unit of measure. 1,440 Twips = 1 inch. However, VB.NET uses Pixels as its unit of measure. To convert from Twips to Pixels requires a Graphics object (since you don't know the number of dots-per-inch). Therefore, if  is the measurement in Twips, then , the measurement in pixels, is calculated as follows (  is the appropriate   object): Use  to calculate coordinates for the Y axis.

Visual Basic .NET/GDI+