예제 #1
0
        public static byte[] Decompress(byte[] data)
        {
            var inStream  = new MemoryStream(data);
            var outStream = new MemoryStream();

            var dec = new LZMA.Decoder();
            EasyCompressorProgress progress = null;

            if (ProgressUpdate != null)
            {
                progress = new EasyCompressorProgress(ProgressUpdate);
            }
            byte[] props = new byte[5];
            inStream.Read(props, 0, 5);
            dec.SetDecoderProperties(props);
            long outSize = 0;

            for (int i = 0; i < 8; i++)
            {
                outSize |= ((long)(byte)inStream.ReadByte()) << (8 * i);
            }
            long compressedSize = inStream.Length - inStream.Position;

            dec.Code(inStream, outStream, compressedSize, outSize, progress);
            inStream.Close();
            outStream.Close();
            return(outStream.ToArray());
        }
예제 #2
0
        public static byte[] Compress(byte[] data)
        {
            var inStream = new MemoryStream(data);
            var stream   = new MemoryStream();

            var enc = new LZMA.Encoder();

            enc.WriteCoderProperties(stream);
            EasyCompressorProgress progress = null;

            if (ProgressUpdate != null)
            {
                progress = new EasyCompressorProgress(ProgressUpdate);
            }
            long dataSize = data.Length;

            for (int i = 0; i < 8; i++)
            {
                stream.WriteByte((byte)(dataSize >> (8 * i)));
            }
            enc.Code(inStream, stream, data.Length, -1, progress);
            inStream.Close();
            stream.Close();
            return(stream.ToArray());
        }
예제 #3
0
        public static byte[] Compress(byte[] data)
        {
            var inStream = new MemoryStream(data);
            var stream = new MemoryStream();

            var enc = new LZMA.Encoder();

            enc.WriteCoderProperties(stream);
            EasyCompressorProgress progress = null;
            if(ProgressUpdate != null)
                progress = new EasyCompressorProgress(ProgressUpdate);
            long dataSize = data.Length;
            for (int i = 0; i < 8; i++)
                stream.WriteByte((byte)(dataSize >> (8 * i)));
            enc.Code(inStream, stream, data.Length, -1, progress);
            inStream.Close();
            stream.Close();
            return stream.ToArray();
        }
예제 #4
0
 public static byte[] Decompress(byte[] data)
 {
     var inStream = new MemoryStream(data);
     var outStream = new MemoryStream();
     
     var dec = new LZMA.Decoder();
     EasyCompressorProgress progress = null;
     if (ProgressUpdate != null)
         progress = new EasyCompressorProgress(ProgressUpdate);
     byte[] props = new byte[5];
     inStream.Read(props, 0, 5);
     dec.SetDecoderProperties(props);
     long outSize = 0;
     for (int i = 0; i < 8; i++)
         outSize |= ((long)(byte)inStream.ReadByte()) << (8 * i);
     long compressedSize = inStream.Length - inStream.Position;
     dec.Code(inStream, outStream, compressedSize, outSize, progress);
     inStream.Close();
     outStream.Close();
     return outStream.ToArray();
 }