toPngBytes method
Convert TxImageSpriteBlock back to a single image for testing/verification startLine and endLine are inclusive
Implementation
Future<Uint8List> toPngBytes() async {
if (_spriteLines.isEmpty) {
throw Exception('_spriteLines is empty: no image to convert toPngBytes()');
}
// create an image for the whole block
var preview = img.Image(width: width, height: height);
// copy in each of the sprites
for (int i = 0; i <= _spriteLines.length; i++) {
img.compositeImage(preview, _spriteLines[i].toImage(),
dstY: (i * spriteLineHeight).toInt());
}
return img.encodePng(preview);
}