C# Bitmap

Bitmap class is an implementation of the Image class which is abstract. Bitmap contains 12 different constructors.

using System.Drawing;
Bitmap(width,height);
Bitmap(width,height,Graphics);
Bitmap(width,height,PixelFormat);
Bitmap(Image);
Bitmap(Image,Size);
Bitmap(Stream);
Bitmap(Stream,Boolean);
Bitmap(String);
Bitmap(Type,String);
Bitmap(Image,width,height);
Bitmap(width,height,stride,PixelFormat,IntPtr);

Example code to draw an image.
using System.Drawing;
Font ft = new Font("Courier New", 8);
Brush brush = new SolidBrush(System.Drawing.Color.Black);
int width = 800;
int height = 400;
Bitmap bm = new Bitmap(width, height);
Graphics grfx = Graphics.FromImage(bm);
grfx.FillRectangle(new SolidBrush(Color.White), 0, 0, width, height);
grfx.DrawLine(new Pen(Color.Black), new Point(100, 100), new Point(100, 300));
grfx.DrawLine(new Pen(Color.Black), new Point(100, 300), new Point(600, 300));
Point[] pts = new Point[3];
pts[0] = new Point(100, 100);
pts[1] = new Point(97, 106);
pts[2] = new Point(103, 106);
grfx.DrawPolygon(new Pen(Color.Black), pts);
grfx.DrawLine(new Pen(Color.Black), new Point(100, 100), new Point(98, 106));
grfx.DrawLine(new Pen(Color.Black), new Point(100, 100), new Point(99, 106));
grfx.DrawLine(new Pen(Color.Black), new Point(100, 100), new Point(100, 106));
grfx.DrawLine(new Pen(Color.Black), new Point(100, 100), new Point(101, 106));
grfx.DrawLine(new Pen(Color.Black), new Point(100, 100), new Point(102, 106));
pts = new Point[3];
pts[0] = new Point(600, 300);
pts[1] = new Point(594, 297);
pts[2] = new Point(594, 303);
grfx.DrawPolygon(new Pen(Color.Black), pts);
grfx.DrawLine(new Pen(Color.Black), new Point(600, 300), new Point(594, 298));
grfx.DrawLine(new Pen(Color.Black), new Point(600, 300), new Point(594, 299));
grfx.DrawLine(new Pen(Color.Black), new Point(600, 300), new Point(594, 300));
grfx.DrawLine(new Pen(Color.Black), new Point(600, 300), new Point(594, 301));
grfx.DrawLine(new Pen(Color.Black), new Point(600, 300), new Point(594, 302));
grfx.Dispose();
bm.Save("test.png");


The image generated by above code is: