I am trying to implement the vivid light color blend in code (I guess c# for now). I found two pages that say how to do it, but I don't understand their notation.
http://www.deepskycolors.com/archive/2010/04/21/formulas-for-Photoshop-blending-modes.html https://en.wikipedia.org/wiki/Blend_modes
Does anyone understand how to convert it into code? From my end, I have two Color objects with r, g, b values. Can anyone show the algorithm but using r, g, b values?
Thanks
Here is my non-working implementation:
using System;
using System.Drawing;
namespace CardMaker
{
class VividLight : ColorFilter
{
public override Color GetFilteredColor(Color p1, Color p2)
{
int newR = Math.Max(0, Math.Min(255, Convert.ToInt32(GetColor(p1.R, p2.R))));
int newG = Math.Max(0, Math.Min(255, Convert.ToInt32(GetColor(p1.G, p2.G))));
int newB = Math.Max(0, Math.Min(255, Convert.ToInt32(GetColor(p1.B, p2.B))));
return Color.FromArgb(newR, newG, newB);
}
private static double GetColor(int c1, int c2)
{
if (c2 > 128)
{
return 256 - ((256 - c1) / (512 * (c2 - 128)));
}
else
{
return c1 / (256 - 512 * c2);
}
}
}
}