Decompress an int into a color object. - CSharp System.Drawing

CSharp examples for System.Drawing:Color

Description

Decompress an int into a color object.

Demo Code


using UnityEngine;

public class Main{
        /// <summary>
        /// Decompress a int into a color object.
        /// </summary>
        /// <param name="color"></param>
        /// <returns></returns>
        public static Color Decode( int color )
        {//from  w ww.j av  a 2 s  .  c om
            byte colorAlpha = ( byte ) ( ( color >> 24 ) & 0xFF );
            byte colorRed = ( byte ) ( ( color >> 16 ) & 0xFF );
            byte colorGreen = ( byte ) ( ( color >> 8 ) & 0xFF );
            byte colorBlue = ( byte ) ( color & 0xFF );

            return new Color32( colorRed, colorGreen, colorBlue, colorAlpha );
        }
}

Related Tutorials