HEX to split RGB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get rid of '#' and convert it to integer | |
long int number = strtol(&command[0], NULL, 16); | |
// Split them up into r, g, b values | |
int red = number >> 16; | |
int green = number >> 8 & 0xFF; | |
int blue = number & 0xFF; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment