[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11919] trunk/blender/source/blender/imbuf /intern/divers.c: Bugfix #7125

Martin Poirier theeth at yahoo.com
Sun Sep 2 19:15:36 CEST 2007


--- Martin Poirier <theeth at yahoo.com> wrote:

> You can probably use that too:
> 
> #define FTOCHAR(val) val<=0.0f?0: (val>(1.0f - 0.5f
> /
> 255.0f)?255: (char)(255.0f*val))
> 
> Multiplying by 255.99 will give values 1 higher than
> they should be for float values > 0.5. (I dealt with
> a
> similar issue at work, that's more or less what we
> used).

That was assuming rounding, of course, in this case,
it's truncating on cast, so you can use:

#define FTOCHAR(val) val<=0.0f?0: (val>(1.0f - 1.0f /
255.0f)?255: (char)(255.0f*val))

The 0.5 was to make it round in the correct direction.

Martin


       
____________________________________________________________________________________
Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
http://farechase.yahoo.com/


More information about the Bf-committers mailing list