Asciimation.RLE.Decode C# (CSharp) Method

Decode() public static method

public static Decode ( byte bytes ) : byte[]
bytes byte
return byte[]
        public static byte[] Decode(byte[] bytes)
        {
            List<byte> result = new List<byte>();

            int i = 0;
            while (i < bytes.Length)
            {
                if ((bytes[i] & 0x80) == 0)
                {
                    int repeatCount = bytes[i] + 2;
                    for (int j = 0; j < repeatCount; j++)
                        result.Add(bytes[i + 1]);
                    i = i + 2;
                }
                else
                {
                    int repeatCount = (0x7F & bytes[i]) + 1;
                    for (int j = 0; j < repeatCount; j++)
                        result.Add(bytes[i + 1 + j]);
                    i = i + 1 + repeatCount;
                }
            }

            return result.ToArray();
        }