forked from michael/leanshot
re-encode image to work with png
This commit is contained in:
parent
eca99edb41
commit
39d80bddf7
4 changed files with 7 additions and 12 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -250,7 +250,7 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|||
|
||||
[[package]]
|
||||
name = "leanshot"
|
||||
version = "0.4.0"
|
||||
version = "0.4.0-rc"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"image",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "leanshot"
|
||||
description = "Screenshot capture for Linux."
|
||||
version = "0.4.0"
|
||||
version = "0.4.0-rc"
|
||||
repository = "https://git.mzhang.io/michael/leanshot"
|
||||
license-file = "LICENSE"
|
||||
edition = "2018"
|
||||
|
|
10
src/gui.rs
10
src/gui.rs
|
@ -30,7 +30,6 @@ impl Gui {
|
|||
// get the dimensions of the screen
|
||||
let screen = self.get_default_screen();
|
||||
let (width, height) = (screen.width_in_pixels(), screen.height_in_pixels());
|
||||
println!("width, height = {:?}", (width, height));
|
||||
|
||||
let image = xcb_image::get(
|
||||
&self.conn,
|
||||
|
@ -102,7 +101,7 @@ impl Gui {
|
|||
.request_check()?;
|
||||
|
||||
info!("Grabbing keyboard...");
|
||||
let result = xproto::grab_keyboard(
|
||||
xproto::grab_keyboard(
|
||||
&self.conn,
|
||||
false,
|
||||
id,
|
||||
|
@ -111,11 +110,10 @@ impl Gui {
|
|||
xcb::GRAB_MODE_ASYNC as u8,
|
||||
)
|
||||
.get_reply()?;
|
||||
println!("result: {:?}", result.status());
|
||||
|
||||
info!("Grabbing pointer...");
|
||||
let cursor = xcb_util::cursor::create_font_cursor(&self.conn, xcb_util::cursor::CROSSHAIR);
|
||||
let result = xproto::grab_pointer(
|
||||
xproto::grab_pointer(
|
||||
&self.conn,
|
||||
false,
|
||||
id,
|
||||
|
@ -129,7 +127,6 @@ impl Gui {
|
|||
xcb::CURRENT_TIME,
|
||||
)
|
||||
.get_reply()?;
|
||||
println!("result: {:?}", result.status());
|
||||
|
||||
let gc = self.conn.generate_id();
|
||||
xproto::create_gc(
|
||||
|
@ -251,7 +248,8 @@ impl ScreenCapture {
|
|||
self.image.data().to_vec(),
|
||||
)
|
||||
.unwrap();
|
||||
let mut image = DynamicImage::ImageBgra8(image);
|
||||
let image = DynamicImage::ImageBgra8(image);
|
||||
let mut image = DynamicImage::ImageRgb8(image.into_rgb8());
|
||||
|
||||
// TODO: compare the rectangles to see if we can skip the crop
|
||||
// crop the image
|
||||
|
|
|
@ -32,7 +32,6 @@ fn main() -> Result<()> {
|
|||
let rectangle = gui.interactive_select(&capture)?;
|
||||
capture.save_cropped_to(&opt.outfile, rectangle)?;
|
||||
}
|
||||
_ => todo!("TODO"),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -58,7 +57,6 @@ pub struct Options {
|
|||
#[allow(missing_docs)]
|
||||
pub enum Region {
|
||||
Fullscreen,
|
||||
ActiveWindow,
|
||||
Selection,
|
||||
}
|
||||
|
||||
|
@ -66,9 +64,8 @@ impl Region {
|
|||
pub fn from_str(x: &str) -> Result<Self> {
|
||||
match x {
|
||||
"fullscreen" => Ok(Region::Fullscreen),
|
||||
"window" => Ok(Region::ActiveWindow),
|
||||
"select" | "selection" => Ok(Region::Selection),
|
||||
_ => bail!("expected {fullscreen|window|selection}"),
|
||||
_ => bail!("expected {fullscreen|selection}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue