I have an UIImage and want to shift it\'s saturation about +10%. Are there standard methods or functions that can be used for this?
Here is an implementation of Bessey's hack (put this code in a UIImage category). It ain't fast and it definitely shifts hues, but it sort of works.
+ (CGFloat) clamp:(CGFloat)pixel
{
if(pixel > 255) return 255;
else if(pixel < 0) return 0;
return pixel;
}
- (UIImage*) saturation:(CGFloat)s
{
CGImageRef inImage = self.CGImage;
CFDataRef ref = CGDataProviderCopyData(CGImageGetDataProvider(inImage));
UInt8 * buf = (UInt8 *) CFDataGetBytePtr(ref);
int length = CFDataGetLength(ref);
for(int i=0; i
Anyone have any ideas on how to improve this without doing a full HSV conversion? Or better yet, a true implementation for:
- (UIImage*) imageWithHueOffset:(CGFloat)h saturation:(CGFloat)s value:(CGFloat)v