Exemple #1
0
 public static void ColorToARGB(UniColor color, out ARGBDATA bits)
 {
     byte[] b;
     b          = BitConverter.GetBytes(((Color)color).ToArgb());
     bits.Alpha = b[3];
     bits.Red   = b[2];
     bits.Green = b[1];
     bits.Blue  = b[0];
 }
Exemple #2
0
        // Single Convert RGB-reversed to ColorRef

        public static UniColor BGRAToColor(BGRADATA Bits)
        {
            var tibs = new ARGBDATA();

            tibs.Alpha = Bits.Alpha;
            tibs.Red   = Bits.Red;
            tibs.Blue  = Bits.Blue;
            tibs.Green = Bits.Green;
            return(ARGBToColor(tibs));
        }
Exemple #3
0
        public static void ColorToBGRA(UniColor Color, out BGRADATA bits)
        {
            var tibs = new ARGBDATA();

            ColorToARGB(Color, out tibs);
            bits.Alpha = tibs.Blue;
            bits.Blue  = tibs.Blue;
            bits.Red   = tibs.Red;
            bits.Green = tibs.Green;
        }
Exemple #4
0
        public static UniColor SetTone(ref ARGBDATA argbData, float pPercent, UniColor Color = default)
        {
            float x;

            if (Color != UniColor.Empty)
            {
                ColorToARGB(Color, out argbData);
            }
            x = Max(argbData.Red, argbData.Green, argbData.Blue);
            if (x == 0f)
            {
                argbData.Red   = 0;
                argbData.Green = 0;
                argbData.Blue  = 0;
                return(UniColor.Empty);
            }

            argbData.Red   = (byte)(argbData.Red / x * (255f * pPercent));
            argbData.Green = (byte)(argbData.Green / x * (255f * pPercent));
            argbData.Blue  = (byte)(argbData.Blue / x * (255f * pPercent));
            return(ARGBToColor(argbData));
        }
Exemple #5
0
 public static UniColor ARGBToColor(ARGBDATA bits)
 {
     return(Color.FromArgb(bits.Alpha, bits.Red, bits.Green, bits.Blue));
 }