gpt4 book ai didi

ios - 如何混合两个图像?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:33:08 25 4
gpt4 key购买 nike

我的 View 中有两张图片,我需要混合这两张图片。但问题是无法得到完美融合。

图像混合代码

CGSize newSize = CGSizeMake(_backGroundImage.frame.size.width, _backGroundImage.frame.size.height);
UIGraphicsBeginImageContext( newSize );
[_backGroundImage.image drawInRect:CGRectMake(_backGroundImage.frame.origin.x,_backGroundImage.frame.origin.y,_backGroundImage.frame.size.width,_backGroundImage.frame.size.height) blendMode:kCGBlendModeNormal alpha:1.0];
[_foreGroundImage.image drawInRect:CGRectMake(_foreGroundImage.frame.origin.x,_foreGroundImage.frame.origin.y,_foreGroundImage.frame.size.width,_foreGroundImage.frame.size.height) blendMode:kCGBlendModeColor alpha:0.5];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[_resultImage setImage:newImage ];

我也尝试了不同的混合模式,但无法获得结果。

enter image description here enter image description here

请帮我解决这个问题

最佳答案

请更改此行

[_foreGroundImage.image drawInRect:CGRectMake(_foreGroundImage.frame.origin.x,_foreGroundImage.frame.origin.y,_foreGroundImage.frame.size.width,_foreGroundImage.frame.size.height) blendMode:kCGBlendModeLighten alpha:0.5];

enter image description here

关于ios - 如何混合两个图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37495730/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com