gray scale a Color - CSharp System.Drawing

CSharp examples for System.Drawing:Color

Description

gray scale a Color

Demo Code


using Microsoft.Xna.Framework;
using System;/* w ww .j  a  v a 2  s  .  c o  m*/

public class Main{
        static public Color grayscale( this Color color )
      {
         return new Color( (int)( color.R * 0.3 + color.G * 0.59 + color.B * 0.11 ),
            (int)( color.R * 0.3 + color.G * 0.59 + color.B * 0.11 ),
            (int)( color.R * 0.3 + color.G * 0.59 + color.B * 0.11 ),
            color.A );
      }
}

Related Tutorials