7 releases
0.1.7 | Feb 18, 2024 |
---|---|
0.1.6 | Feb 13, 2023 |
0.1.5 | Nov 16, 2022 |
0.1.3 | Mar 4, 2021 |
#230 in Images
217 downloads per month
76KB
2K
SLoC
rxscreen
A simple wrapper over libx11 to take screenshots.
Dependencies
- libx11
- libxext (with the
shm
feature) - libxrandr (with the
xrandr
feature)
Features
- save (save screenshots directly to file)
- MIT-SHM (use the MIT-SHM extension to rapidly take screenshots, used for screenrecording and similar)
- Xrandr (use Xrandr to query monitors connected to the X11 server)
- Mouse (query the mouse position)
Planned features
- Graphics, to allow creating own displays and drawing on them.
- Extend Xrandr support to change display configuration
Similar projects
lib.rs
:
rxscreen
is designed to be a simple, easy to use library around various functionality of the
x11 server and corresponding extensions.
Implemented features:
- X11
- Xrandr (via the
xrandr
feature) - MIT-SHM (via the
shm
feature)
Examples
Capture a screenshot of the entire X11 display
if let Ok(display) = Display::new(":0.0") {
let capture = display.capture()
.unwrap();
// `capture` is now an `Image` containing Bgr8 data of the image.
// You can now save it to a file, or do whatever you want with it.
}
Capture a screenshot of a specific monitor (requires the "xrandr" feature)
#[cfg(feature = "xrandr")]
#[cfg(feature = "xrandr")]
if let Ok(display) = Display::new(":0.0") {
if let Some(monitor) = display.monitors()
.iter()
.find(|monitor| monitor.primary()) {
let capture = display.capture_area(
(monitor.x as u32, monitor.y as u32),
(monitor.width as u32, monitor.height as u32)
).unwrap();
// `capture` is now an `Image` containing the screenshot of the primary monitor as Bgr8 data.
// You can now save it to a file, or do whatever you want with it.
}
}
Dependencies
~0–0.9MB
~12K SLoC