我正在对一个
尽管在稍微不同的上下文(Quartz Composer)中提到了这个问题here。苹果公司的
这是代码的相关部分(位于
如果我尝试使用像
我想知道是否有快速修复方法,而不需要深入研究
NSView
的内容进行快照,应用CIFilter
,并将结果放回到视图中。如果CIFilter
是一种模糊形式,例如CIBoxBlur
或CIGuassianBlur
,则过滤后的结果略小于原始大小。由于我要反复这样做,结果会变得越来越小,我想避免这种情况。尽管在稍微不同的上下文(Quartz Composer)中提到了这个问题here。苹果公司的
FunHouse
演示应用程序应用了Gaussian blur
而没有使图像缩小,但我还没有弄清楚这个应用程序是如何做到的(它似乎使用了我不熟悉的OpenGL
)。这是代码的相关部分(位于
NSView
子类内部):NSImage* background = [[NSImage alloc] initWithData:[self dataWithPDFInsideRect:[self bounds]]];
CIContext* context = [[NSGraphicsContext currentContext] CIContext];
CIImage* ciImage = [background ciImage];
CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"
keysAndValues: kCIInputImageKey, ciImage,
@"inputRadius", [NSNumber numberWithFloat:10.0], nil];
CIImage *result = [filter valueForKey:kCIOutputImageKey];
CGImageRef cgImage = [context createCGImage:result
fromRect:[result extent]];
NSImage* newBackground = [[NSImage alloc] initWithCGImage:cgImage size:background.size];
如果我尝试使用像
CISepiaTone
这样的颜色变换滤镜,它并不会改变像素的位置,那么缩小就不会发生。我想知道是否有快速修复方法,而不需要深入研究
openGL
?
CIImage *cropped=[output imageByCroppingToRect:CGRectMake(0, 0, view.bounds.size.width, view.bounds.size.height)]
- foundryCGImageRef cgImage = [context createCGImage:result fromRect:[**ciImage** extent]];)
因此,范围来自于原始图像而不是过滤器的输出。 - EarlyRiser