CSharp examples for System.Drawing:Color RGB
Gets the saturation value from an RGB
using Microsoft.Xna.Framework; using System;/*from ww w .java 2 s . co m*/ public class Main{ /// <summary> /// Gets the saturation value from an RGB /// </summary> /// <param name="R">Red</param> /// <param name="G">Green</param> /// <param name="B">Blue</param> /// <returns></returns> public static double getSat(int R, int G, int B) { double C; double alph = 0.5*(2*R-(G+B)); double beta = Math.Sqrt(3)*0.5*(G-B); C = Math.Sqrt(Math.Pow(alph,2) + Math.Pow(beta,2)); if(C==0) return 0; return (C/ getVal(R,G,B)); } }