Browse Source

add SANE_{,UN}FIX

master
Magnus Ulimoen 3 years ago
parent
commit
4fa167eb2a
  1. 8
      sane-sys/src/lib.rs

8
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::*;

Loading…
Cancel
Save