Color To HSV value - CSharp System.Drawing

CSharp examples for System.Drawing:Color HSV

Description

Color To HSV value

Demo Code


using System.Drawing;
using System;//from  www . j a  v a 2 s  .co  m

public class Main{
        public static void ColorToHSV(Color color, out double hue, out double saturation, out double value)
        {
            int max = Math.Max(color.R, Math.Max(color.G, color.B));
            int min = Math.Min(color.R, Math.Min(color.G, color.B));

            hue = color.GetHue();
            saturation = (max == 0) ? 0 : 1d - (1d * min / max);
            value = max / 255d;
        }
}

Related Tutorials