コード例 #1
0
        public DXT5Block(EndianBinaryReader reader, DXTxBlockLayout blockLayout)
        {
            byte bits_5, bits_4, bits_3, bits_2, bits_1, bits_0;

            switch (blockLayout)
            {
            case DXTxBlockLayout.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   = DXTC.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 DXTxBlockLayout.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   = DXTC.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");
            }
        }
コード例 #2
0
        public DXT1Block(EndianBinaryReader reader, DXTxBlockLayout blockLayout)
        {
            byte color0_hi, color0_lo, color1_hi, color1_lo, bits_3, bits_2, bits_1, bits_0;

            switch (blockLayout)
            {
            case DXTxBlockLayout.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 DXTxBlockLayout.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   = DXTC.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);
        }