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

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

CIColorMap的文档说:inputGradientImage =一个CIImage类,其属性类型为CIAttributeTypeGradient并且其显示名称为Gradient Image。我的问题是因为我没有确定“属性类型”吗?我该怎么做?

我的代码在主行中是这样的……

    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。

关于cocoa - CIColorMap滤镜错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3182711/

10-11 15:51