示例#1
0
文件: Lzw.cs 项目: zer09/Cosmos
        public static byte[] Decompress(byte[] data)
        {
            MemoryStream   ot           = new MemoryStream();
            LzwInputStream CompInStream = new LzwInputStream(new MemoryStream(data));
            int            ch           = CompInStream.ReadByte();

            while (ch != -1)
            {
                ot.WriteByte((byte)ch);
                ch = CompInStream.ReadByte();
            }
            return(ot.GetBuffer());
        }
示例#2
0
        public void ZeroLengthInputStream()
        {
            LzwInputStream lis       = new LzwInputStream(new MemoryStream());
            bool           exception = false;

            try {
                lis.ReadByte();
            } catch {
                exception = true;
            }

            Assert.IsTrue(exception, "reading from an empty stream should cause an exception");
        }