Lighten Color - CSharp System.Drawing

CSharp examples for System.Drawing:Color

Description

Lighten Color

Demo Code


using System.Drawing;
using System;/*from   w w w.jav  a 2s.  com*/

public class Main{
    public static Color Lighten(Color color, int passes)
      {
         for (int i = 1; i <= passes; i++)
         {
            color = Lighten(color);
         }

         return color;
      }
    public static Color Lighten(Color color)
      {
         float correctionFactor = 0.5f;
         float red = (255 - color.R) * correctionFactor + color.R;
         float green = (255 - color.G) * correctionFactor + color.G;
         float blue = (255 - color.B) * correctionFactor + color.B;
         Color lighterColor = Color.FromArgb(color.A, (int)red, (int)green, (int)blue);
         return lighterColor;
      }
}

Related Tutorials