利用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);

你可能感兴趣的:(利用Graphics的截图功能CopyFromScreen)