How can you convert a RGB color to an 8 bit (0-255) color (for a Limitless LED light bulb) in objective c? so output is in the format (0-255), convert from 16777216 to 256 in hex, instead of range 000000-FFFFFF, to range 00-FF
NSString *output = nil;
NSColor *color = [[self.colorWell color] colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
double redFloatValue, greenFloatValue, blueFloatValue;
[color getRed:&redFloatValue green:&greenFloatValue blue:&blueFloatValue alpha:NULL];
int redIntValue, greenIntValue, blueIntValue;
redIntValue = redFloatValue * 255;
greenIntValue = greenFloatValue * 255;
blueIntValue = blueFloatValue * 255;
output = [NSString stringWithFormat:@"#%02x%02x%02x", redIntValue, greenIntValue, blueIntValue];
NSLog(@"%@", output);
With a color well when you open a color picker, you can pick 16,8 million colors which I need to translate to 256 colors.
This is a discussion of the colors from http://limitlessled.com/dev
Byte2: Color Matrix Chart: (thanks Stephan Schaade, http://knx-user-forum.de http://mknx.github.io/smarthome/)
note there are more colours (0-255) in between, this color chart is just steps of 16.
0x00 Violet
0x10 Royal_Blue
0x20 Baby_Blue
0x30 Aqua
0x40 Mint
0x50 Seafoam_Green
0x60 Green
0x70 Lime_Green
0x80 Yellow
0x90 Yellow_Orange
0xA0 Orange
0xB0 Red
0xC0 Pink
0xD0 Fusia
0xE0 Lilac
0xF0 Lavendar