encodePng function

Future<Uint8List> encodePng(
  1. dynamic image
)

Encodes an Image object into a PNG format byte array.

Parameters:

  • image: The Image to encode.

Returns a Future that completes with the encoded image data as a Uint8List.

Implementation

Future<Uint8List> encodePng(Image image) async {
  final byteData = await image.toByteData(format: ImageByteFormat.png);
  return byteData!.buffer.asUint8List();
}