分享下源码
using System;
using System.Drawing;
using System.Windows.Forms;
namespace 截图
{
class Program
{
//线成问题
[STAThread]
static void Main(string[] args)
{
Bitmap img = new Bitmap(GetImgDesk());
SaveImage(img);
}
//类都应该写外面新建,为了方便凑一块了
public static Bitmap GetImgDesk()
{
Rectangle rect = new Rectangle();
rect = System.Windows.Forms.Screen.GetBounds(rect);
Size mySize = new Size(rect.Width, rect.Height);
//Rectangle rect = System.Windows.Forms.Screen.GetBounds();
获取屏幕分辨率
int x_ = rect.Width;
int y_ = rect.Height;
//截屏
Bitmap img = new Bitmap(x_, y_);
Graphics g = Graphics.FromImage(img);
g.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(x_, y_));
return img;