I am trying to create ARGB pixel, I have seen this example:
int createPixel(int r, int g, int b, int a)
{
return (a<<24) | (r<<16) | (g<<8) | (b<<0);
}
For understanding I would like get answers to this questions:
- What am getting as result (return)?
- What is << means?
- If value of each color is 255, so for RED 16 is 255 and 23 is 0?
<<is binary shift left, this means a will be shifted 24 bits to the left, red 16,... you get an 4byte integer as result, first byte is a (because shifted 24 bits (3Bytes) to the left), second byte is r, third is g, fourth b.resulting
0xaarrggbbexample input
(255,255,0,16)returns0xFFFF000F0x stands for "in hex format"
|is a bitwise or.