pack1Bit static method

Uint8List pack1Bit(
  1. Uint8List bpp1
)

Implementation

static Uint8List pack1Bit(Uint8List bpp1) {
  int byteLength =
      (bpp1.length + 7) ~/ 8; // Calculate the required number of bytes
  Uint8List packed =
      Uint8List(byteLength); // Create the Uint8List to hold packed bytes

  for (int i = 0; i < bpp1.length; i++) {
    int byteIndex = i ~/ 8;
    int bitIndex = i % 8;
    packed[byteIndex] |= (bpp1[i] & 0x01) << (7 - bitIndex);
  }

  return packed;
}