runliuv

runliuv@cnblogs

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

 

 

internal Image ScreenCapture()
        {
            try
            {
                int iWidth = Screen.PrimaryScreen.Bounds.Width;//屏幕宽
                int iHeight = Screen.PrimaryScreen.Bounds.Height;//屏幕高
                Image img = new Bitmap(iWidth, iHeight);//按照屏幕宽高创建位图
                using (Graphics gc = Graphics.FromImage(img)) //从一个继承自Image类的对象中创建Graphics对象
                {
                    gc.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(iWidth, iHeight));//抓屏并拷贝到myimage里
                }

                return img;
            }
            catch
            {
                return null;
            }
        }

 

posted on 2020-06-09 11:04  runliuv  阅读(195)  评论(0编辑  收藏  举报