Convert graphics object to bitmap object

bitmap, c#, graphics

Solution

Bitmap myBitmap = new Bitmap(width, height, myGraphics);

Alternatively:

Graphics myGraphics = Graphics.FromImage(myBitmap);
// some code with draw on myGraphics
myGraphics.Dispose();

Problem

How can I convert graphics object to bitmap object using C#?

Original source

Related problems