Changes the Color intensity. - CSharp System.Drawing

CSharp examples for System.Drawing:Color

Description

Changes the Color intensity.

Demo Code


using System.Windows.Media;
using System.Globalization;
using System;/*from ww  w .  j av a 2  s.c  o m*/

public class Main{
        /// <summary>
        /// Changes the intensity.
        /// </summary>
        /// <param name="c">
        /// The c.
        /// </param>
        /// <param name="factor">
        /// The factor.
        /// </param>
        /// <returns>
        /// </returns>
        public static Color ChangeIntensity(this Color c, double factor)
        {
            var hsv = ColorToHsv(c);
            hsv[2] *= factor;
            if (hsv[2] > 1.0)
            {
                hsv[2] = 1.0;
            }

            return HsvToColor(hsv);
        }
}

Related Tutorials