Esempio n. 1
0
        public static MemoryStream DecompressToMemoryStream(byte[] compressedBytes, ECompressionType compressType, int decompressedSize = -1)
        {
            MemoryStream decompressedStream;

            switch (compressType)
            {
            case ECompressionType.LzMa:      //LZMA
            {
                decompressedStream = new MemoryStream();
                SevenZipHelper.DecompressData(compressedBytes, decompressedStream, decompressedSize);
                break;
            }

            case ECompressionType.Lz4:       //LZ4
            case ECompressionType.Lz4Hc:     //LZ4HC
            {
                var decompressedBytes = new byte[decompressedSize];
                LZ4Codec.Decode(compressedBytes, 0, compressedBytes.Length,
                                decompressedBytes, 0, decompressedSize);
                decompressedStream = new MemoryStream(decompressedBytes);
                break;
            }

            //case CompressionType.LzHam:   //LZHAM
            case ECompressionType.None:          //None
            default:
            {
                decompressedStream = new MemoryStream(compressedBytes);
                break;
            }
            }
            return(decompressedStream);
        }