简体   繁体   English

将图形对象转换为位图对象

[英]Convert graphics object to bitmap object

如何使用 C# 将图形对象转换为位图对象?

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

Alternatively:或者:

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

Do you mean System.Drawing.Graphics ?你的意思是System.Drawing.Graphics The Graphics class is a surface to an image and is already a bitmap. Graphics 类是图像的表面,并且已经是位图。

What are you trying to do with it ?你想用它做什么?

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

or要么

Bitmap bmp = new Bitmap(100,100,graphics);

这看起来像您可能想要的: DaniWeb ,是的,烦人的软件,但它确实提供了一个可行的解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM