Int To the color. - CSharp System.Drawing

CSharp examples for System.Drawing:Color

Description

Int To the color.

Demo Code


using System.Drawing;

public class Main{

        /// <summary>
        /// To the color.
        /// </summary>
        /// <param name="this">
        /// The this.
        /// </param>
        /// <returns>
        /// Color.
        /// </returns>
        public static Color ToColor(this int @this)
        {//  w w w . j  a  va 2  s .co m
            // http://www.lukiller.net/post/Split-INT-color-into-RGB-or-RGBA-in-C.aspx
            var red = (byte)(@this & 0xff);
            var green = (byte)(@this >> 8 & 0xff);
            var blue = (byte)(@this >> 16 & 0xff);

            return Color.FromArgb(255, red, green, blue);
        }
}

Related Tutorials