¿Existe una manera fácil (o una biblioteca incorporada) en iOS 5.x de desaturar un UIImage? Aquí está cómo lo estoy haciendo actualmente:¿Cómo desaturo un UIImage?
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextTranslateCTM(context, 0.0, self.bounds.size.height); // flip image right side up
CGContextScaleCTM(context, 1.0, -1.0);
CGContextDrawImage(context, rect, self.image.CGImage);
CGContextSetBlendMode(context, kCGBlendModeSaturation);
CGContextClipToMask(context, self.bounds, image.CGImage); // restricts drawing to within alpha channel
CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, desaturation);
CGContextFillRect(context, rect);
CGContextRestoreGState(context); // restore state to reset blend mode
Esto parece ser un poco más complicado de lo que esperaba. ¿Hay una manera más simple que esto?
Estaba pensando en Core Image, pero parece que no puedo encontrar un ejemplo concreto sobre cómo desaturar una imagen usando eso.
No estoy seguro, pero posiblemente podría intentar aplicar [CIFilter] (http://developer.apple.com/library/ios/#DOCUMENTATION/GraphicsImaging/Reference/QuartzCoreFramework/Classes/CIFilter_Class/Reference/Reference.html) de [kCICategoryColorEffect] (http://developer.apple.com/library/ios/DOCUMENTATION/GraphicsImaging/Reference/QuartzCoreFramework/Classes/CIFilter_Class/Reference/Reference.html#//apple_ref/doc/c_ref/kCICategoryColorEffect) tipo. Demostración rápida de cómo aplicar CIFilter: http://iazapps.wordpress.com/2012/02/01/applying-cifilter-on-image-in-an-uiimageview/ –
¿cuál es su valor para la desaturación? – malhal
indiekiduk, ese código aparece en más contexto en una respuesta aquí: http://stackoverflow.com/questions/1144768/how-can-i-change-the-saturation-of-an-uiimage (la desaturación es un ivar en el ejemplo). – JLundell