owenthewizard / screenshots-rs

A cross-platform screenshots library for MacOS、Windows、Linux(X11、wayland).

Home Page:https://docs.rs/screenshots

Repository from Github https://github.comowenthewizard/screenshots-rsRepository from Github https://github.comowenthewizard/screenshots-rs

screenshots

A cross-platform screenshots library for MacOS、Windows、Linux(X11、wayland).

example

use screenshots::Screen;
use std::{fs, time::Instant};

fn main() {
  let start = Instant::now();
  let screens = Screen::all();

  for screen in screens {
    println!("capturer {:?}", screen);
    let image = screen.capture().unwrap();
    let buffer = image.buffer();
    fs::write(format!("{}.png", screen.id.to_string()), &buffer).unwrap();
  }

  let screen = Screen::from_point(100, 100).unwrap();
  println!("capturer {:?}", screen);

  let image = screen.capture().unwrap();
  let buffer = image.buffer();
  fs::write("capture_display_with_point.png", &buffer).unwrap();

  println!("运行耗时: {:?}", start.elapsed());
}

About

A cross-platform screenshots library for MacOS、Windows、Linux(X11、wayland).

https://docs.rs/screenshots

License:Apache License 2.0


Languages

Language:Rust 100.0%