我在我的應用中使用了一堆CIFilter
過濾器來調整亮度,飽和度等,它們工作正常。我遇到了一些與inputSharpness
有關的問題。如果我觸摸銳度滑塊,圖片就會消失。相關代碼:無法在UIImage上應用inputSharpness
UIImage *aUIImage = [imageView image];
CGImageRef aCGImage = aUIImage.CGImage;
aCIImage = [CIImage imageWithCGImage:aCGImage];
//Create context
context = [CIContext contextWithOptions:nil];
sharpFilter = [CIFilter filterWithName:@"CIAttributeTypeScalar" keysAndValues: @"inputImage", aCIImage, nil];
....
- (IBAction)sharpSliderChanged:(id)sender
{
//Set filter value
[sharpFilter setValue:[NSNumber numberWithFloat:sharpSlider.value] forKey:@"inputSharpness"];
//Convert CIImage to UIImage
outputImage = [sharpFilter outputImage];
CGImageRef cgimg = [context createCGImage:outputImage fromRect:[outputImage extent]];
newUIImage = [UIImage imageWithCGImage:cgimg];
CGImageRelease(cgimg);
//add image to imageView
[imageView setImage:newUIImage];
}
你是否檢查過你的outputImage是否爲零? – tiguero
圖像不是零,但是當我調試代碼時,我看到'sharpFilter \t CIFilter * 0x00000000'因此,尖銳的過濾器定義可能有些問題。 – Segev
你保留sharpFilter嗎? – tiguero