bg1R * (1 - alpha)) / alpha;
      in1[i + 1] = (in1G - bg1G * (1 - alpha)) / alpha;
      in1[i + 2] = (in1B - bg1B * (1 - alpha)) / alpha;
      in1[i + 3] = alpha * 255;
    }
    $out.width = width;
    $out.height = height;
    $out.getContext("2d").putImageData(imgData, 0, 0);
  };
</script>
