in dotnet/WPF/ScreenCapture/CaptureSampleCore/BasicCapture.cs [46:82]
public BasicCapture(IDirect3DDevice d, GraphicsCaptureItem i)
{
item = i;
device = d;
d3dDevice = Direct3D11Helper.CreateSharpDXDevice(device);
var dxgiFactory = new SharpDX.DXGI.Factory2();
var description = new SharpDX.DXGI.SwapChainDescription1()
{
Width = item.Size.Width,
Height = item.Size.Height,
Format = SharpDX.DXGI.Format.B8G8R8A8_UNorm,
Stereo = false,
SampleDescription = new SharpDX.DXGI.SampleDescription()
{
Count = 1,
Quality = 0
},
Usage = SharpDX.DXGI.Usage.RenderTargetOutput,
BufferCount = 2,
Scaling = SharpDX.DXGI.Scaling.Stretch,
SwapEffect = SharpDX.DXGI.SwapEffect.FlipSequential,
AlphaMode = SharpDX.DXGI.AlphaMode.Premultiplied,
Flags = SharpDX.DXGI.SwapChainFlags.None
};
swapChain = new SharpDX.DXGI.SwapChain1(dxgiFactory, d3dDevice, ref description);
framePool = Direct3D11CaptureFramePool.Create(
device,
DirectXPixelFormat.B8G8R8A8UIntNormalized,
2,
i.Size);
session = framePool.CreateCaptureSession(i);
lastSize = i.Size;
framePool.FrameArrived += OnFrameArrived;
}