Skip to main content

Module dxgi_duplication_api

Module dxgi_duplication_api 

Source
Expand description

Contains types and functions related to the DXGI Desktop Duplication API. DXGI Desktop Duplication API wrapper.

This module provides [DxgiDuplicationApi] to capture a monitor using the Windows DXGI Desktop Duplication API. It integrates with crate::monitor::Monitor to select the target output and exposes CPU-readable frames via crate::frame::FrameBuffer.

§Example

use windows_capture::dxgi_duplication_api::DxgiDuplicationApi;
use windows_capture::encoder::ImageFormat;
use windows_capture::monitor::Monitor;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Select the primary monitor
    let monitor = Monitor::primary()?;

    // Create a duplication session for this monitor
    let mut dup = DxgiDuplicationApi::new(monitor)?;

    // Try to grab one frame within ~33ms (about 30 FPS budget)
    let mut frame = dup.acquire_next_frame(33)?;

    // Map the GPU image into CPU memory and save a PNG
    let mut buffer = frame.buffer()?;
    buffer.save_as_image("dup.png", ImageFormat::Png)?;
    Ok(())
}

Structs§

DxgiDuplicationApi
A minimal, ergonomic wrapper around the DXGI Desktop Duplication API for capturing a monitor.
DxgiDuplicationFrame
Represents a pre-assembled full desktop image for the current frame, backed by the internal GPU texture. Call DxgiDuplicationFrame::buffer to obtain a CPU-readable crate::frame::FrameBuffer.
DxgiDuplicationFrameBuffer
Represents a frame buffer containing pixel data.

Enums§

DxgiDuplicationFormat
Supported DXGI formats for duplication.
Error
Errors that can occur while using the DXGI Desktop Duplication API wrapper.