什么是kCGBlendModeColorDodge的公式

时间:2012-05-01 03:49:39

标签: ios graphics quartz-graphics

我在Quartz2D中使用“CGContextSetBlendMode”函数,但我不明白“kCGBlendModeColorDodge”常量的含义。什么是kCGBlendModeColorDodge的公式?

2 个答案:

答案 0 :(得分:1)

这是“颜色躲闪”的公式:

// 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'。

答案 1 :(得分:0)

尝试:

// 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;
}