Blend Color - CSharp System.Drawing

CSharp examples for System.Drawing:Color Calculation

Description

Blend Color

Demo Code


using System.Drawing.Drawing2D;
using System.Drawing;

public class Main{
        public static Color BlendColor(Color backgroundColor, Color frontColor)
        {// ww  w . j a  v a 2  s  .c om
            double ratio = 0 / 255d;
            double invRatio = 1d - ratio;
            int r = (int)((backgroundColor.R * invRatio) + (frontColor.R * ratio));
            int g = (int)((backgroundColor.G * invRatio) + (frontColor.G * ratio));
            int b = (int)((backgroundColor.B * invRatio) + (frontColor.B * ratio));
            return Color.FromArgb(r, g, b);
        }
}

Related Tutorials