指定区域截图

 

 

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;
            }
        }

 

你可能感兴趣的:(指定区域截图)