System.Net.Topology.ByteArrayExtensions.ToBitStream C# (CSharp) Method

ToBitStream() static private method

static private ToBitStream ( this bytes, bool fromLeft ) : IEnumerable
bytes this
fromLeft bool
return IEnumerable
        internal static IEnumerable<bool> ToBitStream(this byte[] bytes, bool fromLeft)
        {
            if (bytes == null)
                throw new ArgumentNullException(nameof(bytes));

            if (fromLeft)
            {
                for (int i = 0; i < bytes.Length; ++i)
                {
                    byte tmp = bytes[i].ReverseBits();
                    for (int j = 0; j < 8; ++j)
                    {
                        yield return (tmp & 1) == 1;
                        tmp >>= 1;
                    }
                }
            }
            else
            {
                for (int i = bytes.Length - 1; i >= 0; --i)
                {
                    byte tmp = bytes[i];
                    for (int j = 0; j < 8; ++j)
                    {
                        yield return (tmp & 1) == 1;
                        tmp >>= 1;
                    }
                }
            }
        }