0
我有一张图像,我正尝试将堆叠模糊应用于并希望从我创建的.png文件应用一个屏蔽以查看下面的清晰图像。我需要下面的图片才能在给定时间更改,但blurView和mask保持静态。这是我正在使用的代码,但我没有在模糊中看到蒙版图像。将屏蔽应用于iOS中的blurView
- (void)viewDidLoad
{
[super viewDidLoad];
UIImageView *imageview = [UIImageView new];
[imageview setFrame:[self.view bounds]];
[imageview setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
[imageview setImage:[UIImage imageNamed:@"myImage.jpg"]];
[imageview setContentMode:UIViewContentModeScaleAspectFill];
[self.view addSubview:imageview];
[self setBlurView:[AMBlurView new]];
[[self blurView] setFrame:CGRectMake(0.f, 0.f, [self.view bounds].size.width, [self.view bounds].size.height)];
[[self blurView] setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
[self.view addSubview:[self blurView]];
imageview.image = [self maskImage:imageview.image withMask:[UIImage imageNamed:@"mask"]];
}
- (UIImage*) maskImage:(UIImage *)image withMask:(UIImage *)maskImage {
CGImageRef imgRef = [image CGImage];
CGImageRef maskRef = [maskImage CGImage];
CGImageRef actualMask = CGImageMaskCreate(CGImageGetWidth(maskRef),
CGImageGetHeight(maskRef),
CGImageGetBitsPerComponent(maskRef),
CGImageGetBitsPerPixel(maskRef),
CGImageGetBytesPerRow(maskRef),
CGImageGetDataProvider(maskRef), NULL, false);
CGImageRef masked = CGImageCreateWithMask(imgRef, actualMask);
return [UIImage imageWithCGImage:masked];
}
这是很多比我更需要。我仍然对开发非常陌生,并且只是从.png中屏蔽blurView的效果。我在这里找到了这个项目[https://github.com/NickTitle/iOS7-Trans-Blur],但它涉及到使用一个滑块来达到这个效果,并且在一整天之后,我仍然无法将它解压缩到我不幸的是需要什么。 –
我正在尝试创建UIImage的静态过滤器,它由高斯模糊效果和alpha遮罩组成。这样除了mask.png中提供的蒙版形状以外,整个图像都会模糊不清。如果你看这里:[https://github.com/JagCesar/iOS-blur]这几乎正是我想要做的,但我想在模糊的矩形中切出一个面具 –
不。在模糊的矩形内我想从我的PNG文件中删除一个形状,所以它就像一个窗口 –