Iphone 使用石英2D绘制时的模糊效果
我希望在绘制时具有模糊效果,如图中的右线: 目前,我使用以下代码进行绘制,但这仅绘制左侧的图片:Iphone 使用石英2D绘制时的模糊效果,iphone,ios,ipad,core-graphics,quartz-graphics,Iphone,Ios,Ipad,Core Graphics,Quartz Graphics,我希望在绘制时具有模糊效果,如图中的右线: 目前,我使用以下代码进行绘制,但这仅绘制左侧的图片: CGContextSetLineWidth(currentContext, thickness); CGContextSetLineCap(currentContext, kCGLineCapRound); CGContextBeginPath(currentContext); CGContextMoveToPoint(currentContext, x, y); CGContextAdd
CGContextSetLineWidth(currentContext, thickness);
CGContextSetLineCap(currentContext, kCGLineCapRound);
CGContextBeginPath(currentContext);
CGContextMoveToPoint(currentContext, x, y);
CGContextAddLineToPoint(currentContext, x, y);
CGContextMoveToPoint(currentContext, x, y);
CGContextStrokePath(currentContext);
有什么想法吗
问候,,
亚历山大
使用此代码,这将为您提供模糊效果。谢谢您的回答,但我希望使用模糊效果进行绘制,而不是在UIImage上应用效果。绘制后,在CIImage中渲染该效果
imageWithCGImage:
如果需要,可以使用fromRect:[InputImageExtent]
。这可以确保blurrImage
与inputImage
的大小相同。使用[结果范围]
可能导致图像大小缩小。
CIContext *context = [CIContext contextWithOptions:nil];
CIImage *inputImage = [[CIImage alloc] initWithImage:@"your image"];
CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"];
[filter setValue:inputImage forKey:kCIInputImageKey];
[filter setValue:[NSNumber numberWithFloat:9.0f] forKey:@"inputRadius"];
CIImage *result = [filter valueForKey:kCIOutputImageKey];
CGImageRef cgImage = [context createCGImage:result fromRect:[result extent]];
UIImage *blurrImage = [UIImage imageWithCGImage:cgImage];