From fb4ee9b3773a8f07d5a03d61130eedc738bd636d Mon Sep 17 00:00:00 2001 From: "A. Molzer" <5550310+197g@users.noreply.github.com> Date: Thu, 5 Feb 2026 04:09:03 +0100 Subject: [PATCH] Convert float images in decode example --- examples/decode.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/examples/decode.rs b/examples/decode.rs index 10a7d10..2bad4a1 100644 --- a/examples/decode.rs +++ b/examples/decode.rs @@ -36,6 +36,31 @@ fn debug_planes( colortype: &tiff::ColorType, (width, height): (u32, u32), ) { + match data { + DecodingResult::F16(v) => { + let samples = v + .iter() + .map(|&f| (f64::from(f) * f64::from(u16::MAX)) as u16) + .collect::>(); + *data = DecodingResult::U16(samples); + } + DecodingResult::F32(v) => { + let samples = v + .iter() + .map(|&f| (f64::from(f) * f64::from(u16::MAX)) as u16) + .collect::>(); + *data = DecodingResult::U16(samples); + } + DecodingResult::F64(v) => { + let samples = v + .iter() + .map(|&f| (f * f64::from(u16::MAX)) as u16) + .collect::>(); + *data = DecodingResult::U16(samples); + } + _ => {} + } + let (depth, mut tupltype) = match colortype { // Note: we will expand, so this is in fact not BLACKANDWHITE tiff::ColorType::Gray(_) => (1, "GRAYSCALE"),