10 stable releases
1.1.3 | Mar 29, 2022 |
---|---|
1.1.2 | Mar 28, 2022 |
1.0.5 | Mar 28, 2022 |
1.0.4 | Mar 25, 2022 |
#132 in Rendering
27 downloads per month
36KB
697 lines
dxcapture
dxcapture
is a library for capturing a Direct3D 11 device on Windows.
[dependencies]
dxcapture = "1.1"
Details
let device = dxcapture::Device::default();
let capture = dxcapture::Capture::new(&device).unwrap();
let raw = loop {
match capture.get_raw_frame() {
Ok(raw) => break raw,
Err(e) => {
if e == dxcapture::CaptureError::NoTexture {
// async, so sometimes it's not there.
continue;
}
panic!("{}", e);
}
}
};
// taked primary monitor.
// hoge raw
Optional Features
-
img
- Enable features that depend on theimage
cratedxcapture = { version = "1.1", features = ["img"] }
let device = dxcapture::Device::default(); let capture = dxcapture::Capture::new(&device).unwrap(); let image = capture.wait_img_frame().expect("Failed to capture"); let path = "image.png"; image.data.save(path).expect("Failed to save");
-
mat
- Enable features that depend on theopencv
cratedxcapture = { version = "1.1", features = ["mat"] }
use opencv::prelude::*; use opencv::imgcodecs::{ imwrite, IMWRITE_PNG_STRATEGY_DEFAULT }; let device = dxcapture::Device::default(); let capture = dxcapture::Capture::new(&device).unwrap(); let mat = capture.wait_mat_frame().expect("Failed to capture"); let path = "image.png"; imwrite(path, &mat.data, &vec![IMWRITE_PNG_STRATEGY_DEFAULT].into()).expect("Failed to save");
Exmaples
Documentation
License
Special Thanks
This crate completed thanks to wgc-rust-demo
Dependencies
~132MB
~2M SLoC