2010-07-05 73 views
0

試圖用CIColorMap過濾器,但得到運行時錯誤「[NSImage中_feImage]:無法識別的選擇發送到實例0x100163b10」應用濾鏡CIColorMap過濾錯誤

當在調試之後,我看到了RTE發生在applyColorMap的最後一行(返回)被執行。我知道兩個(JPG)文件存在(imageIn和在函數內初始化的文件)。所以...任何想法,爲什麼我得到這個錯誤?

CIColorMap的文檔說:inputGradientImage =屬性類型爲CIAttributeTypeGradient並且其顯示名稱爲Gradient Image的CIImage類。是我的問題,因爲我沒有確定「屬性類型」?我會怎麼做?

我的代碼是這樣的...在主線:

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 
} 

回答

2

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

+0

OH ...對!謝謝! – Adam 2010-07-06 02:32:46