fromBytes method

Future<void> fromBytes(
  1. Uint8List rgba,
  2. int width,
  3. int height
)

Creates texture from raw RGBA bytes.

Implementation

Future<void> fromBytes(Uint8List rgba, int width, int height) async {
  final completer = ui.ImmutableBuffer.fromUint8List(rgba);
  final buffer = await completer;
  final descriptor = ui.ImageDescriptor.raw(
    buffer,
    width: width,
    height: height,
    pixelFormat: ui.PixelFormat.rgba8888,
  );
  final codec = await descriptor.instantiateCodec();
  final frame = await codec.getNextFrame();
  _image = frame.image;
  _width = width;
  _height = height;
  _loaded = true;
}