本文介绍了如何在iPhone操作系统中使用CIFilter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apple说CIFilter在iPhone操作系统中可用。然而,在我的mac上我找不到一个CoreImage框架来链接。

Apple says that CIFilter is available in iPhone OS. However, on my mac I couldn't find an CoreImage framework to link against.

@property(retain)CIFilter * filter

@property(retain) CIFilter *filter

ie当我尝试做这样的事情,它崩溃,因为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>


推荐答案

下面是一个例子,使用CIFilter在iPhone上过滤UIImage。

The following is an example of how I am generating a filtered UIImage on the iPhone using a CIFilter.

- (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;
}

这篇关于如何在iPhone操作系统中使用CIFilter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 13:55