Crates.io | dcx_screencapturer |
lib.rs | dcx_screencapturer |
version | 0.1.4 |
source | src |
created_at | 2023-07-27 14:40:33.452867 |
updated_at | 2023-08-05 18:03:00.311798 |
description | A library to capture screens |
homepage | |
repository | https://github.com/diocarvalho/dcx-screencapturer-rs |
max_upload_size | |
id | 927485 |
size | 5,554 |
This library was made to capture screens, from the operating systems:
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"