Last active
December 25, 2015 06:19
-
-
Save fclairamb/6931438 to your computer and use it in GitHub Desktop.
RGB 24 --> 16 bits
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
def rgb16(r, g, b): | |
r = (r & 255) >> 3 # RED (5 bits) | |
g = (g & 255) >> 2 # GREEN (6 bits) | |
b = (b & 255) >> 3 # BLUE (5 bits) | |
c = (r << (6+5)) | (g << 5) | b | |
return "0x{0:04x}".format(c) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment