作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试生成 CIGaussianGradient 但我在控制台中得到了空闲输出
012-08-03 16:45:10.423 OGL[2882:303] *** Assertion failure in -[NSBitmapImageRep initWithCIImage:], /SourceCache/AppKit/AppKit-1187/AppKit.subproj/NSBitmapImageRep.m:1531
2012-08-03 16:45:10.425 OGL[2882:303] An uncaught exception was raised
2012-08-03 16:45:10.427 OGL[2882:303] <CIImage: 0x400353620> {
FEPromise: 0x4007106e0 extent: infinite; filter CIGaussianGradient: 0x4001ecde0; kernel gaussianDot; center [150 150] color0 <CGColor 0x40021b6e0> [<CGColorSpace 0x400417ca0> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; Generic RGB Profile)] ( 1 1 1 0 ) color1 <CGColor 0x400236180> [<CGColorSpace 0x400417ca0> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; Generic RGB Profile)] ( 0 0 0 1 ) radius_recip 0.00333333
} parameter to -initWithCIImage: is not of finite extent
CIFilter *F = [CIFilter filterWithName:@"CIGaussianGradient"];
[F setDefaults];
[F setValue:[CIColor colorWithRed:1 green:1 blue:1 alpha:0] forKey:@"inputColor0"];
[F setValue:[CIColor colorWithRed:0 green:0 blue:0 alpha:1] forKey:@"inputColor1"];
CIImage *Fimg = [F valueForKey:@"outputImage"];
NSBitmapImageRep *FBitmap = [[NSBitmapImageRep alloc] initWithCIImage:Fimg];
最佳答案
无限平面的一部分必须被裁剪为图像。
见:An example use of CIGaussianGradient filter for Core Image
在下面的示例中,创建了一个 600 x 600 的图像。
示例:
// create a CIImage and apply the filter
CIImage *theCIImage = [[CIImage alloc] init];
theCIImage = [CIFilter filterWithName:@"CIGaussianGradient" keysAndValues:@"inputCenter", centerVector, @"inputColor0", color0, @"inputColor1", color1, @"inputRadius", radius, nil].outputImage;
// crop the image using CICrop
CGRect rect = CGRectMake(0.0, 0.0, 600.0, 600.0);
theCIImage = [CIFilter filterWithName:@"CICrop" keysAndValues:kCIInputImageKey, theCIImage, @"inputRectangle", rect, nil].outputImage;
NSBitmapImageRep *FBitmap = [[NSBitmapImageRep alloc] initWithCIImage:theCIImage];
关于objective-c - CIGaussian梯度失效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11797082/
我是一名优秀的程序员,十分优秀!