C# 截屏

 

 

  Rectangle rect = new Rectangle();//存储矩形大小位置
            rect = Screen.GetWorkingArea(this); //GetWorkingArea 获取屏幕工作区域,不包括工作栏任务栏
            Bitmap bit = new Bitmap(this.Width, this.Height);//实例化一个和窗体一样大的bitmap 
            Graphics g = Graphics.FromImage(bit);//创建绘图对象
            g.CompositingQuality = CompositingQuality.HighQuality;//质量设为最高
            g.CopyFromScreen(this.Left, this.Top, 0, 0, new Size(this.Width, this.Height));//保存整个窗体为图片 
            Image MyImage = bit;
            MyImage.Save(@"c:/Capture.jpg", ImageFormat.Jpeg);

 

 Rectangle rect = new Rectangle();//存储矩形大小位置
            rect = Screen.GetBounds(this);//GetBounds 获取屏幕整个区域 
            Bitmap bit = new Bitmap(rect.Width, rect.Height);//实例化一个和窗体一样大的bitmap
            Graphics g = Graphics.FromImage(bit);
            g.CompositingQuality = CompositingQuality.HighQuality;//质量设为最高 
            g.CopyFromScreen(0, 0, 0, 0, new Size(rect.Width, rect.Height));//保存整个窗体为图片 
            Image MyImage = bit;
            MyImage.Save(@"c:/Capture.jpg", ImageFormat.Jpeg);

 

posted @ 2018-01-11 10:58  蓝雨冰城  阅读(263)  评论(0编辑  收藏  举报