//屏幕宽
int iWidth = Screen.PrimaryScreen.Bounds.Width;
//屏幕高
int iHeight = Screen.PrimaryScreen.Bounds.Height;
//按照屏幕宽高创建位图
Image img = new Bitmap(iWidth, iHeight);
//从一个继承自Image类的对象中创建Graphics对象
Graphics gc = Graphics.FromImage(img);
//抓屏并拷贝到myimage里
gc.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(iWidth, iHeight));
//this.BackgroundImage = img;
//保存位图
img.Save(@"C:\" + Guid.NewGuid().ToString() + ".jpg");
时间: 2024-12-28 10:54:37