0

我是开发 iOS 应用程序的新手。我想在我的应用程序中使用内置的核心图像过滤器。但我不知道如何使用它们。我已经创建了“CISephiaTon”过滤器。现在我想创建“CIPhotoEffectTransfer”过滤器。但我不知道我该怎么做=(有没有人知道一个很好的教程或者可以给我一个在 xcode 5 中应用核心图像过滤器的教程?

这是我要添加的过滤器。有人可以给我这个过滤器的代码吗?

希望可以有人帮帮我。

4

1 回答 1

0

观察下面的代码...

//First create a CIImage
UIImageOrientation originalOrientation = origim.imageOrientation;
data3 = UIImagePNGRepresentation(origim);
CIImage *result = [CIImage imageWithData:data3];

//Create the context
CIContext *context = [CIContext contextWithOptions:nil];

Apply the filter
CIFilter *colorControlsFilter = [CIFilter filterWithName:@"CIColorControls"];
    [colorControlsFilter setDefaults];
    [colorControlsFilter setValue:result forKey:@"inputImage"];
    [colorControlsFilter setValue:[NSNumber numberWithFloat:slySlider1.value] forKey:@"inputSaturation"];
    result = [colorControlsFilter valueForKey: @"outputImage"];

//Create CGImage with the original orientation, CIImage, and context.
CGImageRef imgRef = [context createCGImage:result fromRect:result.extent];

    //Create the new UIImage from CGImage
    theimage.image = [[UIImage alloc] initWithCGImage:imgRef scale:1.0 orientation:originalOrientation];
    //Release CGImageRef
    CGImageRelease(imgRef);

很好的教程开始核心图像

于 2014-04-08T04:42:48.977 回答