From 3d42028abf06e17a2c16957e017c6f7162b2d8f8 Mon Sep 17 00:00:00 2001 From: Hubert Figuière Date: Mon, 14 Oct 2024 18:05:20 -0400 Subject: ordiag: Fix am overflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hubert Figuière --- src/bin/ordiag.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/ordiag.rs b/src/bin/ordiag.rs index 6dac5d6..fcfa6f4 100644 --- a/src/bin/ordiag.rs +++ b/src/bin/ordiag.rs @@ -132,13 +132,13 @@ fn save_raw(p: &str, rawdata: &RawImage) -> Result { let mut amount = 0; let raw = std::path::PathBuf::from(format!("{stem}_RAW.pgm")); if let Some(d) = rawdata.data16() { - let white = (1 << rawdata.bpc()) - 1; + let white = (1_u32 << rawdata.bpc()) - 1; let mut f = std::fs::File::create(&raw)?; amount += f.write(b"P5\n")?; amount += f.write(format!("{} {}\n", rawdata.width(), rawdata.height()).as_bytes())?; amount += f.write(format!("{white}\n").as_bytes())?; for b in d { - let value = std::cmp::min(*b, white); + let value = std::cmp::min(*b, white as u16); f.write_u16::(value)?; amount += 2; } -- cgit v1.2.3