createImageFromImageBitmap function

FutureOr<Image> createImageFromImageBitmap(
  1. JSAny imageSource
)

Creates a ui.Image from an ImageBitmap object.

The contents of the ImageBitmap must have a premultiplied alpha. The engine will take ownership of the ImageBitmap object and consume its contents.

See https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap

Implementation

FutureOr<ui.Image> createImageFromImageBitmap(JSAny imageSource) {
  if (!domInstanceOfString(imageSource, 'ImageBitmap')) {
    throw ArgumentError('Image source $imageSource is not an ImageBitmap.', 'imageSource');
  }
  return renderer.createImageFromImageBitmap(
    imageSource as DomImageBitmap,
  );
}