summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Figuière <hub@figuiere.net>2024-10-14 18:05:20 -0400
committerHubert Figuière <hub@figuiere.net>2024-10-14 18:05:20 -0400
commit3d42028abf06e17a2c16957e017c6f7162b2d8f8 (patch)
tree23a1f1ce214d6e0476810109b4cee256d461ef61
parentb61e994c4ef4fb1c122677359ca76b86b568730a (diff)
ordiag: Fix am overflow
Signed-off-by: Hubert Figuière <hub@figuiere.net>
-rw-r--r--src/bin/ordiag.rs4
1 files 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<usize> {
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::<BigEndian>(value)?;
amount += 2;
}