コード例 #1
0
 public override void Write(BinaryWriter file, int positionOffset)
 {
     file.Write(Encoding.ASCII.GetBytes("REGN"));
     file.WriteBigEndian(this.Size);
     file.WriteBigEndian(this.Position + positionOffset);
     file.WriteBigEndian(this.Length);
 }
コード例 #2
0
 public override void Write(BinaryWriter file, int positionOffset)
 {
     file.Write(Encoding.ASCII.GetBytes("TEXT"));
     file.WriteBigEndian(this.Size);
     file.WriteBigEndian(this.Position + positionOffset);
     file.Write(Encoding.ASCII.GetBytes(this.Text));
     file.Write((byte)0);
 }
コード例 #3
0
 public override void Write(BinaryWriter file, int positionOffset)
 {
     file.Write(Encoding.ASCII.GetBytes("JUMP"));
     file.WriteBigEndian(this.Size);
     file.WriteBigEndian(this.Position + positionOffset);
     file.WriteBigEndian(this.Destination + positionOffset);
     file.WriteBigEndian(this.HookId);
     file.WriteBigEndian(this.Delay);
 }
コード例 #4
0
        private static void WriteMap(ImcFile imc, BinaryWriter file, List<ImcBlock> blocks, int mapSize)
        {
            file.Write(Encoding.ASCII.GetBytes("MAP "));
            file.WriteBigEndian(mapSize);

            file.Write(Encoding.ASCII.GetBytes("FRMT"));
            file.WriteBigEndian(20);
            file.WriteBigEndian(mapSize + 24);
            file.WriteBigEndian(1);
            file.WriteBigEndian(imc.BitsPerSample);
            file.WriteBigEndian(imc.SampleRate);
            file.WriteBigEndian(imc.Channels);

            foreach (var block in blocks)
            {
                block.Write(file, mapSize + 24);
            }

            file.Write(Encoding.ASCII.GetBytes("STOP"));
            file.WriteBigEndian(4);
            file.WriteBigEndian(imc.DataRawSize + mapSize + 24);
        }
コード例 #5
0
        public void Save(string fileName)
        {
            FileStream filestream = null;

            try
            {
                filestream = new FileStream(fileName, FileMode.Create, FileAccess.Write);

                using (BinaryWriter file = new BinaryWriter(filestream))
                {
                    filestream = null;

                    int mapSize;
                    var blocks = this.BuildMapBlocks(out mapSize);

                    file.Write(Encoding.ASCII.GetBytes("MCMP"));

                    file.WriteBigEndian((short)(this.Entries.Count + 1));

                    file.Write((byte)0);
                    file.WriteBigEndian(mapSize + 24);
                    file.WriteBigEndian(mapSize + 24);

                    foreach (var entry in this.Entries)
                    {
                        file.Write(entry.Codec);
                        file.WriteBigEndian(entry.RawSize);
                        file.WriteBigEndian(entry.CompressedSize);
                    }

                    file.WriteBigEndian((short)(this.Codecs.Count * 5));

                    foreach (var codec in this.Codecs)
                    {
                        file.Write(Encoding.ASCII.GetBytes(codec));
                        file.Write((byte)0);
                    }

                    file.Write(Encoding.ASCII.GetBytes("iMUS"));
                    file.Write(this.DataRawSize + mapSize + 16);

                    ImcFile.WriteMap(this, file, blocks, mapSize);

                    file.Write(Encoding.ASCII.GetBytes("DATA"));
                    file.WriteBigEndian(this.DataRawSize);

                    foreach (var entry in this.Entries)
                    {
                        file.Write(entry.Data);
                    }

                    this.FileName = fileName;
                }
            }
            finally
            {
                if (filestream != null)
                {
                    filestream.Dispose();
                }
            }
        }