To capture multiple items at the same time, your application must create a capture session for each item to be captured, which requires invoking the picker UI for each item that is to be captured. This way your application can choose to capture the same item for various experiences. Once the user has explicitly given consent to capturing an application window or display in the system UI, the GraphicsCaptureItem can be associated to multiple CaptureSession objects. _session = FramePool.CreateCaptureSession(CaptureItem) Next, get an instance of the GraphicsCaptureSession class for your Direct3D11CaptureFramePool by passing the GraphicsCaptureItem to the CreateCaptureSession method: _session = _framePool.CreateCaptureSession(_item)
Private Sub StartCaptureInternal(item As GraphicsCaptureItem)įramePool = Direct3D11CaptureFramePool.Create(ĭirectXPixelFormat.B8G8R8A8UIntNormalized, ' Pixel format Private _session As GraphicsCaptureSession WithEvents FramePool As Direct3D11CaptureFramePool WithEvents CaptureItem As GraphicsCaptureItem _framePool = Direct3D11CaptureFramePool.Create(ĭirectXPixelFormat.B8G8R8A8UIntNormalized, // Pixel format Public void StartCaptureInternal(GraphicsCaptureItem item) Private Direct3D11CaptureFramePool _framePool For more information, please see Using DirectX with high dynamic range Displays and Advanced Color. This article will focus on SDR content capturing. Depends on the need, additional processing such as saving to HDR content format or HDR-to-SDR tone mapping might be required. the captured content looks washed out) when capturing HDR content, consider using DXGI_FORMAT_R16G16B16A16_FLOAT for every component in the capturing pipeline, including the Direct3D11CaptureFramePool, the target destination such as CanvasBitmap.
On systems with Windows HD color enabled, the content pixel format might not necessarily be DXGI_FORMAT_B8G8R8A8_UNORM. The ContentSize property of the GraphicsCaptureItem class can be used as the size of your frame: Using the GraphicsCaptureItem, you will create a Direct3D11CaptureFramePool with your D3D device, supported pixel format ( DXGI_FORMAT_B8G8R8A8_UNORM), number of desired frames (which can be any integer), and frame size. If you're calling it from the code-behind for a page of your application (like ) this is done for you automatically, but if not, you can force it to run on the UI thread with the following code: CoreWindow window = Īwait (CoreDispatcherPriority.Normal, async () =>ĭim window As CoreWindow = Īwait (CoreDispatcherPriority.Normal,Ĭreate a capture frame pool and capture session ' control without making a selection or hit Cancel.īecause this is UI code, it needs to be called on the UI thread. ' The item may be null if the user dismissed the
' The GraphicsCapturePicker follows the same pattern theĭim item As GraphicsCaptureItem = Await picker.PickSingleItemAsync() Public Async Function StartCaptureAsync() As Task We'll define this method later in the document. control without making a selection or hit Cancel. The item may be null if the user dismissed the GraphicsCaptureItem item = await picker.PickSingleItemAsync()
Var picker = new GraphicsCapturePicker() The GraphicsCapturePicker follows the same pattern the The picker will return a GraphicsCaptureItem that will be used to create a GraphicsCaptureSession: public async Task StartCaptureAsync() The end user uses this UI to select the display or application window of which to take screen captures. Once you've verified that screen capture is supported, use the GraphicsCapturePicker class to invoke the system picker UI. If Not GraphicsCaptureSession.IsSupported ThenĬaptureButton.Visibility = Visibility.Collapsed Hide the capture UI if screen capture is not supported.ĬaptureButton.Visibility = Visibility.Collapsed If (!GraphicsCaptureSession.IsSupported()) Use the IsSupported method in the GraphicsCaptureSession class to determine if UWP screen capture is supported: // This runs when the application starts. There are several reasons why your application might not be able to use screen capture, including if the device does not meet hardware requirements or if the application targeted for capture blocks screen capture. Launch the system UI to start screen captureīefore launching the system UI, you can check to see if your application is currently able to take screen captures.