5个版本 (2个稳定版)
1.0.1 | 2023年3月20日 |
---|---|
0.1.2 | 2023年3月19日 |
0.1.1 | 2023年3月18日 |
0.1.0 | 2023年3月18日 |
#666 在 图像
每月45次下载
21KB
419 行
现在通过利用它简单的cli api,轻松将flameshot集成到您的应用程序中。您可以选择性地获取截图的动态_image进行操作。如果您完全不想使用dynamic_image或image crate,您可以在FlameshotOutput.output的stdout字段中找到原始图像
此示例使用'image' crate功能。
//use flameshot::FullArgs;
use flameshot::GuiArgs;
//use flameshot::ScreenArgs;
//////////////////////////////////////////////////////////////////////
// If we enable "image" library Feature, we will be able to convert//
// a FlameshotOutput into a DynamicImage form rust Image crate. //
///////////////////////////////////////////////////////////////////
pub fn main() {
/// We select one of the 3 main param types and use the builder method to
/// customize the cli arguments, it includes all flameshot cli args.
let params = GuiArgs::builder()
.accept_on_select()
.raw() // this parameter is REQUIRED for converting to DynamicImage
.build();
/// This operation can error, it can error because of OS problems
/// or Flameshot problems.
let output = flameshot::execute(params).unwrap();
/// This operation cause an Image error
let img = output.to_dynamic_image().unwrap();
let convert_black_and_white = img.to_luma8().save("black_and_white.png").unwrap();
}
请确保安装flameshot并将其添加到您的环境路径中。现在您可以使用此crate通过flameshot捕获截图,同时可以选择性地获取用于操作的截图动态_image。如果您完全不想使用dynamic_image或image crate,您可以在FlameshotOutput.output的stdout字段中找到原始图像
查看其他示例。
依赖关系
~0–3MB
~15K SLoC