コード例 #1
0
ファイル: EasyCompressor.cs プロジェクト: nicolasmaurice/Rant
        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
ファイル: EasyCompressor.cs プロジェクト: nicolasmaurice/Rant
        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
ファイル: EasyCompressor.cs プロジェクト: W-h-a-t-s/Rant
        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
ファイル: EasyCompressor.cs プロジェクト: W-h-a-t-s/Rant
 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();
 }