canvasToImageElement function

ImageElement canvasToImageElement(
  1. CanvasElement canvas, [
  2. String? mimeType,
  3. num? quality
])

Converts canvas to ImageElement

mimeType MIME-Type of the image. quality Quality of the image.

Implementation

ImageElement canvasToImageElement(CanvasElement canvas,
    [String? mimeType, num? quality]) {
  mimeType ??= 'image/png';
  quality ??= 0.99;

  var dataUrl = canvas.toDataUrl(mimeType);
  var img = ImageElement(src: dataUrl);
  img.width = canvas.width;
  img.height = canvas.height;
  return img;
}