Convert graphics object to bitmap object

后端 未结 3 1334
温柔的废话
温柔的废话 2020-12-31 03:53

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

相关标签:
3条回答
  • 2020-12-31 04:02

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

    0 讨论(0)
  • 2020-12-31 04:03
    Bitmap myBitmap = new Bitmap(width, height, myGraphics);
    

    Alternatively:

    Graphics myGraphics = Graphics.FromImage(myBitmap);
    // some code with draw on myGraphics
    myGraphics.Dispose();
    
    0 讨论(0)
  • 2020-12-31 04:05

    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);
    
    0 讨论(0)
提交回复
热议问题