diff --git a/sane-sys/src/lib.rs b/sane-sys/src/lib.rs index cf6af3c..4665c0c 100644 --- a/sane-sys/src/lib.rs +++ b/sane-sys/src/lib.rs @@ -16,6 +16,14 @@ pub const fn SANE_VERSION_BUILD(code: SANE_Int) -> SANE_Word { (code >> 0) as SANE_Word & 0xffff } +pub fn SANE_FIX(v: f64) -> SANE_Word { + (v * (1 << SANE_FIXED_SCALE_SHIFT) as f64) as SANE_Word +} + +pub fn SANE_UNFIX(v: SANE_Word) -> f64 { + v as f64 / (1 << SANE_FIXED_SCALE_SHIFT) as f64 +} + #[cfg(test)] mod tests { use super::*;