| Crates.io | luo-capture |
| lib.rs | luo-capture |
| version | 0.1.0 |
| created_at | 2026-01-08 08:07:07.13866+00 |
| updated_at | 2026-01-08 08:07:07.13866+00 |
| description | A high-performance screen capture module using DXGI technology for Windows platforms |
| homepage | https://github.com/luo1227/luo-capture-rs |
| repository | https://github.com/luo1227/luo-capture-rs.git |
| max_upload_size | |
| id | 2029737 |
| size | 32,633 |
A high-performance screen capture module using DXGI technology for Windows platforms.
Add this to your Cargo.toml:
[dependencies]
luo-capture-rs = "0.1.0"
use luo_capture_rs::capture::*;
fn main() {
// Initialize the capture module
let mut capture = init().expect("Failed to initialize capture");
// Define a capture region (x, y, width, height)
let region = CaptureRegion {
x: 0,
y: 0,
width: 800,
height: 600,
};
// Capture the region
match capture.capture(region) {
Ok(capture_data) => {
println!("Captured {}x{} image with {} bytes of data",
capture_data.width, capture_data.height, capture_data.data.len());
},
Err(e) => eprintln!("Capture failed: {}", e),
}
}
use luo_capture_rs::capture::*;
#[tokio::main]
async fn main() {
// Initialize the capture module asynchronously
let async_capture = init_async().await.expect("Failed to initialize async capture");
// Define a capture region
let region = CaptureRegion {
x: 0,
y: 0,
width: 800,
height: 600,
};
// Capture the region asynchronously
match async_capture.capture(region).await {
Ok(capture_data) => {
println!("Captured {}x{} image with {} bytes of data",
capture_data.width, capture_data.height, capture_data.data.len());
},
Err(e) => eprintln!("Capture failed: {}", e),
}
}
use luo_capture_rs::capture::*;
use std::time::Instant;
fn main() {
// Measure initialization time
let start_time = Instant::now();
let mut capture = init().expect("Failed to initialize capture");
let init_duration = start_time.elapsed();
println!("Initialization took: {:.3}ms", init_duration.as_secs_f64() * 1000.0);
// Define a capture region
let region = CaptureRegion {
x: 0,
y: 0,
width: 800,
height: 600,
};
// Measure capture time
let start_time = Instant::now();
match capture.capture(region) {
Ok(capture_data) => {
let capture_duration = start_time.elapsed();
println!("Capture took: {:.3}ms", capture_duration.as_secs_f64() * 1000.0);
println!("Captured {}x{} image with {} bytes of data",
capture_data.width, capture_data.height, capture_data.data.len());
},
Err(e) => eprintln!("Capture failed: {}", e),
}
}
CaptureRegion: Defines the screen region to capture (x, y, width, height)CaptureData: Contains captured image data, dimensions, and timestampScreenCapture: Main capture interfaceAsyncScreenCapture: Async wrapper for non-blocking operationsinit(): Initialize the capture module synchronouslyinit_async(): Initialize the capture module asynchronouslycapture(): Capture a screen region synchronouslycapture_async(): Capture a screen region asynchronouslyThe module provides comprehensive error handling through the CaptureError enum:
InitializationError: Errors during initializationCaptureError: Errors during capture operationsInvalidRegion: Invalid capture region parametersResourceError: Resource allocation or management errorsCurrently supports Windows platforms with DXGI support. The implementation uses DirectX Graphics Infrastructure for optimal performance.
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.
To run the examples:
cargo run --example usage
To run tests:
cargo test