开发者

CIColorMap filter error

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

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???

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];

Then the function being called is:

- (CIImage*) applyColorMap: (CIImage*)imageIn {
    // Convert imageIn to B&W by using a gradient image half white / half bl开发者_StackOverflow社区ack
    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 needs to be a CIImage and not an NSImage, IIRC.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜