Splitting an RGB uint into its separate R G B components
bit-manipulation, colors, language-agnostic
Solution
r = (colour >> 16) & 0xff;
g = (colour >> 8) & 0xff;
b = colour & 0xff;
Problem
I have an RGB colour stored as a uint. I can create this from the RGB values using the bitwise left and bitwise or operator in an expression like this: ``` colour = r<<16 | g<<8 | b; ``` I want to do the opposite. I have the final number and I want the r, g and b values. Does anyone know how to do this?