pixels property

  1. @override
Future<PCanvasPixels> get pixels
override

Returns the pixels of this canvas. See PCanvasPixels.

Implementation

@override
Future<PCanvasPixels> get pixels async {
  final image = await toImage();

  final byteData =
      await image.toByteData(format: ui.ImageByteFormat.rawStraightRgba);

  var data = byteData!.buffer
      .asUint32List(byteData.offsetInBytes, byteData.lengthInBytes ~/ 4);

  return PCanvasPixelsABGR.fromPixels(image.width, image.height, data);
}