如何混合两个图像?

在我看来,我有两个图像,我需要混合这两个图像。 但问题是无法得到完美的融合。

代码为图像混合

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 ]; 

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

在这里输入图像说明 在这里输入图像说明

请帮我解决这个问题

请更改此行

 [_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]; 

在这里输入图像说明