Gets the V='value' in the HSV colour system from RGB - CSharp System.Drawing

CSharp examples for System.Drawing:Color RGB

Description

Gets the V='value' in the HSV colour system from RGB

Demo Code


using Microsoft.Xna.Framework;
using System;/*w  ww  . j  av a2  s  . co  m*/

public class Main{
        /// <summary>
        /// Gets the V='value' in the HSV colour system from RGB
        /// </summary>
        /// <param name="R">red</param>
        /// <param name="G">green</param>
        /// <param name="B">blue</param>
        /// <returns>value</returns>
        public static int getVal(int R, int G, int B)
        {
            if(R>=G && R>=B)
            {
                return R;
            }
            
            if(B>=G && B>=R)
            {
                return B;
            }
            
            if(G>=R && G>=B)
            {
                return G;
            }
            return G;//Default
        }
}

Related Tutorials