//获取桌面图像 private static Bitmap GetScreen(bool bCaptureCursor, bool bFromClipBoard) { Bitmap bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); if (bCaptureCursor) //是否捕获鼠标 { CaptureForm.DrawCurToScreen(); } //做完以上操作 才开始捕获桌面图像 using (Graphics g = Graphics.FromImage(bmp)) { g.CopyFromScreen(0, 0, 0, 0, bmp.Size); if (!bFromClipBoard) { return(bmp); } using (Image img_clip = Clipboard.GetImage()) { if (img_clip != null) { using (SolidBrush sb = new SolidBrush(Color.FromArgb(150, 0, 0, 0))) { g.FillRectangle(sb, 0, 0, bmp.Width, bmp.Height); g.DrawImage(img_clip, (bmp.Width - img_clip.Width) >> 1, (bmp.Height - img_clip.Height) >> 1, img_clip.Width, img_clip.Height); } } } } return(bmp); }
private void FrmCapture_Load(object sender, EventArgs e) { this.InitMember(); imageProcessBox1.BaseImage = CaptureForm.GetScreen(this.isCaptureCursor, this.isFromClipBoard); m_MHook.SetMHook(); m_MHook.MHookEvent += new HookHelper.MHookEventHandler(m_MHook_MHookEvent); imageProcessBox1.IsDrawOperationDot = false; this.BeginInvoke(new MethodInvoker(() => this.Enabled = false)); timer1.Interval = 500; timer1.Enabled = true; }