Ejemplo n.º 1
0
        public void CompressionSwitchesReferenceColorOrderWhenAlpha()
        {
            var expectedMin    = Color.FromArgb(10, 10, 10);
            var expectedMax    = Color.FromArgb(250, 250, 250);
            var expectedColor0 = ColorUtility.To16Bit(expectedMin);
            var expectedColor1 = ColorUtility.To16Bit(expectedMax);
            var colors         = ColorHelper.CreateRandomColorsBetween(expectedMin, expectedMax);

            // Place expected min and max color in test input
            colors[4]  = expectedMin;
            colors[10] = expectedMax;

            // Add an arbitrary alpha value to some color
            ColorHelper.AddAlpha(ref colors[5]);

            var data = new BC1Format().Compress(colors);

            var color0 = Color565.FromValue((ushort)((data[1] << 8) | data[0]));
            var color1 = Color565.FromValue((ushort)((data[3] << 8) | data[2]));

            Assert.LessOrEqual(color0.Value, color1.Value);
            Assert.AreEqual(expectedColor0.Value, color0.Value);
            Assert.AreEqual(expectedColor1.Value, color1.Value);
        }