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;
}
新闻热点
疑难解答