2017-04-16 56 views
0

我创建了一个绘图模块,可以在其中绘制背景图像。 “图纸”是一个透明的PNG,当我保存图像时,我将它合并在一起。iOS保存组合图像

但是,这里的问题是,对比度有时不好看(见下图)。

之前(油漆模式):

enter image description here

后(生病时乘两个图像):

enter image description here

(很难看到任何黄色)。

我乘以两个图像:

UIGraphicsBeginImageContextWithOptions(size, false, 0.0) 
    bottomImage!.draw(in: CGRect(x: 0,y: 0,width: size.width, height: size.height)) 
    topImage!.draw(in: CGRect(x: 0,y: 0,width: size.width, height: size.height), blendMode: CGBlendMode.multiply , alpha: 1.0) 
    combinedImage = UIGraphicsGetImageFromCurrentImageContext() 
    UIGraphicsEndImageContext() 

任何想法我如何能得到更好的颜色?

+0

你为什么使用'.multiply'?这似乎很愚蠢。 – matt

+0

我想结合两个图像的内容。还有什么不该用的? – derdida

+0

那么,有[CGBlendMode的文档](https://developer.apple.com/reference/coregraphics/cgb​​lendmode)。如果你只是想合并它们,'.normal'似乎是一个明显的选择。 – DarkDust

回答

1

剪下关于混合模式的部分。只需将“绘画”(topImage)直接绘制到背景上(bottomImage)即可。

+0

啊,这很容易 - 生病猜猜我用“白色”背景(而不是一个明确的PNG作为顶部图像)绘制时使用繁殖 - 然后我需要繁殖(当然) - 感谢您的答案! – derdida