function insertImage(ctx, x, y) {
  const layer = this.getCurrentLayer();
  if (layer === null) return;
  const batch = layer.createBatchAt(x, y);
  const view = ctx.canvas;
  const width = view.width; const height = view.height;
  const data = ctx.getImageData(0, 0, width, height).data;
  const ww = width - 1; const hh = height - 1;
  batch.resizeRectangular(
    x, y,
    width - 1, height - 1
  );
  let count = 0;
  for (let ii = 0; ii < data.length; ii += 4) {
    const idx = (ii / 4) | 0;
    const xx = (idx % width) | 0;
    const yy = (idx / width) | 0;
    const px = (yy * width + xx) * 4;
    const r = data[px + 0];
    const g = data[px + 1];
    const b = data[px + 2];
    const a = data[px + 3];
    if (a <= 0) continue;
    batch.drawPixelFast(x + xx, y + yy, [r, g, b, alphaByteToRgbAlpha(a)]);
    count++;
  };
  // nothing changed
  if (count <= 0) {
    batch.kill();
    return;
  }
  batch.refreshTexture(true);
  batch.resizeByMatrixData();
  this.enqueue(CommandKind.INSERT_IMAGE, batch);
  return;
}
@param {CanvasRenderingContext2D} ctx
@param {Number} x
@param {Number} y
@return {Void}