I have 3 canvases. I crop a region from canvas1 and display it on canvas 2 . Then I want to convert canvas 2 image to a URL and to see if can convert that URL back to a image. I want it to be displayed in canvas c4.Any help is appreciated.
// image is drawn here , I want this image to be converted to a dataURL //then back to image and display it in canvas c4 var c2 = document.getElementById("area_c2"); var ctx = c.getContext("2d"); var ctx2 = c2.getContext("2d"); image_src.width = c2.width; image_src.height = c2.height; ctx2.drawImage(image_src, 0, 0,image_src.width, image_src.height); var c4 = document.getElementById("area_c4"); var ctx4 = c4.getContext("2d"); var dataURL = c2.toDataURL(); var myImg = new Image; myImg.src = dataURL; myImg.width = c4.width; myImg.height = c4.height; ctx4.drawImage(myImg, 0, 0, image_src.width, image_src.height); //Image //is not displayed here , I want the image to take the size of the canvas <canvas id ="area_c2" style="width:300px;height:300px;border:3px solid black;z-index:1" > </canvas> <canvas id ="area_c4" style="width:300px;height:300px;border:3px solid black;z-index:1;background:red"> </canvas>