Draw normal or xmb bitmap (1 bit, 8 pixels per byte.)
This will break up large bitmaps in to multiple batches of grouped scanlines. The future returned completes with the success of all work.
Source
Future<bool> bitmap(
int x, int y, int width, int height, int color, Iterable<int> bytes,
{int background, bool xmb: false}) {
// num pixels wide / 8 pixels per byte.
int scan = (width / 8).ceil();
// either 49 or 47 bytes for per-packet data (sucks).
int linesPer =
(ArdProto.maxDataLength - ((background == null) ? 10 : 12)) ~/ scan;
var work = [];
for (int i = 0; i < height; i += linesPer) {
var h = (height - i).clamp(0, linesPer);
proto.log("scan: $i height: $h");
var fut = proto.write(
(background == null ? 15 : 16) + (xmb ? 2 : 0),
_s2b(x)
..addAll(_s2b(y + i))
..addAll(_s2b(width))
..addAll(_s2b(h))
..addAll(_s2b(color))
..addAll(background == null ? const <int>[] : _s2b(background))
..addAll(bytes.skip(scan * i).take(h * scan)));
work.add(fut);
}
return Future.wait(work).then((work) => work.every((e) => e == true));
}