ScaleToQuantum() static private méthode

static private ScaleToQuantum ( double value ) : Byte
value double
Résultat System.Byte
Exemple #1
0
        /// <summary>
        /// Updates the color value in an inherited class.
        /// </summary>
        protected override void UpdateColor()
        {
            double c;
            double h = Hue * 360.0;

            if (Lightness <= 0.5)
            {
                c = 2.0 * Lightness * Saturation;
            }
            else
            {
                c = (2.0 - (2.0 * Lightness)) * Saturation;
            }
            double min = Lightness - (0.5 * c);

            h -= 360.0 * Math.Floor(h / 360.0);
            h /= 60.0;
            double x = c * (1.0 - Math.Abs(h - (2.0 * Math.Floor(h / 2.0)) - 1.0));

            switch ((int)Math.Floor(h))
            {
            case 0:
            default:
                Color.R = Quantum.ScaleToQuantum(min + c);
                Color.G = Quantum.ScaleToQuantum(min + x);
                Color.B = Quantum.ScaleToQuantum(min);
                break;

            case 1:
                Color.R = Quantum.ScaleToQuantum(min + x);
                Color.G = Quantum.ScaleToQuantum(min + c);
                Color.B = Quantum.ScaleToQuantum(min);
                break;

            case 2:
                Color.R = Quantum.ScaleToQuantum(min);
                Color.G = Quantum.ScaleToQuantum(min + c);
                Color.B = Quantum.ScaleToQuantum(min + x);
                break;

            case 3:
                Color.R = Quantum.ScaleToQuantum(min);
                Color.G = Quantum.ScaleToQuantum(min + x);
                Color.B = Quantum.ScaleToQuantum(min + c);
                break;

            case 4:
                Color.R = Quantum.ScaleToQuantum(min + x);
                Color.G = Quantum.ScaleToQuantum(min);
                Color.B = Quantum.ScaleToQuantum(min + c);
                break;

            case 5:
                Color.R = Quantum.ScaleToQuantum(min + c);
                Color.G = Quantum.ScaleToQuantum(min);
                Color.B = Quantum.ScaleToQuantum(min + x);
                break;
            }
        }
Exemple #2
0
        /// <summary>
        /// Updates the color value in an inherited class.
        /// </summary>
        protected override void UpdateColor()
        {
            QuantumType gray = Quantum.ScaleToQuantum(_shade);

            Color.R = gray;
            Color.G = gray;
            Color.B = gray;
        }
Exemple #3
0
        /// <summary>
        /// Updates the color value in an inherited class.
        /// </summary>
        protected override void UpdateValue()
        {
            QuantumType gray = Quantum.ScaleToQuantum(Shade);

            Value.R = gray;
            Value.G = gray;
            Value.B = gray;
        }
Exemple #4
0
        /// <summary>
        /// Updates the color value in an inherited class.
        /// </summary>
        protected override void UpdateColor()
        {
            if (Math.Abs(Saturation) < double.Epsilon)
            {
                Color.R = Color.G = Color.B = Quantum.ScaleToQuantum(Value);
                return;
            }

            double h = 6.0 * (Hue - Math.Floor(Hue));
            double f = h - Math.Floor(h);
            double p = Value * (1.0 - Saturation);
            double q = Value * (1.0 - (Saturation * f));
            double t = Value * (1.0 - (Saturation * (1.0 - f)));

            switch ((int)h)
            {
            case 0:
            default:
                Color.R = Quantum.ScaleToQuantum(Value);
                Color.G = Quantum.ScaleToQuantum(t);
                Color.B = Quantum.ScaleToQuantum(p);
                break;

            case 1:
                Color.R = Quantum.ScaleToQuantum(q);
                Color.G = Quantum.ScaleToQuantum(Value);
                Color.B = Quantum.ScaleToQuantum(p);
                break;

            case 2:
                Color.R = Quantum.ScaleToQuantum(p);
                Color.G = Quantum.ScaleToQuantum(Value);
                Color.B = Quantum.ScaleToQuantum(t);
                break;

            case 3:
                Color.R = Quantum.ScaleToQuantum(p);
                Color.G = Quantum.ScaleToQuantum(q);
                Color.B = Quantum.ScaleToQuantum(Value);
                break;

            case 4:
                Color.R = Quantum.ScaleToQuantum(t);
                Color.G = Quantum.ScaleToQuantum(p);
                Color.B = Quantum.ScaleToQuantum(Value);
                break;

            case 5:
                Color.R = Quantum.ScaleToQuantum(Value);
                Color.G = Quantum.ScaleToQuantum(p);
                Color.B = Quantum.ScaleToQuantum(q);
                break;
            }
        }
Exemple #5
0
        /// <summary>
        /// Converts the value of this instance to an equivalent Color.
        /// </summary>
        /// <returns>A <see cref="Color"/> instance.</returns>
        public Color ToColor()
        {
            if (!_isCmyk)
            {
                return(Color.FromArgb(Quantum.ScaleToByte(A), Quantum.ScaleToByte(R), Quantum.ScaleToByte(G), Quantum.ScaleToByte(B)));
            }

            var r = Quantum.ScaleToQuantum(Quantum.Max - ((Quantum.ScaleToDouble(R) * (Quantum.Max - K)) + K));
            var g = Quantum.ScaleToQuantum(Quantum.Max - ((Quantum.ScaleToDouble(G) * (Quantum.Max - K)) + K));
            var b = Quantum.ScaleToQuantum(Quantum.Max - ((Quantum.ScaleToDouble(B) * (Quantum.Max - K)) + K));

            return(Color.FromArgb(Quantum.ScaleToByte(A), Quantum.ScaleToByte(r), Quantum.ScaleToByte(g), Quantum.ScaleToByte(b)));
        }
Exemple #6
0
 /// <summary>
 /// Updates the color value in an inherited class.
 /// </summary>
 protected override void UpdateColor()
 {
     Color.R = Quantum.ScaleToQuantum(Y - (3.945707070708279e-05 * (U - 0.5)) + (1.1398279671717170825 * (V - 0.5)));
     Color.G = Quantum.ScaleToQuantum(Y - (0.3946101641414141437 * (U - 0.5)) - (0.5805003156565656797 * (V - 0.5)));
     Color.B = Quantum.ScaleToQuantum(Y + (2.0319996843434342537 * (U - 0.5)) - (4.813762626262513e-04 * (V - 0.5)));
 }
Exemple #7
0
 private ColorGray(MagickColor color)
     : base(color)
 {
     _shade = Quantum.ScaleToQuantum(color.R);
 }
Exemple #8
0
 private ColorGray(IMagickColor <QuantumType> color)
     : base(color)
 {
     _shade = Quantum.ScaleToQuantum(color.R);
 }
Exemple #9
0
 /// <summary>
 /// Updates the color value in an inherited class.
 /// </summary>
 protected override void UpdateValue()
 {
     Value.R = Quantum.ScaleToQuantum(_Y + (1.13980 * _V));
     Value.G = Quantum.ScaleToQuantum(_Y - (0.39380 * _U) - (0.58050 * _V));
     Value.B = Quantum.ScaleToQuantum(_Y + (2.02790 * _U));
 }