当前位置:K88软件开发文章中心编程语言.NET.NET01 → 文章内容

C#中截取全屏幕图像的方法

减小字体 增大字体 作者:佚名  来源:翔宇亭IT乐园  发布时间:2018-12-31 11:27:28

: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#中截取全屏幕图像的方法