From 39d80bddf72d9cf52b50dcc4e401241a6512c1b3 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Wed, 23 Dec 2020 22:58:39 -0600 Subject: [PATCH] re-encode image to work with png --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/gui.rs | 10 ++++------ src/main.rs | 5 +---- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 540b212..2d92540 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -250,7 +250,7 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "leanshot" -version = "0.4.0" +version = "0.4.0-rc" dependencies = [ "anyhow", "image", diff --git a/Cargo.toml b/Cargo.toml index 058dd6e..cd0cdd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/gui.rs b/src/gui.rs index 989a5cb..d142583 100644 --- a/src/gui.rs +++ b/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 diff --git a/src/main.rs b/src/main.rs index 70962ff..c4abdab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 { match x { "fullscreen" => Ok(Region::Fullscreen), - "window" => Ok(Region::ActiveWindow), "select" | "selection" => Ok(Region::Selection), - _ => bail!("expected {fullscreen|window|selection}"), + _ => bail!("expected {fullscreen|selection}"), } } }