public void Read(Stream data) { _header = new ResourceHeader(); var br = new BinaryReader(data); _header.Read(br); if (_header.Magic != ResourceHeader.MagicValue) { throw new Exception("Not a valid resource"); } switch (_header.CompressCodec) { case CompressionType.LZX: _codec = CompressionCodecFactory.LZX; break; case CompressionType.Deflate: _codec = CompressionCodecFactory.Deflate; break; default: throw new ArgumentOutOfRangeException(); } var ms = new MemoryStream(); _codec.Decompress(data, ms); ms.Seek(0, SeekOrigin.Begin); _systemMemData = new byte[SystemMemSize]; ms.Read(_systemMemData, 0, SystemMemSize); _graphicsMemData = new byte[GraphicsMemSize]; ms.Read(_graphicsMemData, 0, GraphicsMemSize); ms.Close(); }
public static object Convert(object buffer, ICompressionCodec destinationCodec) { throw new NotImplementedException(); }
public void Read(Stream data) { _header = new ResourceHeader(); var br = new BinaryReader(data); _header.Read(br); if (_header.Magic != ResourceHeader.MagicValue) { throw new Exception("Not a valid resource"); } switch (_header.CompressCodec) { case CompressionType.LZX: _codec = CompressionCodecFactory.LZX; break; case CompressionType.Deflate: _codec = CompressionCodecFactory.Deflate; break; default: throw new ArgumentOutOfRangeException(); } var ms = new MemoryStream(); _codec.Decompress( data, ms ); ms.Seek(0, SeekOrigin.Begin); _systemMemData = new byte[SystemMemSize]; ms.Read(_systemMemData, 0, SystemMemSize); _graphicsMemData = new byte[GraphicsMemSize]; ms.Read(_graphicsMemData, 0, GraphicsMemSize); ms.Close(); }