2009-10-08 47 views

回答

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

或者:

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

'新的位圖(..,我的圖形)'不會**將圖形的像素複製到位圖中,也不允許訪問「myGraphics」的內容。第二種解決方案是針對不同問題的解決方案(與問題相反):如何使用'Graphics'方法繪製位圖。 – ToolmakerSteve 2017-09-22 19:25:37

9

你的意思是System.Drawing.Graphics? Graphics類是圖像的表面,並且已經是位圖。

你想用它做什麼?

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

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

該文檔只是說*圖形對象,指定新的位圖的分辨率。*;聽起來不像'Graphics'對象被複制的任何東西。 – 2013-04-10 13:09:05

+6

不起作用。結果是黑色矩形。 – 2014-04-09 08:07:14

0

這看起來像你可能會想:DaniWeb,是annoyingware但它確實提供了一個可行的解決方案