我正在使用这样的解决方案来掩盖我UIImage
的一些 alpha 绘图:
masking an UIImage
问题是稍后我想应用一些CIFilters
. 但是,当我更改过滤器的值时,我的 alpha 会从UIImage
. 每次修改 CIFilter 后,我是否必须重新应用 alpha 通道来输出图像?这肯定会使这个过程慢得多。
代码示例:(每个新段落都在另一种方法中)
// set the image
_image = [incomeImage imageWithMask:_mask]; // imageWithMask from method from link
[_myView.imageView setImage:_image];
// calculate ciimages
_inputCIImage = [[CIImage alloc] initWithCGImage:_image.CGImage options:nil];
_myView.imageView.image = _image;
_currentCIImage = _inputCIImage;
// change value in filter
[filter setValue:@(0.2f) forKey:@"someKey"];
[filter setValue:_inputCIImage forKey:kCIInputImageKey];
_currentCIImage = [filter outputImage];
CGImageRef img = [_context createCGImage:_currentCIImage fromRect:[_currentCIImage extent]];
UIImage *newImage = [UIImage imageWithCGImage:img];