问题
Is it possible to adjust Hue of the UIImage/CGContextRef? I have tried to blend Context with Color and Hue blend mode but result was wrong.
Should I convert RGB to HSB, adjust HSB and convert back?
回答1:
For iOS 5, you can use core image filter name CIHueAdjust.
CIHueAdjust filter
回答2:
I have found solution. I have simply converted color of each pixel to HSB, adjusted hue and converted back to RBG:
//convert to HSB
CGFloat h, s, l, a;
UIColor *color = [UIColor colorWithRed:r green:g blue:b alpha:1.0f];
[color getHue:&h saturation:&s brightness:&l alpha:&a];
//adjust hue
h *= amount;
//convert back to RGB
color = [UIColor colorWithHue:h saturation:s brightness:l alpha:1.0f];
[color getRed:&r green:&g blue:&b alpha:&a];
It is not fastest solution but it is simple
来源:https://stackoverflow.com/questions/8493231/ios-adjust-hue-of-uiimage