I have a decimal color code (eg: 4898901
). I am converting it into a hexadecimal equivalent of that as 4ac055
. How to get the red, green and blue component value from the hexadecimal color code?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How can I create this custom Bottom Navigation on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
I'm not sure about your exact need. However some tips.
Integer class can transform a decimal number to its hexadecimal representation with the method:
To get the RGB you can use the class Color:
If you have a string this way is a lot nicer:
If you have a number then do it this way:
Then of course to get the colours you just do:
Assuming this is a string:
When you have the
hex-code : 4ac055
. The first two letters are the color red. The next two are green and the two latest letters are for the color blue. So When you have the hex-code of the color red you must convert it to dez back. In these example wherered 4a = 74
.Green c0 = 192
andblue = 85
..Try to make a function which split the
hexcode
and then give back thergb
code