Beispiel #1
0
        public void Encode(Stream input, Stream output, IEnumerable <Match> matches)
        {
            if (input.Length > 0xFFFFFF)
            {
                throw new InvalidOperationException("Data to compress is too long.");
            }

            var compressionHeader = new byte[]
            {
                0x30, (byte)(input.Length & 0xFF), (byte)((input.Length >> 8) & 0xFF),
                (byte)((input.Length >> 16) & 0xFF)
            };

            output.Write(compressionHeader, 0, 4);

            _encoder.Encode(input, output, matches);
        }
Beispiel #2
0
        public void Encode(Stream input, Stream output, IEnumerable <Match> matches)
        {
            if (input.Length > 0x1FFFFFFF)
            {
                throw new InvalidOperationException("Data to compress is too long.");
            }

            var compressionHeader = new[] {
                (byte)((byte)(input.Length << 3) | 4),
                (byte)(input.Length >> 5),
                (byte)(input.Length >> 13),
                (byte)(input.Length >> 21)
            };

            output.Write(compressionHeader, 0, 4);

            _encoder.Encode(input, output, matches);
        }