利用Graphics的截图功能CopyFromScreen


该方式是直接对屏幕进行截图操作

UserControl chartContainPanel = new UserControl();
Graphics graph = chartContainPanel.CreateGraphics();
Size s = chartContainPanel.Size;
Bitmap memoryImage = new Bitmap(s.Width, s.Height, graph);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
Point screen = chartContainPanel.PointToScreen(this.Location);
// 拷贝屏幕对应区域为 memoryGraphics 的 BitMap  
memoryGraphics.CopyFromScreen(screen.X, screen.Y, 0, 0, s);
memoryImage.Save(fileName);
posted @ 2020-02-26 11:52  snsnet  阅读(1458)  评论(0编辑  收藏  举报