1. 程式人生 > >C# 截屏

C# 截屏

posit rap left size 任務 截屏 copy pre this

  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);

C# 截屏