【问题标题】:xcode5: How to use the built in Core Image filters?xcode5:如何使用内置的 Core Image 过滤器?
【发布时间】:2014-05-19 20:39:13
【问题描述】:

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

这是我要添加的过滤器。谁能给我这个过滤器的代码?

希望有人可以帮助我。

【问题讨论】:

    标签: core-image ciimage


    【解决方案1】:

    观察下面的代码...

    //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);
    

    好教程Beginning Core Image

    【讨论】:

    • 我要为 ,,origim 添加什么?什么是 data3?
    • origim 是 uiimage,data3 是 nsdata
    猜你喜欢
    • 2012-05-27
    • 2015-11-11
    • 2012-11-18
    • 1970-01-01
    • 2011-12-23
    • 2018-08-15
    • 2022-01-26
    • 2012-02-12
    • 1970-01-01
    相关资源
    最近更新 更多