CIColorMap过滤器错误 [英] CIColorMap filter error

查看:258
本文介绍了CIColorMap过滤器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用CIColorMap过滤器,但在应用过滤器时遇到运行时错误[NSImage _feImage]:无法识别的选择器发送到实例0x100163b10

Trying to use CIColorMap filter, but getting run-time error "[NSImage _feImage]: unrecognized selector sent to instance 0x100163b10" when applying the filter

调试器,我看到RTE发生时,执行applyColorMap的最后一行(返回)。我知道(JPG)文件存在(imageIn和一个初始化的函数内)。所以...任何想法为什么我得到这个错误???

Following in the debugger, I see the RTE happens when the last line (return) of applyColorMap is executed. I know both of the (JPG) files exist (imageIn and the one initialized within the function). So ... any idea why I'm getting this error???

CIColorMap的文档说:inputGradientImage =属性类型为CIAttributeTypeGradient的CIImage类,其显示名称是渐变图像。是我的问题,因为我没有识别属性类型?

The doc for CIColorMap says: inputGradientImage = A CIImage class whose attribute type is CIAttributeTypeGradient and whose display name is Gradient Image. Is my issue because I have not identified the "attribute type"? How would I do that?

我的代码是这样的...在主行:

My code is like this ... in the main line:

    CIImage *myResult = [self applyColorMap: inputCIimage];

然后被调用的函数是:

- (CIImage*) applyColorMap: (CIImage*)imageIn {
    // Convert imageIn to B&W by using a gradient image half white / half black
    NSString *gradientFP = [[NSString alloc] initWithString:[self myFilepath:
                                                         [NSString stringWithString:@"WB-1x20.jpg"]]];
    NSImage *colormapImage = [[NSImage alloc] initWithContentsOfFile:gradientFP];
    if (colormapImage == nil) {
        NSLog (@"Bailing out.  Gradient image allocation was NOT successful.");
        return nil;
    }
    CIFilter *colorMapFilter = [CIFilter filterWithName:@"CIColorMap"];
    //[colorMapFilter setDefaults];
    [colorMapFilter setValue:imageIn forKey:@"inputImage"];
    [colorMapFilter setValue:colormapImage forKey:@"inputGradientImage"];
    return [colorMapFilter valueForKey:@"outputImage"];  //apply filter and return the new image
}


推荐答案

colormapImage 需要是 CIImage ,而不是 NSImage ,IIRC。

colormapImage needs to be a CIImage and not an NSImage, IIRC.

这篇关于CIColorMap过滤器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆