コード例 #1
0
 public static byte[] Compress(byte[] input, LZ4FrameBlockMode blockMode = LZ4FrameBlockMode.Linked, LZ4FrameBlockSize blockSize = LZ4FrameBlockSize.Max1MB, LZ4FrameChecksumMode checksumMode = LZ4FrameChecksumMode.Content, long?maxFrameSize = null, bool highCompression = false)
 {
     if (input == null)
     {
         throw new ArgumentNullException("input");
     }
     return(Compress(input, 0, input.Length, blockMode, blockSize, checksumMode, maxFrameSize, highCompression));
 }
コード例 #2
0
ファイル: LZ4Stream.cs プロジェクト: ifdog/lz4.net
        public static LZ4Stream CreateCompressor(Stream innerStream, LZ4StreamMode streamMode, LZ4FrameBlockMode blockMode = LZ4FrameBlockMode.Linked, LZ4FrameBlockSize blockSize = LZ4FrameBlockSize.Max64KB, LZ4FrameChecksumMode checksumMode = LZ4FrameChecksumMode.Content, long?maxFrameSize = null, bool leaveInnerStreamOpen = false)
        {
            var s = LZ4Loader.CreateCompressor()(innerStream, streamMode, blockMode, blockSize, checksumMode, maxFrameSize, leaveInnerStreamOpen);
            var r = new LZ4Stream();

            r._innerStream = s;
            return(r);
        }
コード例 #3
0
        public static byte[] Compress(byte[] input, int inputOffset, int inputLength, LZ4FrameBlockMode blockMode = LZ4FrameBlockMode.Linked, LZ4FrameBlockSize blockSize = LZ4FrameBlockSize.Max1MB, LZ4FrameChecksumMode checksumMode = LZ4FrameChecksumMode.Content, long?maxFrameSize = null, bool highCompression = false)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            else if (inputOffset < 0)
            {
                throw new ArgumentOutOfRangeException("inputOffset");
            }
            else if (inputLength <= 0)
            {
                throw new ArgumentOutOfRangeException("inputLength");
            }
            else if (inputOffset + inputLength > input.Length)
            {
                throw new ArgumentOutOfRangeException("inputOffset+inputLength");
            }

            using (var ms = new MemoryStream()) {
                using (var lz4 = LZ4Stream.CreateCompressor(ms, LZ4StreamMode.Write, blockMode, blockSize, checksumMode, maxFrameSize, highCompression, true)) {
                    lz4.Write(input, inputOffset, inputLength);
                }
                return(ms.ToArray());
            }
        }
コード例 #4
0
 public static byte[] Compress(byte[] input, int inputOffset, int inputLength, LZ4FrameBlockMode blockMode = LZ4FrameBlockMode.Linked, LZ4FrameBlockSize blockSize = LZ4FrameBlockSize.Max64KB, LZ4FrameChecksumMode checksumMode = LZ4FrameChecksumMode.Content, long?maxFrameSize = null)
 {
     return(LZ4Loader.Compress4()(input, inputOffset, inputLength, blockMode, blockSize, checksumMode, maxFrameSize));
 }
コード例 #5
0
ファイル: LZ4Helper.cs プロジェクト: wizard872/lz4.net
        //public static class Custom {

        //	public static byte[] Compress(byte[] input) {
        //		return LZ4Loader.Compress1()(input);
        //	}

        //	public static byte[] Compress(byte[] input, int inputOffset, int inputLength, int passes) {
        //		return LZ4Loader.Compress2()(input, inputOffset, inputLength, passes);
        //	}

        //	public static byte[] Decompress(byte[] input) {
        //		return LZ4Loader.Decompress1()(input);
        //	}

        //	public static byte[] Decompress(byte[] input, int inputOffset, int inputLength) {
        //		return LZ4Loader.Decompress2()(input, inputOffset, inputLength);
        //	}
        //}

        //public static class Frame {

        public static byte[] Compress(byte[] input, LZ4FrameBlockMode blockMode = LZ4FrameBlockMode.Linked, LZ4FrameBlockSize blockSize = LZ4FrameBlockSize.Max1MB, LZ4FrameChecksumMode checksumMode = LZ4FrameChecksumMode.Content, long?maxFrameSize = null, bool highCompression = false)
        {
            return(LZ4Loader.Compress3()(input, blockMode, blockSize, checksumMode, maxFrameSize, highCompression));
        }