Extracting/Setting alpha bits in a DWORD...
I have a DWORD which represents the colour if my particles, including their alpha. I need to be able to extract the alpha and set it independently of the rest, what is the best way to do this?
The DWORD layout is like this...
RRGGBBAA
Thanks in advance.
Mark Coleman
typedef unsigned char byte_t;const DWORD AlphaMask = 0xFF;inline byte_t GetAlpha(DWORD c){ return c & AlphaMask;}inline void SetAlpha(DWORD &c, byte_t a){ (c &= ~AlphaMask) |= a;}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement