c# 截屏并保存为图像的方法其极简单,主要用到Graphics类的FromImage()方法,而保存则用到Image类的Save方法,主要代码如下:
Screen scr = Screen.PrimaryScreen;
Rectangle rc = scr.Bounds;
int iWidth = rc.Width;
int iHeight = rc.Height;
Image image = new Bitmap(iWidth, iHeight);
Graphics graph = Graphics.FromImage(image);
graph.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(iWidth, iHeight));
image.Save(@"D:/2.jpeg");