C#中截取屏幕圖像的方法,有時有些程序需要監控用戶的屏幕或者是對屏幕進行截圖,這個C#函數就是實現這個功能。它可以截取全屏幕的圖像。具體源代碼如下:
/// <summary>
/// 截取全屏幕圖像
/// </summary>
/// <returns>屏幕位圖</returns>
public Bitmap GetFullScreen()
{
Bitmap mimage = new Bitmap(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);
Graphics gp = Graphics.FromImage(mimage);
gp.CopyFromScreen(new Point(System.Windows.Forms.Screen.PrimaryScreen.Bounds.X, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Y), new Point(0, 0), mimage.Size, CopyPixelOperation.SourceCopy);
return mimage;
}
新聞熱點
疑難解答