Example #1
0
        /// <summary>
        /// Initialise a System.Drawing.Color from a FREObject.
        /// </summary>
        /// <param name="freObject"></param>
        /// <param name="hasAlpha">Set to true when the AS3 uint is in ARGB format.</param>
        /// <returns></returns>
        public static Color AsColor(this FREObject freObject, bool hasAlpha = true)
        {
            var rgb = freObject.AsUInt();

            if (hasAlpha)
            {
                return(Color.FromArgb(
                           Convert.ToByte((rgb >> 24) & 0xff),
                           Convert.ToByte((rgb >> 16) & 0xff),
                           Convert.ToByte((rgb >> 8) & 0xff),
                           Convert.ToByte(rgb & 0xff)));
            }

            return(Color.FromArgb(
                       Convert.ToByte((rgb >> 16) & 0xff),
                       Convert.ToByte((rgb >> 8) & 0xff),
                       Convert.ToByte(rgb & 0xff)));
        }