[cairo] Use 8-bit colour values internally
Behdad Esfahbod
behdad at cs.toronto.edu
Tue Aug 23 11:56:12 PDT 2005
On Tue, 23 Aug 2005, MenTaLguY wrote:
> On Mon, 2005-08-22 at 23:37 -0400, Jason Dorje Short wrote:
>
> > #define COLOR_INT_TO_SHORT(c) ((c) << 8)
>
> If you're going to do that, it may as well be:
>
> #define COLOR_INT_TO_SHORT(c) (((c) << 8) | (c))
which happens to be
#define COLOR_INT_TO_SHORT(c) ((c) * 257)
> Which yields the expected 65535 for COLOR_INT_TO_SHORT(255),
> instead of 65280.
thanks to the (x+1) * (x-1) == (x*x-1).
> -mental
;)
--behdad
More information about the cairo
mailing list