Ejemplo n.º 1
0
 public void SetUp()
 {
     inputStream = new MemoryStream();
     inputStream.WriteByte((byte)'A');
     inputStream.WriteByte((byte)'B');
     inputStream.Flush();
     inputStream.Seek(0, 0);
     target = new StreamEncoderInput(inputStream);
 }
        private static void Encode(Stream inputStream, Stream outputStream)
        {
            var encoderInput = new StreamEncoderInput(inputStream);
            var encoderOutput = new StreamEncoderOutput(outputStream);
            var codeTable = new FrameworkDictionaryCodeTable(1000);
            var encoder = new LzwEncoder(encoderInput, encoderOutput, codeTable);

            encoder.Encode();
            outputStream.Flush();
            outputStream.Seek(0, SeekOrigin.Begin);
        }
Ejemplo n.º 3
0
        public void SetUp()
        {
            byte[] dataToEncode = System.Text.Encoding.ASCII.GetBytes("ABABBA");
            inputStream = new MemoryStream(dataToEncode);
            outputStream = new MemoryStream();

            var input = new StreamEncoderInput(inputStream);
            var output = new StreamEncoderOutput(outputStream);
            var codeTable = new FrameworkDictionaryCodeTable(4000);
            target = new LzwEncoder(input, output, codeTable);
        }
        private LzwEncoder CreateEncoder()
        {
            inputStream = new MemoryStream(dataToEncode);
            outputStream = new MemoryStream();

            var input = new StreamEncoderInput(inputStream);
            var output = new StreamEncoderOutput(outputStream);
            ICodeTable codeTable = CreateCodeTable();
            var encoder = new LzwEncoder(input, output, codeTable);

            return encoder;
        }
        private byte[] Encode(byte[] dataToEncode)
        {
            using(var encoderInputStream = new MemoryStream(dataToEncode))
            {
                using(var encoderOutputStream = new MemoryStream())
                {
                    var input = new StreamEncoderInput(encoderInputStream);
                    var output = new StreamEncoderOutput(encoderOutputStream);
                    ICodeTable codeTable = new FrameworkDictionaryCodeTable(10000);
                    var encoder = new LzwEncoder(input, output, codeTable);

                    encoder.Encode();

                    return encoderOutputStream.ToArray();
                }
            }
        }