public IBitmapFrame Capture() { Gdi32.BitBlt(_hdcDest, 0, 0, _region.Width, _region.Height, _hdcSrc, _region.X, _region.Y, (int)CopyPixelOperation.SourceCopy); var img = new OneTimeFrame(Image.FromHbitmap(_hBitmap)); if (_includeCursor) { using (var editor = img.GetEditor()) MouseCursor.Draw(editor.Graphics, _transform); } return(img); }
public IBitmapFrame Capture() { try { OnCapture(); var img = new OneTimeFrame(Image.FromHbitmap(_hBitmap)); if (_includeCursor) { using (var editor = img.GetEditor()) MouseCursor.Draw(editor.Graphics, _transform); } return(img); } catch (Exception e) when(!(e is WindowClosedException)) { return(RepeatFrame.Instance); } }