Create ARGB Platte in Android

137 views Asked by At

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:

  1. What am getting as result (return)?
  2. What is << means?
  3. If value of each color is 255, so for RED 16 is 255 and 23 is 0?
1

There are 1 answers

0
bbuecherl On BEST ANSWER

<< 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 0xaarrggbb

example input (255,255,0,16) returns 0xFFFF000F

0x stands for "in hex format"

| is a bitwise or.