decodeImageFromPixels method

  1. @Deprecated('Use Image.fromPixels() instead. This method will be removed in v1.2.0')
Future<Image> decodeImageFromPixels(
  1. Uint8List pixels,
  2. int width,
  3. int height, {
  4. bool runAsWeb = false,
})

Converts an array of pixel values into an Image object.

The pixels parameter is the pixel data in the encoding described by PixelFormat.rgba8888, the encoding can't be changed to allow for web support.

If you want the image to be decoded as it would be on the web you can set runAsWeb to true. Keep in mind that it is slightly slower than the native ui.decodeImageFromPixels. By default it is set to kIsWeb.

Implementation

@Deprecated(
  'Use Image.fromPixels() instead. This method will be removed in v1.2.0',
)
Future<Image> decodeImageFromPixels(
  Uint8List pixels,
  int width,
  int height, {
  bool runAsWeb = false,
}) {
  final completer = Completer<Image>();
  ui.decodeImageFromPixels(
    pixels,
    width,
    height,
    PixelFormat.rgba8888,
    completer.complete,
  );
  return completer.future;
}