-1

I have been attempting to solve this for a while now, basically I want an integer, such as white (16777215) to be converted back into RGB (255,255,255), but I have no idea how.

I know R+(G*256)+(B*65536) = Integer but I want Integer = R,G,B.

Thanks for any help you can give!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
BSasuke
  • 79
  • 1
  • 1
  • 7

1 Answers1

3
int R = (i & 0x000000FF);
int G = (i & 0x0000FF00) >> 8;
int B = (i & 0x00FF0000) >> 16;
int A = (i & 0xFF000000) >> 24;
0699
  • 250
  • 2
  • 11