Xcode:使用核心图像与alpha合成 [英] Xcode: compositing with alpha using core image

查看:135
本文介绍了Xcode:使用核心图像与alpha合成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个CoreImage过滤器链,并且能够通过将其各自的效果与alpha或不透明度设置合成来控制链中每个过滤器的强度,但我没有找到方法在文档中使用alpha或opacity进行复合。

I'd like to create a CoreImage filter chain, and to be able to control the "intensity" of each filter in the chain by compositing its individual effect with alpha, or opacity settings, but I am not seeing a way to composite with alpha or opacity in the docs.

我猜可以跳出核心图像过滤器链和复合核心图形上下文。

I could jump out of Core image filter chain and composite with a core graphics context I guess.

推荐答案

结束这样做。此答案的代码: https://stackoverflow.com/a/3188761/1408546

Ended up doing it like this. Code from this answer: https://stackoverflow.com/a/3188761/1408546

UIImage *bottomImage = inputImage;
UIImage *image = filterOutput;
CGSize newSize = CGSizeMake(inputImage.size.width, inputImage.size.height);
UIGraphicsBeginImageContext( newSize );
[bottomImage drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height) blendMode:kCGBlendModeNormal alpha:_opacity];
UIImage *blendedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

这篇关于Xcode:使用核心图像与alpha合成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆