i try to do method which takes B(brightness) from UIColor.
problem is in second part of method. when i log result bri is equal to _red. Where's problem?
-(void)rgbToHSBWithR:(float)_red G:(float)_green B:(float)_blue {
_red = _red / 255.0;
_green = _green / 255.0;
_blue = _blue / 255.0;
UIColor *color = [UIColor colorWithRed:_red green:_green blue:_blue alpha:1];
float hue, sat, bri, alpha;
[color getHue:&hue saturation:&sat brightness:&bri alpha:&alpha];
NSLog(@"R: %f, G: %0.2f, B: %0.2f, V: %f", _red, _green, _blue, bri);
}
answer is:
b = (red / 255.0) * 0.3 + (green / 255.0) * 0.59 + (blue / 255.0) * 0.11;
it's working fine.