From: Maxim S. <mcs...@ya...> - 2005-09-02 16:10:08
|
> byte f(byte alpha, byte cover) > { > int q=alpha*cover+128; > return (q+(q>>8))>>8; > } > > exact for 0< alpha,cover,f() < 256 and not terribly slower than > (alpha*cover + 255) >> 8. Thanks! I have checked it, and it works well even for 16 bits, and even when alpha=16bit, cover=8bit. But the latest, ((65535*255+128) + ((65535*255+128)>>8))>>8 gives us 65534. But that's fine I suppose, because I always check for "cover < 255". McSeem __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |