private void FillSymbol(int i, int j, Bitmap pattern, BitArray sampleData, ref int index) { var pixelTracker = new BitmapPixelTracker(_settings.PixelsLookupDirection) { XStart = i, XEnd = _settings.SymbolWidth + i, XDelta = 1, YStart = j, YEnd = _settings.SymbolHeight + j, YDelta = 1 }; foreach (var pixel in pixelTracker) { // If there was not enough data, just skip the symbol (leaves cell empty) if (index >= sampleData.Length) { return; } var pixelValue = sampleData.ToByte(index, _settings.BitsPerPixel); pattern.SetPixel(pixel.X, pixel.Y, Colors[pixelValue]); index += _settings.BitsPerPixel; } }