Compress a color object to an int. - CSharp System.Drawing

CSharp examples for System.Drawing:Color

Description

Compress a color object to an int.

Demo Code


using UnityEngine;

public class Main{
        /// <summary>
        /// Compress a color object to an int.
        /// </summary>
        /// <param name="self"></param>
        /// <returns></returns>
        public static int Encode( Color self )
        {/*from  ww w. j a v  a2 s  .c om*/
            Color32 color32 = self;

            int c = 0;

            c |= color32.a << 24;
            c |= color32.r << 16;
            c |= color32.g << 8;
            c |= color32.b;

            return c;
        }
}

Related Tutorials