//Get a UIImage from the UIVIEw UIGraphicsBeginImageContext(self.vIEw.bounds.size); [self.vIEw.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *vIEwImage = UIGraphicsGetimageFromCurrentimageContext(); UIGraphicsEndImageContext(); //Blur the UIImage CIImage *imagetoBlur = [CIImage imageWithCGImage:vIEwImage.CGImage]; CIFilter *gaussianBlurFilter = [CIFilter filterWithname:@"CIGaussianBlur"]; [gaussianBlurFilter setValue:imagetoBlur forKey:@"inputimage"]; [gaussianBlurFilter setValue:[NSNumber numberWithfloat:2] forKey:@"inputRadius"]; CIImage *resultimage = [gaussianBlurFilter valueForKey:@"outputimage"]; UIImage *endImage = [[UIImage alloc] initWithCIImage:resultimage]; //Place the UIImage in a UIImageVIEw newVIEw = [[UIImageVIEw alloc] initWithFrame:self.vIEw.bounds]; newVIEw.image = endImage; [self.vIEw addSubvIEw:newVIEw];
它工作得很好,但我希望能够将其反转并使视图恢复正常.
我怎么能这样做,因为试图简单地从它的超视图中移除模糊的视图不起作用.我也尝试过将各种属性设置为零而没有运气.
解决方法 在属性中保留指向vIEwImage的指针@property (nonatomic,strong) UIImage* originalimage;
然后
UIImage *vIEwImage = UIGraphicsGetimageFromCurrentimageContext();
加
self.originalimage = vIEwImage;
要还原您的图像:
newVIEw.image = self.originalimage;
当你应用模糊时它不会改变vIEwImage ..你创建了一个单独的CIImage,它变得模糊,你从模糊的CIImage中创建一个新的UIImage.
总结以上是内存溢出为你收集整理的高斯模糊滤镜逆转:iOS全部内容,希望文章能够帮你解决高斯模糊滤镜逆转:iOS所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)