Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert graphics object to bitmap object

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

like image 605
Binu Avatar asked Oct 08 '09 05:10

Binu


3 Answers

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

Alternatively:

Graphics myGraphics = Graphics.FromImage(myBitmap);
// some code with draw on myGraphics
myGraphics.Dispose();
like image 158
AndreyAkinshin Avatar answered Sep 20 '22 18:09

AndreyAkinshin


Do you mean System.Drawing.Graphics ? The Graphics class is a surface to an image and is already a bitmap.

What are you trying to do with it ?

using(Graphics g = Graphics.FromImage(bitmap))
{
  //draw here
}

or

Bitmap bmp = new Bitmap(100,100,graphics);
like image 34
Andrew Keith Avatar answered Sep 20 '22 18:09

Andrew Keith


This looks like what you might want: DaniWeb, yes annoyingware but it does provide a working solution

like image 1
monksy Avatar answered Sep 24 '22 18:09

monksy