Skip to content

Commit

Permalink
Screenshots size equal the window logical size
Browse files Browse the repository at this point in the history
  • Loading branch information
asny committed Apr 13, 2023
1 parent 4ea58b7 commit 1f216ea
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/window/winit_window/frame_input_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,25 @@ impl FrameInputGenerator {

#[cfg(not(target_arch = "wasm32"))]
if let Some(exit_time) = option_env!("THREE_D_EXIT").map(|v| v.parse::<f64>().unwrap()) {
if exit_time < self.accumulated_time {
if exit_time < frame_input.accumulated_time {
#[cfg(feature = "image")]
if let Some(path) = option_env!("THREE_D_SCREENSHOT") {
let pixels = frame_input.screen().read_color::<[u8; 4]>();
let img = image::DynamicImage::ImageRgba8(
image::ImageBuffer::from_raw(
self.viewport.width,
self.viewport.height,
frame_input.viewport.width,
frame_input.viewport.height,
pixels.into_iter().flatten().collect::<Vec<_>>(),
)
.unwrap(),
);
img.resize(1280, 720, image::imageops::FilterType::Triangle)
.save(path)
.unwrap();
img.resize(
frame_input.window_width,
frame_input.window_height,
image::imageops::FilterType::Triangle,
)
.save(path)
.unwrap();
}
std::process::exit(0);
}
Expand Down

0 comments on commit 1f216ea

Please sign in to comment.