Monotouch:改变图像的色调,而不仅仅是饱和度

时间:2012-08-01 06:03:20

标签: ios image-processing xamarin.ios uiimage hue

我有以下MonoTouch代码,可以更改Saturation,但我也尝试更改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);

2 个答案:

答案 0 :(得分:1)

它是不同过滤器的一部分,因此您需要使用CIHueAdjust代替CIColorControls来控制色调。

答案 1 :(得分:1)

以下是我最后添加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);

但是,这对Retina设备无效,返回的图像缩放不正确。