【发布时间】:2012-05-01 03:49:38
【问题描述】:
我在Quartz2D中使用“CGContextSetBlendMode”函数,但是我不明白“kCGBlendModeColorDodge”常量的含义。kCGBlendModeColorDodge的公式是什么?
【问题讨论】:
标签: ios graphics quartz-graphics
我在Quartz2D中使用“CGContextSetBlendMode”函数,但是我不明白“kCGBlendModeColorDodge”常量的含义。kCGBlendModeColorDodge的公式是什么?
【问题讨论】:
标签: ios graphics quartz-graphics
这是“颜色减淡”的公式:
// v1 and v2 are the RGBA pixel values for the two pixels
// "on top of each other" being blended
void someFunction(v1,v2) {
return Math.min(v1 + v2, 255);
}
来源是这个页面:
http://jswidget.com/blog/2011/03/11/image-blending-algorithmpart-ii/
编辑:
有两个闪避功能。一种是线性的,另一种是简单地称为“闪避”。以下是不同混合模式的更广泛列表:
How does photoshop blend two images together?
混合模式公式在此页面确认:
http://www.pegtop.net/delphi/articles/blendmodes/dodge.htm
...但在这个页面上,他们似乎通过颠倒公式来得到它:
http://www.simplefilter.de/en/basics/mixmods.html
您可能仍然需要找出特殊情况,并记住“1”实际上是“255”。
【讨论】:
尝试:
// t_component's range is [0...1]
t_component dodge_component(const t_component& a, const t_component& b) {
// note: saturate and limit to range
return a / (1.0 - b);
}
t_color dodge_color(const t_color& a, const t_color& b) {
t_color result;
for (each component in color_model) {
result.component[i] = dodge_component(a.component[i], b.component[i]);
}
return result;
}
【讨论】: