Exemple #1
0
        public DXT5Block(EndianBinaryReader reader, DXTxRGTCBlockLayout blockLayout)
        {
            byte bits_5, bits_4, bits_3, bits_2, bits_1, bits_0;

            switch (blockLayout)
            {
            case DXTxRGTCBlockLayout.Normal:
                Alpha0 = reader.ReadByte();
                Alpha1 = reader.ReadByte();

                bits_5 = reader.ReadByte();
                bits_4 = reader.ReadByte();
                bits_3 = reader.ReadByte();
                bits_2 = reader.ReadByte();
                bits_1 = reader.ReadByte();
                bits_0 = reader.ReadByte();
                Bits   = DXTxRGTC.ExtractBits((((ulong)bits_0 << 40) | ((ulong)bits_1 << 32) | ((ulong)bits_2 << 24) | ((ulong)bits_3 << 16) | ((ulong)bits_4 << 8) | (ulong)bits_5), 3);

                Color = new DXT1Block(reader, blockLayout);
                break;

            case DXTxRGTCBlockLayout.PSP:
                Color  = new DXT1Block(reader, blockLayout);
                Alpha0 = reader.ReadByte();
                Alpha1 = reader.ReadByte();

                bits_5 = reader.ReadByte();
                bits_4 = reader.ReadByte();
                bits_3 = reader.ReadByte();
                bits_2 = reader.ReadByte();
                bits_1 = reader.ReadByte();
                bits_0 = reader.ReadByte();
                Bits   = DXTxRGTC.ExtractBits((((ulong)bits_0 << 40) | ((ulong)bits_1 << 32) | ((ulong)bits_2 << 24) | ((ulong)bits_3 << 16) | ((ulong)bits_4 << 8) | (ulong)bits_5), 3);
                break;

            default:
                throw new Exception("Unknown block layout");
            }
        }
Exemple #2
0
        public DXT1Block(EndianBinaryReader reader, DXTxRGTCBlockLayout blockLayout)
        {
            byte color0_hi, color0_lo, color1_hi, color1_lo, bits_3, bits_2, bits_1, bits_0;

            switch (blockLayout)
            {
            case DXTxRGTCBlockLayout.Normal:
                color0_hi = reader.ReadByte();
                color0_lo = reader.ReadByte();
                color1_hi = reader.ReadByte();
                color1_lo = reader.ReadByte();
                bits_3    = reader.ReadByte();
                bits_2    = reader.ReadByte();
                bits_1    = reader.ReadByte();
                bits_0    = reader.ReadByte();
                break;

            case DXTxRGTCBlockLayout.PSP:
                bits_3    = reader.ReadByte();
                bits_2    = reader.ReadByte();
                bits_1    = reader.ReadByte();
                bits_0    = reader.ReadByte();
                color0_hi = reader.ReadByte();
                color0_lo = reader.ReadByte();
                color1_hi = reader.ReadByte();
                color1_lo = reader.ReadByte();
                break;

            default:
                throw new Exception("Unknown block layout");
            }

            Bits   = DXTxRGTC.ExtractBits((((uint)bits_0 << 24) | ((uint)bits_1 << 16) | ((uint)bits_2 << 8) | (uint)bits_3), 2);
            Color0 = (ushort)(((ushort)color0_lo << 8) | (ushort)color0_hi);
            Color1 = (ushort)(((ushort)color1_lo << 8) | (ushort)color1_hi);
        }