iOS - adjust hue of UIImage
-
15-03-2021 - |
Question
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?
Solution
For iOS 5, you can use core image filter name CIHueAdjust.
OTHER TIPS
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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow