我的应用程序中有一个图像视图,并且我从手机照片库中加载了图像。现在我想对这张图片应用效果,但我写的代码给了我错误。我的代码如下。任何帮助将不胜感激。
CIImage *beginImage =
[CIImage imageWithContentsOfURL:self.imageView.image];
// 1
CIContext *context = [CIContext contextWithOptions:nil];
CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone"
keysAndValues: kCIInputImageKey, beginImage,
@"inputIntensity", @0.8, nil];
CIImage *outputImage = [filter outputImage];
// 2
CGImageRef cgimg =
[context createCGImage:outputImage fromRect:[outputImage extent]];
// 3
UIImage *newImage = [UIImage imageWithCGImage:cgimg];
self.imageView.image = newImage;
// 4
CGImageRelease(cgimg);