private static string DecodeStringLZW(ref string str) { using (LZW inst_rle = new LZW()) { string str_decoded = inst_rle.Decode(ref str); Console.WriteLine("\r\nBase string ({0} chars): {1}\r\nAfter RLE-decoding ({2} chars): {3}", str.Length, str, str_decoded.Length, str_decoded); return(str_decoded); } }
private static String EncodeStringLZW(ref string str) { using (LZW inst_rle = new LZW()) { string str_encoded = inst_rle.Encode(ref str); Console.WriteLine("\r\nBase string ({0} chars): {1}\r\nAfter RLE-encoding ({2} chars): {3}\r\nCompression percentage: %{4}", str.Length, str, str_encoded.Length, str_encoded, inst_rle.GetPercentage((double)str.Length, (double)str_encoded.Length).ToString()); return(str_encoded); } }