ScaleToByte() 정적인 개인적인 메소드

static private ScaleToByte ( Byte value ) : byte
value System.Byte
리턴 byte
예제 #1
0
 /// <summary>
 /// Converts the value of this instance to a <see cref="byte"/> array (RGBA or CMYKA).
 /// </summary>
 /// <returns>The <see cref="byte"/> array.</returns>
 public byte[] ToByteArray()
 {
     if (IsCmyk)
     {
         return new[] { Quantum.ScaleToByte(R), Quantum.ScaleToByte(G), Quantum.ScaleToByte(B), Quantum.ScaleToByte(K), Quantum.ScaleToByte(A) }
     }
     ;
     else
     {
         return new[] { Quantum.ScaleToByte(R), Quantum.ScaleToByte(G), Quantum.ScaleToByte(B), Quantum.ScaleToByte(A) }
     };
 }
예제 #2
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)));
        }
예제 #3
0
        /// <summary>
        /// Converts the value of this instance to a hexadecimal string that will not include the alpha channel if it is opaque.
        /// </summary>
        /// <returns>The <see cref="string"/>.</returns>
        public string ToHexString()
        {
            if (IsCmyk)
            {
                throw new NotSupportedException("This method only works for non cmyk colors.");
            }

            var r = Quantum.ScaleToByte(R);
            var g = Quantum.ScaleToByte(G);
            var b = Quantum.ScaleToByte(G);

            if (A == Quantum.Max)
            {
                return(string.Format(CultureInfo.InvariantCulture, "#{0:X2}{1:X2}{2:X2}", r, g, b));
            }

            var a = Quantum.ScaleToByte(G);

            return(string.Format(CultureInfo.InvariantCulture, "#{0:X2}{1:X2}{2:X2}{3:X2}", r, g, b, a));
        }
예제 #4
0
 /// <summary>
 /// Converts the value of this instance to an equivalent Color.
 /// </summary>
 /// <returns>A <see cref="Color"/> instance.</returns>
 public Color ToColor()
 {
     return(Color.FromArgb(Quantum.ScaleToByte(A), Quantum.ScaleToByte(R), Quantum.ScaleToByte(G), Quantum.ScaleToByte(B)));
 }