Crates.io | dxcapture |
lib.rs | dxcapture |
version | 1.1.3 |
source | src |
created_at | 2022-03-25 08:25:03.968058 |
updated_at | 2022-03-29 06:06:21.12664 |
description | `dxcapture` is a library for capturing a Direct3D 11 device on Windows. |
homepage | https://bass-clef.github.io/ |
repository | https://github.com/bass-clef/dxcapture |
max_upload_size | |
id | 556141 |
size | 36,151 |
dxcapture
is a library for capturing a Direct3D 11 device on Windows.
[dependencies]
dxcapture = "1.1"
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
img
- Enable features that depend on the image
crate
dxcapture = { 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 the opencv
crate
dxcapture = { 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");
This crate completed thanks to wgc-rust-demo