我希望在绘制这张图的正确线条时具有模糊效果:

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

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

对我有什么想法吗?

问候,
亚历山大(Alexandre)

最佳答案

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];
使用此代码将给您模糊效果。

关于iphone - 使用Quartz 2D绘制时模糊效果,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19153121/

10-09 02:39