问题描述
嘿,我一直在使用一些过滤器。并非所有这些似乎都能正常工作,例如CISepiaTone和CIHueAdjust。
最近我尝试了CIGLoom过滤器,它返回一个空图像。
Hey all i've been using some filters. Not all of them seem to work normally like say for example CISepiaTone and CIHueAdjust.recently i tried CIGLoom filter and it returns a null image.
-(UIImage*)getGloom:(UIImage*)anImage{
CGImageRef cgimage = anImage.CGImage;
CIImage *cimage = [CIImage imageWithCGImage:cgimage];
CIFilter *filter = [CIFilter filterWithName:@"CIGloom"];
[filter setDefaults];
[filter setValue: cimage forKey: @"inputImage"];
[filter setValue: [NSNumber numberWithFloat: 25]
forKey: @"inputRadius"];
[filter setValue: [NSNumber numberWithFloat: 0.75]
forKey: @"inputIntensity"];
CIContext *context = [CIContext contextWithOptions:nil];
CIImage *ciimage = [filter outputImage];
CGImageRef cgimg = [context createCGImage:ciimage fromRect:[ciimage extent]];
UIImage *uimage = [UIImage imageWithCGImage:cgimg scale:1.0f orientation:UIImageOrientationUp];
CGImageRelease(cgimg);
return uimage; }
我实际上从今年的techtalk世界巡演中得到了这个代码,它适用于CISepiaTone但它只是没有为cigloom。 cicolorposterize,ciedges和其他一些。任何人都知道为什么?或者如何绕过这个NUll IMAGE?
i actually got this code from the techtalk world tour this year and it works for CISepiaTone but it just fails for cigloom. cicolorposterize, ciedges and some others. Anyone got any idea why? or how to get around this NUll IMAGE?
推荐答案
CIGloom和其他你遇到过问题的人都不受支持在iOS上。可以检查其过滤您有可用使用这种阵列的结果:
CIGloom, and others you've been having problems with, aren't supported yet on iOS. You can check which filters you have available using this array result:
NSArray *supportedFilters = [CIFilter filterNamesInCategory:kCICategoryBuiltIn];
这篇关于CIFilter无法正常工作,返回null图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!