【发布时间】:2011-12-18 18:28:13
【问题描述】:
我有一个面板,我使用它的 Graphics gr = panel1.CreateGraphics() 来绘制线条和其他东西。我需要获取鼠标点击点的像素颜色,所以我决定使用 Bitmap 的 GetPixel 方法。我这样创建位图:
Bitmap b = new Bitmap(width, height);
panel1.DrawToBitmap(b, new Rectangle(0, 0, width, height));
b.Save("D:/aaa.bmp");
但即使我画了任何东西,我也只能得到白色矩形。有什么问题?
【问题讨论】:
-
最小化表单并恢复它,看看为什么不应该使用 CreateGraphics()。
标签: c# graphics bitmap system.graphics