toPackedRows method

Uint8List toPackedRows({
  1. bool blackIsOne = true,
})

Implementation

Uint8List toPackedRows({bool blackIsOne = true}) {
  final int rowBytes = (width + 7) >> 3;
  final Uint8List out = Uint8List(rowBytes * height);
  for (int y = 0; y < height; y++) {
    for (int x = 0; x < width; x++) {
      final int value = data[y * width + x];
      final bool bit = blackIsOne ? value == 0 : value != 0;
      if (bit) out[y * rowBytes + (x >> 3)] |= 0x80 >> (x & 7);
    }
  }
  return out;
}