using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
//獲得當前屏幕的分辨率
Screen scr = Screen.PrimaryScreen;
Rectangle rc = scr.Bounds;
int iWidth = rc.Width;
int iHeight = rc.Height;
//創建一個和屏幕一樣大的Bitmap
Image myImage = new Bitmap(iWidth, iHeight);
//從一個繼承自Image類的對象中創建Graphics對象
Graphics g = Graphics.FromImage(myImage);
//抓屏並拷貝到myimage裡
g.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(iWidth, iHeight));
//保存為文件
myImage.Save(@"c:/1.jpeg");
}
}
}
作者“csharp”