Ejemplo n.º 1
0
        public static Stream convertStringTo4BitDigitStream(string str)
        {
            // Write string to stream
            using (MemoryStream uncompressedStream = new MemoryStream())
            {
                StreamWriter writer = new StreamWriter(uncompressedStream);
                writer.Write(str);

                // Just flush the writer here to ensure all the data is written to the stream.
                //  It cannot be closed/disposed as that will also close the underlying stream
                writer.Flush();

                // Reset the stream position back to the beginning, as the compressor will run from
                //  the current position
                uncompressedStream.Position = 0;

                // Stream to hold compressed 4 bit digit output
                MemoryStream outStream = new MemoryStream();

                Compression.CompressStream4BitDigit(uncompressedStream, outStream);
                return(outStream);
            }
        }