You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have hard coded stride to 4320 so the final buffer would be the correct length. (The saved image is pure distorted noise nevertheless) It seems that the captured buffer would use a strange 1920x1920 resolution?
Code for reproduce:
fn cap_and_save(file_name:&str) -> (){let one_second = Duration::new(1,0);let one_frame = one_second / 60;let display = Display::all().expect("Couldn't find any display.");let second = display
.into_iter().nth(1).expect("Couldn't find second display.");letmut capturer = Capturer::new(second).expect("Couldn't begin capture.");let(w, h) = (capturer.width(), capturer.height());loop{// Wait until there's a frame.let buffer = match capturer.frame(){Ok(buffer) => buffer,Err(error) => {if error.kind() == WouldBlock{// Keep spinning.
thread::sleep(one_frame);continue;}else{panic!("Error: {}", error);}}};println!("Captured! Saving...");// Flip the ARGB image into a RGB image.letmut bitflipped = Vec::with_capacity(w * h *4);//let stride = buffer.len() / h;let stride = 4320;println!("w: {}, h: {}, buffer_len: {}", w, h, buffer.len());println!("pixels: {}, pixels / 1920: {}", buffer.len()/4, (buffer.len() / 4) / 1920);println!("stride:{}", stride);for y in0..h {for x in0..w {let i = stride * y + 4* x;
bitflipped.extend_from_slice(&[buffer[i + 1], buffer[i + 2], buffer[i + 3]]);}}println!("RGB-len:{}", bitflipped.len());
...break;}
Env:
Windows 10, scrap = "0.5"
The text was updated successfully, but these errors were encountered:
Your code looks similar to the example in the example folder. I think the bitflipping is different? bitflipped.extend_from_slice(&[buffer[i + 1], buffer[i + 2], buffer[i + 3]]);
might require to be bitflipped.extend_from_slice(&[buffer[i + 2], buffer[i + 1], buffer[i + 0], 255]);
The following log was printed when I tried to capture from a portrait screen (1080 x 1920):
I have hard coded
stride
to 4320 so the final buffer would be the correct length. (The saved image is pure distorted noise nevertheless) It seems that the captured buffer would use a strange 1920x1920 resolution?Code for reproduce:
Env:
Windows 10, scrap = "0.5"
The text was updated successfully, but these errors were encountered: