renderToPng method
Renders the skeleton drawable's current pose to a PNG encoded in a Uint8List, with the given width
and height
.
Uses bgColor
, a 32-bit ARGB color value, to paint the background.
Scales and centers the skeleton to fit the within the bounds of width
and height
.
Implementation
Future<Uint8List> renderToPng(double width, double height, int bgColor) async {
final recorder = renderToPictureRecorder(width, height, bgColor);
final image = await recorder.endRecording().toImage(width.toInt(), height.toInt());
return (await image.toByteData(format: ImageByteFormat.png))!.buffer.asUint8List();
}