public IEditableFrame Capture() { try { if (!_duplCapture.Get(_desktopImageTexture, _mousePointer)) { return(RepeatFrame.Instance); } } catch { try { _duplCapture.Init(); } catch { // ignored } return(RepeatFrame.Instance); } var editor = new Direct2DEditor(_editorSession); _mousePointer?.Draw(editor); return(editor); }
public IBitmapFrame Capture() { OutputDuplicateFrameInformation?frameInfo; try { frameInfo = _duplCapture.Get(_desktopImageTexture, Timeout); } catch { try { _duplCapture.Init(); } catch { // ignored } return(RepeatFrame.Instance); } if (frameInfo is null) { return(RepeatFrame.Instance); } var mapSource = _device.ImmediateContext.MapSubresource(_desktopImageTexture, 0, MapMode.Read, MapFlags.None); try { var bmp = ProcessFrame(mapSource.DataPointer, mapSource.RowPitch, frameInfo.Value); return(new OneTimeFrame(bmp)); } finally { _device.ImmediateContext.UnmapSubresource(_desktopImageTexture, 0); } }