gpt4 book ai didi

objective-c - CIGaussian梯度失效

转载 作者:行者123 更新时间:2023-12-04 05:37:00 30 4
gpt4 key购买 nike

我尝试生成 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/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com