diff options
Diffstat (limited to 'examples/screenshot/src/main.rs')
-rw-r--r-- | examples/screenshot/src/main.rs | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/examples/screenshot/src/main.rs b/examples/screenshot/src/main.rs index d9784dc8..fa06d3e9 100644 --- a/examples/screenshot/src/main.rs +++ b/examples/screenshot/src/main.rs @@ -273,15 +273,20 @@ impl Application for Example { async fn save_to_png(screenshot: Screenshot) -> Result<String, PngError> { let path = "screenshot.png".to_string(); - img::save_buffer( - &path, - &screenshot.bytes, - screenshot.size.width, - screenshot.size.height, - ColorType::Rgba8, - ) - .map(|_| path) - .map_err(|err| PngError(format!("{err:?}"))) + + tokio::task::spawn_blocking(move || { + img::save_buffer( + &path, + &screenshot.bytes, + screenshot.size.width, + screenshot.size.height, + ColorType::Rgba8, + ) + .map(|_| path) + .map_err(|err| PngError(format!("{err:?}"))) + }) + .await + .expect("Blocking task to finish") } #[derive(Clone, Debug)] |