Alpha-RGB (usually called RGBA or aRGB) consists of four bytes packed into a single unit.
AAAAAAAARRRRRRRRBBBBBBBBGGGGGGGG // the original par4, each char represents one bit. // where ARBG stands for alpha, red, blue and green bit.
The shift and and operator is used to extract each individual byte. For example, par4 >> 16 & 255 first shifts the integer 16 bits so that the original 3rd byte is in the database, and 255 serves as a mask to extract only one byte.
And par4 >> 16 shifts the original bit to 16 bits,
0000000000000000AAAAAAAARRRRRRRR
Finally, applying &255 , which is 00000000000000000000000011111111 in the bit representation, will mask the last 8 bits:
0000000000000000AAAAAAAARRRRRRRR & 00000000000000000000000011111111 = 000000000000000000000000RRRRRRRR
This gives you a red byte.
source share