使用C#/Winforms/GDI+;,如何获取控件的像素或图像?
我想在winforms对话框中“抓取”控件的图像。我可以使用以下方式访问控件的“图形”上下文:使用C#/Winforms/GDI+;,如何获取控件的像素或图像?,winforms,gdi+,Winforms,Gdi+,我想在winforms对话框中“抓取”控件的图像。我可以使用以下方式访问控件的“图形”上下文: MyControl.CreateGraphics() 但是,如何将矩形从图形上下文复制到图像或位图,或在其上调用getpixel 非常感谢。我认为MyControl.DrawToBitmap是一个不错的选择: Bitmap bmp = new Bitmap(MyControl.Width, MyControl.Height); MyControl.DrawToBitmap(bmp, MyContro
MyControl.CreateGraphics()
但是,如何将矩形从图形上下文复制到图像或位图,或在其上调用getpixel
非常感谢。我认为MyControl.DrawToBitmap是一个不错的选择:
Bitmap bmp = new Bitmap(MyControl.Width, MyControl.Height);
MyControl.DrawToBitmap(bmp, MyControl.ClientRectangle);
如果需要获取像素,请使用Bitmap.GetPixel或Bitmap.LockBits我认为MyControl.DrawToBitmap是一种方法:
Bitmap bmp = new Bitmap(MyControl.Width, MyControl.Height);
MyControl.DrawToBitmap(bmp, MyControl.ClientRectangle);
如果需要获取像素,请使用Bitmap.GetPixel或Bitmap.LockBits我在使用MyControl.DrawToBitmap时取得了一些骇人的成功,这是一个好方法吗?还是有更好的选择?我在使用MyControl.DrawToBitmap时取得了一些骇人的成功,这是一个好方法吗?还是有更好的选择?