예제 #1
0
        private void Init(Stream stream)
        {
            using (var reader = new BinaryReader(stream, Encoding.Default, true))
            {
                stream.Seek(0, SeekOrigin.Begin);

                _unknown1 = reader.ReadInt32();
                _expectedNumberOfFrames = reader.ReadInt32();
                _unknown2 = reader.ReadBytes(56);

                _frames           = new EFAFrame[_expectedNumberOfFrames];
                _framesCollection = new ReadOnlyCollection <EFAFrame>(_frames);

                var frameHeaders = new EFAFrameHeader[_expectedNumberOfFrames];

                for (int i = 0; i < _expectedNumberOfFrames; ++i)
                {
                    frameHeaders[i] = EFAFrameHeader.Read(reader);
                }

                for (int i = 0; i < _expectedNumberOfFrames; ++i)
                {
                    var    header         = frameHeaders[i];
                    byte[] compressedData = reader.ReadBytes(header.Size);

                    using (var compressedStream = new MemoryStream(compressedData))
                        using (var decompressedStream = new MemoryStream())
                            using (var decompressionStream = new DeflateStream(compressedStream, CompressionMode.Decompress))
                            {
                                compressedStream.Seek(2, SeekOrigin.Begin);
                                decompressionStream.CopyTo(decompressedStream);
                                _frames[i] = new EFAFrame(frameHeaders[i], decompressedStream.ToArray());
                            }
                }
            }
        }
예제 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="reader"></param>
 public EFAFrame(EFAFrameHeader header, byte[] data)
 {
     _header         = header;
     _data           = data;
     _dataCollection = new ReadOnlyCollection <byte>(_data);
 }