0

The following question Merge Image using Javascript has some good answers to it.
But the answers only have javascript and not the html context where they are in.

var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var imageObj1 = new Image();
var imageObj2 = new Image();
imageObj1.src = "1.png"
imageObj1.onload = function() {
    ctx.drawImage(imageObj1, 0, 0, 328, 526);
    imageObj2.src = "2.png";
    imageObj2.onload = function() {
        ctx.drawImage(imageObj2, 15, 85, 300, 300);
        var img = c.toDataURL("image/png");
        document.write('<img src="' + img + '" width="328" height="526"/>');
    }
};

var canvas = canvasBuild.getContext('canvasObj');
var img = document.getElementById('mergePic1');
canvas.drawImage(img, 0, 0);

What would be a full working example with the html code?

Community
  • 1
  • 1

0 Answers0