From c037eb74549baec0e7371eff3fcc65036b97dc93 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sat, 21 Dec 2024 22:42:05 +0100 Subject: [PATCH] fix: make sure the image has width 800 --- linux_app/src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/linux_app/src/main.rs b/linux_app/src/main.rs index 5f64c59..0817d9d 100644 --- a/linux_app/src/main.rs +++ b/linux_app/src/main.rs @@ -34,7 +34,10 @@ async fn main() -> tokio_serial::Result<()> { img = img.rotate90(); } - let rgb_img = img.resize(WIDTH.try_into().unwrap(), HEIGHT.try_into().unwrap(), FilterType::Nearest).into_rgb8(); + let ratio = WIDTH as f64 / img.width() as f64; + let height = (ratio * img.height() as f64) as u32; + + let rgb_img = img.resize_exact(WIDTH.try_into().unwrap(), height, FilterType::Nearest).into_rgb8(); let mut raw_img = rgb_img.into_raw(); raw_img.resize(TOTAL_BYTES, 0x00); -- 2.48.1