Get Color Brightness - CSharp System.Drawing

CSharp examples for System.Drawing:Color Brightness

Description

Get Color Brightness

Demo Code


using System.Windows.Media;
using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//  w w  w .ja v a2 s  .c o m

public class Main{
        public static float GetBrightness(this Color c)
      {
         byte minval = Math.Min(c.R, Math.Min(c.G, c.B));
         byte maxval = Math.Max(c.R, Math.Max(c.G, c.B));

         return (float)(maxval + minval) / 510;
      }
}

Related Tutorials