[sane-devel] what' mean SANE_FIX ?
Wed, 24 Jul 2002 20:14:59 +0200
On Wed, Jul 24, 2002 at 11:03:36AM +0800, zhu wrote:
> When I read some backends,I often see SANE_FIX and SANE_UNFIX macro,they are defined in sane.h:
> #define SANE_FIXED_SCALE_SHIFT 16
> #define SANE_FIX(v) ((SANE_Word) ((v) * (1 << SANE_FIXED_SCALE_SHIFT)))
> #define SANE_UNFIX(v) ((double)(v) / (1 << SANE_FIXED_SCALE_SHIFT))
> Is SANE_FIX(v)=v*32768 and SANE_UNFIX(v)=v/32768 ?
> in many backend, when we initialize some value,we SANE_FIX it,when we
> need to use these value,we SANE_UNFIX it ,Why we shoud do SANE_FIX
> and SANE_UNFIX ,what SANE_FIX mean ?
That's a data format: SANE_Fixed is a fixed point type that's used to
store fixed point numbers in a SANE_Word. SANE_FIX means: "cast double
to SANE_Fixed", SANE_UNFIX is the other way round.
See SANE standard 4.2.4 (http://www.mostang.com/sane/html/doc011.html).