public static void Main()
.Select((pixel, index) => (pixel, index))
.GroupBy(pixelWithIndex => pixelWithIndex.index / 8)
.Select(g => (byte)g.Sum(
pixelWithIndex => CheckPixel(pixelWithIndex.pixel) * Math.Pow(2, (pixelWithIndex.index % 8))
static int CheckPixel(int pixel)
return pixel == 0 ? 0 : 1;