本文介绍了如何在iOS中使用CIFilter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Apple说CIFilter在iOS中可用。但是,在我的Mac上,我找不到要链接的CoreImage框架。
Apple says that CIFilter is available in iOS. However, on my mac I couldn't find an CoreImage framework to link against.
@property(retain)CIFilter * filter
@property(retain) CIFilter *filter
即当我尝试执行类似操作时,由于CIFilter未知而崩溃:
i.e. when I try to do something like this, it crashes because CIFilter is unknown:
[transition setFilter:[CIFilter filterWithName:@"CIShapedWaterRipple"]];
我针对:
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import <CoreGraphics/CoreGraphics.h>
推荐答案
以下是我如何生成
- (UIImage*)sepia
{
CIImage *beginImage = [CIImage imageWithCGImage:[self CGImage]];
CIContext *context = [CIContext contextWithOptions:nil];
CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone"
keysAndValues: kCIInputImageKey, beginImage,
@"inputIntensity", [NSNumber numberWithFloat:0.8], nil];
CIImage *outputImage = [filter outputImage];
CGImageRef cgimg =
[context createCGImage:outputImage fromRect:[outputImage extent]];
UIImage *newImg = [UIImage imageWithCGImage:cgimg];
self = newImg;
CGImageRelease(cgimg);
return self;
}
这篇关于如何在iOS中使用CIFilter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!