利用Graphics的截图功能CopyFromScreen

不问归期 提交于 2020-02-26 12:48:02


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

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);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!