public DuplCapture(Output1 Output) { // Separate Device required otherwise AccessViolationException happens using (var adapter = Output.GetParent <Adapter>()) _device = new Device(adapter); _output = Output; Init(); }
public DesktopDuplicator(bool includeCursor, Output1 output) { _device = new Device(DriverType.Hardware, DeviceCreationFlags.BgraSupport, FeatureLevel.Level_11_1); // Separate Device required otherwise AccessViolationException happens using (var adapter = output.GetParent <Adapter>()) _deviceForDesktopDuplication = new Device(adapter); _desktopDuplicationCapture = new DesktopDuplicationCapture(_deviceForDesktopDuplication, output); var bounds = output.Description.DesktopBounds; var width = bounds.Right - bounds.Left; var height = bounds.Bottom - bounds.Top; _stagingTexture = new Texture2D(_device, new Texture2DDescription { CpuAccessFlags = CpuAccessFlags.Read, BindFlags = BindFlags.None, Format = Format.B8G8R8A8_UNorm, Width = width, Height = height, OptionFlags = ResourceOptionFlags.None, MipLevels = 1, ArraySize = 1, SampleDescription = { Count = 1, Quality = 0 }, Usage = ResourceUsage.Staging }); _desktopImageTexture = new Texture2D(_device, new Texture2DDescription { CpuAccessFlags = CpuAccessFlags.None, BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, Format = Format.B8G8R8A8_UNorm, Width = width, Height = height, OptionFlags = ResourceOptionFlags.None, MipLevels = 1, ArraySize = 1, SampleDescription = { Count = 1, Quality = 0 }, Usage = ResourceUsage.Default }); _editorSession = new Direct2DEditorSession(_desktopImageTexture, _device, _stagingTexture); if (includeCursor) { _mousePointer = new DxMousePointer(_editorSession); } }
public DuplCapture(Output1 Output) { // Separate Device required otherwise AccessViolationException happens using (var adapter = Output.GetParent <Adapter>()) _device = new Device(adapter); _output = Output; var bound = Output.Description.DesktopBounds; _width = bound.Right - bound.Left; _height = bound.Bottom - bound.Top; Init(); }