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 图像
每月812次下载
用于 9 crate
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