Question

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);
Was it helpful?

Solution

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

OTHER TIPS

Here's what I ended up doing to add Hue:

        var hueAdjust = new CIHueAdjust() {
            Image = CIImage.FromCGImage(originalImage.CGImage),
            Angle = hue // Default is 0
        };
        var output = hueAdjust.OutputImage;
        var context = CIContext.FromOptions(null);
        var cgimage = context.CreateCGImage(output, output.Extent);
        return UIImage.FromImage(cgimage);

However, this does not work on Retina devices, the image returned is scaled incorrectly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top