12个不稳定版本 (5个破坏性版本)

使用旧的Rust 2015

0.5.0 2018年4月8日
0.4.0 2018年1月4日
0.3.2 2017年7月16日
0.3.0 2017年6月25日
0.0.2 2017年6月21日

#509 in 图像

Download history 190/week @ 2024-03-13 238/week @ 2024-03-20 267/week @ 2024-03-27 257/week @ 2024-04-03 211/week @ 2024-04-10 214/week @ 2024-04-17 262/week @ 2024-04-24 230/week @ 2024-05-01 263/week @ 2024-05-08 430/week @ 2024-05-15 230/week @ 2024-05-22 269/week @ 2024-05-29 191/week @ 2024-06-05 189/week @ 2024-06-12 232/week @ 2024-06-19 165/week @ 2024-06-26

每月812次下载
用于 9 crate

MIT许可证

50KB
1.5K SLoC

scrap

Scrap可以记录您的屏幕!如果您使用的是Windows、macOS或Linux,它至少可以做到这一点。

使用方法

[dependencies]
scrap = "0.5"

它的API简单到极致!

struct Display; /// A screen.
struct Frame; /// An array of the pixels that were on-screen.
struct Capturer; /// A recording instance.

impl Capturer {
    /// Begin recording.
    pub fn new(display: Display) -> io::Result<Capturer>;

    /// Try to get a frame.
    /// Returns WouldBlock if it's not ready yet.
    pub fn frame<'a>(&'a mut self) -> io::Result<Frame<'a>>;

    pub fn width(&self) -> usize;
    pub fn height(&self) -> usize;
}

impl Display {
    /// The primary screen.
    pub fn primary() -> io::Result<Display>;

    /// All the screens.
    pub fn all() -> io::Result<Vec<Display>>;

    pub fn width(&self) -> usize;
    pub fn height(&self) -> usize;
}

impl<'a> ops::Deref for Frame<'a> {
    /// A frame is just an array of bytes.
    type Target = [u8];
}

帧格式

  • 帧格式保证是 打包的BGRA
  • 宽度和高度保证保持不变。
  • 步进可能大于宽度,并且它可能在帧之间变化。

系统要求

操作系统 最低要求
macOS macOS 10.8
Linux XCB + SHM + RandR
Windows DirectX 11.1

依赖关系

~135KB