Skip to content

Commit

Permalink
fix foo and redundant comment
Browse files Browse the repository at this point in the history
  • Loading branch information
sverrejb committed Jul 22, 2024
1 parent 937a57c commit 165e722
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/selfie/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pub fn grab_selfie(main_window: &MainWindow) -> Timer {
move || {
let ui = sc_handle.unwrap();
ui.window().request_redraw();
let foo = ui.window().take_snapshot().unwrap();
save_screenshot(foo);
let pixel_buffer = ui.window().take_snapshot().unwrap();
save_screenshot(pixel_buffer);
},
);

Expand All @@ -28,10 +28,11 @@ pub fn grab_selfie(main_window: &MainWindow) -> Timer {

#[cfg(feature = "selfie")]
fn save_screenshot(screenshot: SharedPixelBuffer<Rgba8Pixel>) {
use log::info;

let (width, height) = (screenshot.width(), screenshot.height());
let raw_pixels: &[u8] = screenshot.as_bytes();

// Create an ImageBuffer from the raw pixel data
let img = ImageBuffer::<Rgba<u8>, _>::from_raw(width, height, raw_pixels)
.ok_or_else(|| {
ImageError::Parameter(ParameterError::from_kind(
Expand All @@ -40,6 +41,6 @@ fn save_screenshot(screenshot: SharedPixelBuffer<Rgba8Pixel>) {
})
.unwrap();

println!("Taking screenshot!");
info!("Taking screenshot!");
let _ = img.save("screenshot.png");
}

0 comments on commit 165e722

Please sign in to comment.