【问题标题】:What's the formula of kCGBlendModeColorDodgekCGBlendModeColorDodge的公式是什么
【发布时间】:2012-05-01 03:49:38
【问题描述】:

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

【问题讨论】:

    标签: ios graphics quartz-graphics


    【解决方案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”。

    【讨论】:

    • 从苹果“QuartzDemo”示例中,我们可以看到源颜色是黄色(RGB=110),目标颜色是蓝色(RGB=001),“kCGBlendModeColorDodge”的结果是蓝色(RGB=001) .如何解释:fileupyours.com/files/317337/abcde.png
    • 感谢Pedery,我发现“pegtop.net/delphi/articles/blendmodes/dodge.htm”的“反色闪避模式”可以解释QuartzDemo案例。非常感谢!
    • 可以吗?我自己对结果感到困惑,因为这不是我根据公式所期望的。为了仔细检查,我在 Photoshop 中做了同样的测试,它也像在 QuartzDemo 中一样混合在一起。
    • 是的,它可以。f(a,b) = b / (1 - a).(如果 b = 0 那么结果 = 0,不管“1-a”。如果 b ! = 0 和 1 - a = 0,然后结果 = 1)
    【解决方案2】:

    尝试:

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

    【讨论】:

      猜你喜欢
      • 2011-09-23
      • 1970-01-01
      • 2017-08-07
      • 1970-01-01
      • 2011-11-19
      • 1970-01-01
      • 1970-01-01
      • 2022-08-14
      • 1970-01-01
      相关资源
      最近更新 更多