4 releases
0.1.4 | Aug 5, 2023 |
---|---|
0.1.3 | Jul 27, 2023 |
0.1.2 | Jul 27, 2023 |
0.1.1 | Jul 27, 2023 |
#633 in Operating systems
6KB
52 lines
dcx_screencapturer
This library was made to capture screens, from the operating systems:
Windows - work;
Linux - coming soon;
MacOs - coming soon;
Example code:
extern crate image;
extern crate dcx_screencapturer;
//used to receive buffer and save to selected format
use image::{ImageBuffer, Rgb, ImageFormat};
use dcx_screencapturer::capture_screen;
fn main() {
//Gets the ImageBuffer<Rgb<u8>, Vec<u8>> using this parameters
//width, height, monitor_index
let buffer = capture_screen( 1920, 1080, 0);
let image_buffer = ImageBuffer::<Rgb<u8>, _>::from_raw(1920, 1080, buffer)
.expect("Error converting to ImageBuffer");
//path to save image file
let image_path = "capture.png";
//saving with png format
image_buffer.save_with_format(image_path, ImageFormat::Png)
.expect("Error saving image");
print!("Image salved in path : {image_path}")
}
Just add the libraries on Cargo.toml
[dependencies]
image = "0.24.6"
dcx_screencapture = "0.1.3"
Dependencies
~16–23MB
~273K SLoC