fromPixels static method

Future<Image> fromPixels(
  1. Uint8List pixels,
  2. int width,
  3. int height
)

Converts a raw list of pixel values into an Image object.

The pixels must be in the RGBA format, i.e. first 4 bytes encode the red, green, blue, and alpha components of the first pixel, next 4 bytes encode the next pixel, and so on. The pixels are in the row-major order, meaning that first width pixels encode the first row of the image, next width pixels the second row, and so on.

Implementation

static Future<Image> fromPixels(Uint8List pixels, int width, int height) {
  assert(pixels.length == width * height * 4);
  final completer = Completer<Image>();
  decodeImageFromPixels(
    pixels,
    width,
    height,
    PixelFormat.rgba8888,
    completer.complete,
  );
  return completer.future;
}