Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 使用石英2D绘制时的模糊效果_Iphone_Ios_Ipad_Core Graphics_Quartz Graphics - Fatal编程技术网

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