예제 #1
0
        public void ConstructionFromBytesSetsColorIndexes()
        {
            byte indexes0 = "11 10 01 00".AsByte(); // d c b a
            byte indexes1 = "00 11 10 01".AsByte(); // h g f e
            byte indexes2 = "01 00 11 10".AsByte(); // l k j i
            byte indexes3 = "10 01 00 11".AsByte(); // p o n m

            var bytes = new byte[BlockFormat.BC3ByteSize];

            bytes[12] = indexes0;
            bytes[13] = indexes1;
            bytes[14] = indexes2;
            bytes[15] = indexes3;

            var block = BC3BlockData.FromBytes(bytes);

            Assert.AreEqual(0, block.ColorIndexes[0]);  // a    00
            Assert.AreEqual(1, block.ColorIndexes[1]);  // b    01
            Assert.AreEqual(2, block.ColorIndexes[2]);  // c    10
            Assert.AreEqual(3, block.ColorIndexes[3]);  // d    11
            Assert.AreEqual(1, block.ColorIndexes[4]);  // e    01
            Assert.AreEqual(2, block.ColorIndexes[5]);  // f    10
            Assert.AreEqual(3, block.ColorIndexes[6]);  // g    11
            Assert.AreEqual(0, block.ColorIndexes[7]);  // h    00
            Assert.AreEqual(2, block.ColorIndexes[8]);  // i    10
            Assert.AreEqual(3, block.ColorIndexes[9]);  // j    11
            Assert.AreEqual(0, block.ColorIndexes[10]); // k    00
            Assert.AreEqual(1, block.ColorIndexes[11]); // l    01
            Assert.AreEqual(3, block.ColorIndexes[12]); // m    11
            Assert.AreEqual(0, block.ColorIndexes[13]); // n    00
            Assert.AreEqual(1, block.ColorIndexes[14]); // o    01
            Assert.AreEqual(2, block.ColorIndexes[15]); // p    10
        }
예제 #2
0
        public void ConstructionFromBytesSetsAlpha1()
        {
            const byte alphaValue = 215;

            var bytes = new byte[BlockFormat.BC3ByteSize];

            bytes[1] = alphaValue;

            var block = BC3BlockData.FromBytes(bytes);

            Assert.AreEqual(alphaValue, block.Alpha1);
        }
예제 #3
0
        public void ConstructionFromBytesSetsColor1()
        {
            var color = new Color565Helper(40500);
            var bytes = new byte[BlockFormat.BC2ByteSize];

            bytes[10] = color.LowByte;
            bytes[11] = color.HighByte;

            var block = BC3BlockData.FromBytes(bytes);

            Assert.AreEqual(color.Color.Value, block.Color1.Value);
        }
예제 #4
0
        public void ConstructionFromBytesSetsAlphaIndexes()
        {
            // Increment until max value, then decrement
            byte alphas0 = "10  001 000".AsByte(); // c b a
            byte alphas1 = "1 100 011 0".AsByte(); // f e d c
            byte alphas2 = "111 110  10".AsByte(); // h g f
            byte alphas3 = "01  110 111".AsByte(); // k j i
            byte alphas4 = "0 011 100 1".AsByte(); // n m l k
            byte alphas5 = "000 001  01".AsByte(); // p o n

            var bytes = new byte[BlockFormat.BC3ByteSize];

            bytes[2] = alphas2;
            bytes[3] = alphas1;
            bytes[4] = alphas0;
            bytes[5] = alphas5;
            bytes[6] = alphas4;
            bytes[7] = alphas3;

            var block = BC3BlockData.FromBytes(bytes);

            Assert.AreEqual(0, block.AlphaIndexes[0]);  // a    000
            Assert.AreEqual(1, block.AlphaIndexes[1]);  // b    001
            Assert.AreEqual(2, block.AlphaIndexes[2]);  // c    010
            Assert.AreEqual(3, block.AlphaIndexes[3]);  // d    011
            Assert.AreEqual(4, block.AlphaIndexes[4]);  // e    100
            Assert.AreEqual(5, block.AlphaIndexes[5]);  // f    101
            Assert.AreEqual(6, block.AlphaIndexes[6]);  // g    110
            Assert.AreEqual(7, block.AlphaIndexes[7]);  // h    111
            Assert.AreEqual(7, block.AlphaIndexes[8]);  // i    111
            Assert.AreEqual(6, block.AlphaIndexes[9]);  // j    110
            Assert.AreEqual(5, block.AlphaIndexes[10]); // k    101
            Assert.AreEqual(4, block.AlphaIndexes[11]); // l    100
            Assert.AreEqual(3, block.AlphaIndexes[12]); // m    011
            Assert.AreEqual(2, block.AlphaIndexes[13]); // n    010
            Assert.AreEqual(1, block.AlphaIndexes[14]); // o    001
            Assert.AreEqual(0, block.AlphaIndexes[15]); // p    000
        }