Пример #1
0
        public BlpData(MPQStream reader)
        {
            Magic       = Encoding.ASCII.GetString(reader.ReadBytes(4));
            Version     = reader.Read <uint>();
            Compression = reader.Read <byte>();
            AlphaDepth  = reader.Read <byte>();
            OtherAlpha  = reader.Read <byte>();
            MipLevel    = reader.Read <byte>();
            Width       = reader.Read <uint>();
            Height      = reader.Read <uint>();

            MipOffsets = new uint[0x10];
            for (int i = 0; i < 0x10; i++)
            {
                MipOffsets[i] = reader.Read <uint>();
            }

            MipCount = 0;
            MipSizes = new uint[0x10];
            for (int i = 0; i < 0x10; i++)
            {
                MipSizes[i] = reader.Read <uint>();
                if (MipSizes[i] > 0)
                {
                    MipCount++;
                }
            }

            RawData = new byte[MipCount][];
            if (Compression == 1)
            {
                Pallette = new uint[0x100];
                for (int i = 0; i < 0x100; i++)
                {
                    Pallette[i] = reader.Read <uint>();
                }
            }

            for (int i = 0; i < MipCount; i++)
            {
                RawData[i] = new byte[MipSizes[i]];
                reader.Seek((int)MipOffsets[i], SeekOrigin.Begin);
                for (int n = 0; n < MipSizes[i]; n++)
                {
                    RawData[i][n] = reader.Read <byte>();
                }
            }
        }
Пример #2
0
        public BlpData(MPQStream reader)
        {
            Magic = Encoding.ASCII.GetString(reader.ReadBytes(4));
            Version = reader.Read<uint>();
            Compression = reader.Read<byte>();
            AlphaDepth = reader.Read<byte>();
            OtherAlpha = reader.Read<byte>();
            MipLevel = reader.Read<byte>();
            Width = reader.Read<uint>();
            Height = reader.Read<uint>();

            MipOffsets = new uint[0x10];
            for (int i = 0; i < 0x10; i++)
                MipOffsets[i] = reader.Read<uint>();

            MipCount = 0;
            MipSizes = new uint[0x10];
            for (int i = 0; i < 0x10; i++)
            {
                MipSizes[i] = reader.Read<uint>();
                if (MipSizes[i] > 0)
                    MipCount++;
            }

            RawData = new byte[MipCount][];
            if (Compression == 1)
            {
                Pallette = new uint[0x100];
                for (int i = 0; i < 0x100; i++)
                    Pallette[i] = reader.Read<uint>();
            }

            for (int i = 0; i < MipCount; i++)
            {
                RawData[i] = new byte[MipSizes[i]];
                reader.Seek((int)MipOffsets[i], SeekOrigin.Begin);
                for (int n = 0; n < MipSizes[i]; n++)
                    RawData[i][n] = reader.Read<byte>();
            }
        }