Display a dataUrl as an image in a canvas

123 Views Asked by At

I have 2 canvases, I save the first one as a dataURL, and then try to display it on a second canvas. I tried many things but nothing shows up. Here is my code. How can I fix that ?

image = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");

var compCanvas = document.getElementById("final-composition");
var ctx = compCanvas.getContext("2d");
var img = new Image;
img.src = image;
img.width = compCanvas.width;
img.height = compCanvas.height;

img.onload = function(){
    ctx.drawImage(img,0,0);
};
0

There are 0 best solutions below