i have a ColorPicker in my Android App and i want to control LEDs, so i need the colors seperatly in byte[1]= Red; byte[2]= Green; byte[3]= Blue to send the colors. But the Color Picker provides the Colors by a method (get.color()) in this format: 0xFF00FF00. Ho can i divide this output to three different byte arrays? Thank you!
Asked
Active
Viewed 74 times
1
-
And FF is wich color? Why giving such a confusing example? And that integer is four bytes. And not four byte arrays. – blackapps Sep 13 '20 at 14:18
-
You can also send those the bytes of that integer. The receiver can then pick the right byte if needed. – blackapps Sep 13 '20 at 14:20
-
Further get.color() will return an integer. Not a hexadecimal notation of that integer value. – blackapps Sep 13 '20 at 14:21
1 Answers
0
To get the int value of a hex-string use hex-integer
for example this will print out -16711936:
int val = Long.decode("0xff00ff00").intValue();
System.out.println(val);
also this might help:

narcis dpr
- 939
- 2
- 12
- 32