2

I have a colorpicker dialog, where you can choose colors for a button, textcolor etc. If I log the choosen color, I get a -13459125 number which I dont know what RGB color is. I see that it's a 24-bit color code because 256*256*256 color can be selected, but how can I convert it to a format where I can define its RGB codes? I am not sure why it is negative either...

Jani Bela
  • 1,660
  • 4
  • 27
  • 50

1 Answers1

6

Its packed 4-bytes to an integer as 0xAARRGGBB

Your value (-13459125), is 0xFF32A14B, or

A=255 R=50 G=161 B=75 in decimal.

If you have a color c, you can get the components with:

int red = Color.red(c)
int green = Color.green(c)

Etc

Tim
  • 35,413
  • 11
  • 95
  • 121
  • I almost started to add 2^24 to it then put it into an online hexadec-dec converter, but you made my day with this. Thank! – Jani Bela May 28 '12 at 18:31