コード例 #1
0
ファイル: FtexsFileChunk.cs プロジェクト: emoose/FtexTool
        public void Read(Stream inputStream, bool absoluteOffset, bool flipEndian = false)
        {
            X360Reader reader = new X360Reader(inputStream, Encoding.Default, true, flipEndian);
            ushort compressedChunkSize = reader.ReadUInt16();
            ushort decompressedChunkSize = reader.ReadUInt16();
            Offset = reader.ReadUInt32();

            long indexEndPosition = reader.BaseStream.Position;

            if (absoluteOffset)
            {
                reader.BaseStream.Position = Offset;
            }
            else
            {
                // HACK: result.Offset could be 0x80000008
                reader.BaseStream.Position = indexEndPosition + (Offset & OffsetBitMask) - IndexSize;
            }

            byte[] data = reader.ReadBytes(compressedChunkSize);
            bool dataCompressed = compressedChunkSize != decompressedChunkSize;
            SetData(data, dataCompressed, decompressedChunkSize);

            reader.BaseStream.Position = indexEndPosition;
        }
コード例 #2
0
ファイル: FtexFileMipMapInfo.cs プロジェクト: emoose/FtexTool
 public void Read(X360Reader reader)
 {
     Offset = reader.ReadInt32();
     DecompressedFileSize = reader.ReadInt32();
     CompressedFileSize = reader.ReadInt32();
     Index = reader.ReadByte();
     FtexsFileNumber = reader.ReadByte();
     ChunkCount = reader.ReadInt16();
 }
コード例 #3
0
ファイル: FtexFileMipMapInfo.cs プロジェクト: emoose/FtexTool
 public static FtexFileMipMapInfo ReadFtexFileMipMapInfo(X360Reader reader)
 {
     FtexFileMipMapInfo result = new FtexFileMipMapInfo();
     result.Read(reader);
     return result;
 }
コード例 #4
0
ファイル: FtexFile.cs プロジェクト: emoose/FtexTool
        private void Read(Stream inputStream)
        {
            X360Reader reader = new X360Reader(inputStream, Encoding.Default, true, false);
            uint magicNumber = reader.ReadUInt32();
            FlipEndian = magicNumber == 0x46544558;
            reader.BaseStream.Position -= 4;
            reader.FlipEndian = FlipEndian;

            magicNumber = reader.ReadUInt32();
            if (magicNumber != MagicNumber1)
                return;

            magicNumber = reader.ReadUInt32();
            if (magicNumber != MagicNumber2)
                return;

            PixelFormatType = reader.ReadInt16();
            Width = reader.ReadInt16();
            Height = reader.ReadInt16();
            Depth = reader.ReadInt16();
            MipMapCount = reader.ReadByte();
            NrtFlag = reader.ReadByte();
            UnknownFlags = reader.ReadInt16();

            reader.FlipEndian = false;

            if (reader.ReadInt32() != OneInt32)
                return;
            if (reader.ReadInt32() != ZeroInt32)
                return;

            TextureType = (FtexTextureType) reader.ReadInt32();
            FtexsFileCount = reader.ReadByte();
            AdditionalFtexsFileCount = reader.ReadByte();
            if (reader.ReadInt16() != 0)
                return;

            if (reader.ReadInt32() != ZeroInt32)
                return;
            if (reader.ReadInt32() != ZeroInt32)
                return;
            if (reader.ReadInt32() != ZeroInt32)
                return;

            Hash = reader.ReadBytes(16);

            reader.FlipEndian = FlipEndian;
            for (int i = 0; i < MipMapCount; i++)
            {
                FtexFileMipMapInfo fileMipMapInfo = FtexFileMipMapInfo.ReadFtexFileMipMapInfo(reader);
                AddMipMapInfo(fileMipMapInfo);
            }
        }