Ejemplo n.º 1
0
        public void Write(Stream data)
        {
            var bw = new BinaryWriter(data);

            if (SystemMemSize != _systemMemData.Length || GraphicsMemSize != _graphicsMemData.Length)
            {
                _header.SetMemSizes(SystemMemSize, GraphicsMemSize);
            }

            _header.Write(bw);

            var ms = new MemoryStream();

            ms.Write(_systemMemData, 0, _systemMemData.Length);
            ms.Write(new byte[SystemMemSize - _systemMemData.Length], 0, SystemMemSize - _systemMemData.Length);
            ms.Write(_graphicsMemData, 0, _graphicsMemData.Length);
            ms.Write(new byte[GraphicsMemSize - _graphicsMemData.Length], 0, GraphicsMemSize - _graphicsMemData.Length);

            ms.Seek(0, SeekOrigin.Begin);

            var msCompress = new MemoryStream();

            _codec.Compress(ms, msCompress);

            bw.Write(msCompress.ToArray());

            ms.Close();
            msCompress.Close();

            bw.Flush();
        }