diff --git a/Cargo.lock b/Cargo.lock index 9417c0d..b752f8c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1351,7 +1351,7 @@ dependencies = [ [[package]] name = "haruhishot" -version = "0.3.0" +version = "0.3.1" dependencies = [ "clap", "dialoguer", diff --git a/Cargo.toml b/Cargo.toml index 2686c1b..e88761f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "haruhishot" -version = "0.3.0" +version = "0.3.1" edition = "2021" build = "build.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/filewriter.rs b/src/filewriter.rs index ab9d72b..8aa4d5a 100644 --- a/src/filewriter.rs +++ b/src/filewriter.rs @@ -139,9 +139,15 @@ pub fn write_to_file_mutisource(bufferdatas: Vec, usestdout: bool) { image::ColorType::Rgba8, ) .unwrap(); - images.push( - image::load_from_memory_with_format(buff.get_ref(), image::ImageFormat::Png).unwrap(), + let image = + image::load_from_memory_with_format(buff.get_ref(), image::ImageFormat::Png).unwrap(); + let image = image::imageops::resize( + &image, + buffer.realwidth as u32, + buffer.realheight as u32, + image::imageops::FilterType::Nearest, ); + images.push(image); } if usestdout { let mut buff = Cursor::new(Vec::new()); diff --git a/src/main.rs b/src/main.rs index 822516e..9335f3f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -568,6 +568,7 @@ fn take_screenshot(option: ClapOption) { manager, &display, shm.clone(), + state.display_logic_size[index], None, ) else { if usestdout { @@ -600,6 +601,7 @@ fn take_screenshot(option: ClapOption) { manager, &display, shm, + state.display_logic_size[id], None, ); match bufferdata { @@ -625,6 +627,7 @@ fn take_screenshot(option: ClapOption) { manager, &display, shm.clone(), + (width, height), Some((pos_x, pos_y, width,height)), ) else { if usestdout { @@ -651,6 +654,11 @@ fn take_screenshot(option: ClapOption) { // match option { ClapOption::ShotWithFullScreen { usestdout } => { + let xdg_output_manager = state.xdg_output_manager.clone().unwrap(); + for i in 0..state.displays.len() { + xdg_output_manager.get_xdg_output(&state.displays[i], &qh, ()); + event_queue.roundtrip(&mut state).unwrap(); + } shootglobal(usestdout, &state); } ClapOption::ShotWithCoosedScreen { screen, usestdout } => { diff --git a/src/wlrbackend.rs b/src/wlrbackend.rs index 4cb58ac..1cc7527 100644 --- a/src/wlrbackend.rs +++ b/src/wlrbackend.rs @@ -107,6 +107,8 @@ pub struct BufferData { //pub buffer: Option, pub width: u32, pub height: u32, + pub realwidth: i32, + pub realheight: i32, //pub stride: u32, shm: WlShm, pub frame_mmap: Option, @@ -114,11 +116,13 @@ pub struct BufferData { } impl BufferData { - fn new(shm: WlShm) -> Self { + fn new(shm: WlShm, (realwidth, realheight): (i32, i32)) -> Self { BufferData { //buffer: None, width: 0, height: 0, + realheight, + realwidth, // stride: 0, shm, frame_mmap: None, @@ -265,12 +269,13 @@ pub fn capture_output_frame( manager: &ZwlrScreencopyManagerV1, display: &WlDisplay, shm: wl_shm::WlShm, + (realwidth, realheight): (i32, i32), slurpoption: Option<(i32, i32, i32, i32)>, ) -> Option { let mut event_queue = connection.new_event_queue(); let qh = event_queue.handle(); display.get_registry(&qh, ()); - let mut framesate = BufferData::new(shm); + let mut framesate = BufferData::new(shm, (realwidth, realheight)); match slurpoption { None => { manager.capture_output(0, output, &qh, ());