2

我想在绘制这张图片中的右线时具有模糊效果:

模糊效果

目前,我正在使用以下代码进行绘图,但这仅在左侧绘制图片:

CGContextSetLineWidth(currentContext, thickness);    
CGContextSetLineCap(currentContext, kCGLineCapRound);
CGContextBeginPath(currentContext);
CGContextMoveToPoint(currentContext, x, y);
CGContextAddLineToPoint(currentContext, x, y);
CGContextMoveToPoint(currentContext, x, y);
CGContextStrokePath(currentContext);

请问有什么想法吗?

问候, 亚历山大

4

1 回答 1

2
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];

使用此代码,这会给你带来模糊的效果。

于 2013-10-03T07:34:57.720 回答