Generally:
So for example:
case Red: return (hexvalue >> 16) & 0xff; case Green: return (hexvalue >> 8) & 0xff; default:
The order of operations helps to reduce the size of the literal constants needed for masks, which usually leads to a reduction in code.
I took a DNNX comment to the heart and switched component names, since the order is usually RGB (not RBG).
Also, note that these operations have nothing to do with a number that is hexadecimal when you perform operations on an integer type. Hexadecimal is a designation, a way of representing numbers, in text form. The number itself is not stored in hexadecimal, it is binary, like everything else on your computer.
source share