Beispiel #1
0
        public TPL(TXGHeader header, Stream stream)
        {
            using (BigEndianWriter writer = new BigEndianWriter(stream))
            {
                writer.Write(_Identifier);
                writer.Write(header.ImageCount);
                writer.Write(0x0C);

                ITableOffsets = new uint[header.ImageCount];
                PTableOffsets = new uint[header.ImageCount];

                for (int i = 0; i < header.ImageCount; i++)
                {
                    writer.Write(0);
                    writer.Write(0);
                }

                if (header._Format.HasPalette)
                {
                    for (int i = 0; i < header.ImageCount; i++)
                    {
                        PTableOffsets[i] = (uint)writer.BaseStream.Position;
                        writer.Write((ushort)(header.PaletteData[i].Length / 2));
                        writer.Write((ushort)0);
                        writer.Write(header.PaletteFormat);
                        writer.Write(0);
                        writer.AlignPosition(0x20);
                        writer.Write(PTableOffsets[i] + 0x08, (uint)writer.BaseStream.Position);
                        writer.Write(header.PaletteData[i]);
                    }
                }

                for (int i = 0; i < header.ImageCount; i++)
                {
                    ITableOffsets[i] = (uint)writer.BaseStream.Position;
                    writer.Write((ushort)header.Height);
                    writer.Write((ushort)header.Width);
                    writer.Write(header.ImageFormat);
                    long PastOffset = writer.BaseStream.Position;
                    writer.Write(0);
                    writer.Write(0);
                    writer.Write(0);
                    writer.Write(1);
                    writer.Write(1);
                    writer.Write(0);
                    writer.Write(0);
                    writer.AlignPosition(0x20);
                    writer.Write(PastOffset, (uint)writer.BaseStream.Position);
                    writer.Write(header.ImageData[i]);
                }

                writer.BaseStream.Position = 0x0C;
                for (int i = 0; i < header.ImageCount; i++)
                {
                    writer.Write(ITableOffsets[i]);
                    writer.Write(PTableOffsets[i]);
                }
                writer.BaseStream.Position = 0x00;
            }
        }
Beispiel #2
0
        public TXG(Stream stream, string[] files)
        {
            using (BigEndianWriter writer = new BigEndianWriter(stream))
            {
                writer.Write(files.Length);
                Offsets = new uint[files.Length];
                for (int i = 0; i < files.Length; i++)
                {
                    writer.Write(0);
                }
                writer.AlignPosition(0x20, 0xFF);

                for (int i = 0; i < files.Length; i++)
                {
                    using (FileStream fStream = File.OpenRead(files[i]))
                    {
                        Offsets[i] = (uint)writer.BaseStream.Position;
                        TXGHeader txg = new TXGHeader(writer, new TPL(fStream));
                    }
                }

                writer.BaseStream.Position = 0x04;
                for (int i = 0; i < files.Length; i++)
                {
                    writer.Write(Offsets[i]);
                }
            }
        }
Beispiel #3
0
        public TXG(Stream stream, string outputDir)
        {
            using (BigEndianReader reader = new BigEndianReader(stream))
            {
                FileCount = reader.ReadUInt32();
                Offsets   = new uint[FileCount];
                for (int i = 0; i < FileCount; i++)
                {
                    Offsets[i] = reader.ReadUInt32();
                }

                for (int i = 0; i < FileCount; i++)
                {
                    reader.BaseStream.Position = Offsets[i];
                    string fileName = Path.Combine(outputDir, i + ".tpl");
                    Console.WriteLine(string.Format("File Name: {0}", fileName));
                    TXGHeader    header  = new TXGHeader(reader);
                    MemoryStream mStream = new MemoryStream();
                    TPL          tpl     = new TPL(header, mStream);
                    File.WriteAllBytes(fileName, mStream.ToArray());
                }
            }
        }