Skip to content

Commit

Permalink
chore: 0.3.1 handle scale now
Browse files Browse the repository at this point in the history
  • Loading branch information
Decodetalkers committed Jan 17, 2023
1 parent 1b0f2d1 commit 4ab09f4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 8 additions & 2 deletions src/filewriter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,15 @@ pub fn write_to_file_mutisource(bufferdatas: Vec<BufferData>, 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());
Expand Down
8 changes: 8 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ fn take_screenshot(option: ClapOption) {
manager,
&display,
shm.clone(),
state.display_logic_size[index],
None,
) else {
if usestdout {
Expand Down Expand Up @@ -600,6 +601,7 @@ fn take_screenshot(option: ClapOption) {
manager,
&display,
shm,
state.display_logic_size[id],
None,
);
match bufferdata {
Expand All @@ -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 {
Expand All @@ -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 } => {
Expand Down
9 changes: 7 additions & 2 deletions src/wlrbackend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,22 @@ pub struct BufferData {
//pub buffer: Option<WlBuffer>,
pub width: u32,
pub height: u32,
pub realwidth: i32,
pub realheight: i32,
//pub stride: u32,
shm: WlShm,
pub frame_mmap: Option<MmapMut>,
state: ScreenCopyState,
}

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,
Expand Down Expand Up @@ -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<BufferData> {
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, ());
Expand Down

0 comments on commit 4ab09f4

Please sign in to comment.