- ·上一篇文章:C#中默认参数的使用方法
- ·下一篇文章:C#中获取某个日期所对应的星期数
C#中截取全屏幕图像的方法
:2012-04-07 08:55:12
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;
}
C#中截取全屏幕图像的方法