我有一个面板并使用它的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");
即使我画了任何东西,但我只能得到一个白色矩形。问题出在哪里?