Search code examples
iosimage-processingxamarin.iosuiimagehue

Monotouch: Changing the Hue of an image, not just Saturation


I have the following MonoTouch code which can change the Saturation , but I am trying to also change the Hue.

float hue = 0;
float saturation = 1;

if (colorCtrls == null)
    colorCtrls = new CIColorControls() { 
                 Image = CIImage.FromCGImage (originalImage.CGImage) };
else
    colorCtrls.Image = CIImage.FromCGImage(originalImage.CGImage);

colorCtrls.Saturation = saturation; 

var output = colorCtrls.OutputImage;
var context = CIContext.FromOptions(null);
var result = context.CreateCGImage(output, output.Extent);

return UIImage.FromImage(result);

Solution

  • It's part of a different filter so you'll need to use CIHueAdjust instead of CIColorControls to control the hue.