ios – 在Objective C中,我们如何以圆形圆形形状模糊脸部?

ios – 在Objective C中,我们如何以圆形圆形形状模糊脸部?,第1张

概述我在iOS应用程序上工作,我从图像和模糊的脸检测脸,我已经实现了矩形的模糊面,但我需要的是模糊圆形的脸.我试过的是 -(void)markAfterFaceDetect:(NSArray *)features{ for (CIFaceFeature *f in features) { CGRect aRect = f.bounds; NSLo 我在iOS应用程序上工作,我从图像和模糊的脸检测脸,我已经实现了矩形的模糊面,但我需要的是模糊圆形的脸.我试过的是

-(voID)markAfterFaceDetect:(NSArray *)features{    for (CIFaceFeature *f in features)    {        CGRect aRect = f.bounds;        NSLog(@"here is the height of h %f",aRect.size.height);        // aRect.size.height=aRect.size.height+10;        aRect.origin.y = self.vIEwShow.bounds.size.height - aRect.size.height - aRect.origin.y;        NSLog(@"Height Of the Image Is : == %f",_imageVIEw.image.size.height);        //self.bounds.size        rectFaceDetect = aRect;        UIVisualEffect *blurEffect;        blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStylelight];        UIVisualEffectVIEw *visualEffectVIEw;        visualEffectVIEw = [[UIVisualEffectVIEw alloc] initWithEffect:blurEffect];        visualEffectVIEw.frame = vv.frame;        //visualEffectVIEw.layer.cornerRadius = visualEffectVIEw.frame.size.height/2;        visualEffectVIEw.Alpha =0.96;        visualEffectVIEw.tag = markVIEwTag;        // [self.imageVIEw addSubvIEw:visualEffectVIEw];        CAShapeLayer *mask = [CAShapeLayer layer];        mask.path = [UIBezIErPath bezIErPathWithovalInRect:visualEffectVIEw.bounds].CGPath;        visualEffectVIEw.layer.mask = mask;    }}

使用这种方式我已经设法模糊圆形或圆形的脸,但当我拍摄视图的屏幕截图以保存应用程序数据库中的模糊图像时,其Alpha变为0并且模糊区域变得可见,我用于截取屏幕截图的代码是

CGRect rect = vIEwShow.frame;UIGraphicsBeginImageContext(rect.size);CGContextRef context = UIGraphicsGetCurrentContext();[vIEwShow.layer renderInContext:context];UIImage *img = UIGraphicsGetimageFromCurrentimageContext();UIGraphicsEndImageContext();

这是截图前后的图像

Now i have used this Category and Achieved this Blur in Rectangular form Image is Attached

现在我有两个问题.
1-如何仅将脸部模糊成圆形或圆形?
2-当我以编程方式截取屏幕时,为什么Alpha变为0.

期望的模糊将如下所示

我们将非常感谢您的帮助.

解决方法 使用 drawViewHierarchyInRect:afterScreenUpdates:捕获视图层次结构的屏幕外观. 总结

以上是内存溢出为你收集整理的ios – 在Objective C中,我们如何以圆形/圆形形状模糊脸部?全部内容,希望文章能够帮你解决ios – 在Objective C中,我们如何以圆形/圆形形状模糊脸部?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1027221.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-23
下一篇2022-05-23

发表评论

登录后才能评论

评论列表(0条)

    保存