save canvas to image and then show on your div
- create empty Image() object
- convert canvas to DataURL image file
- create HTML element for img
- Inject imageURI to new HTML element source
- append your HTML element to document.
- Inject imageURI to your Image() object source
let myImage = new Image();
let imageURI = this.myCanvas.toDataURL("image/png");
let newImageElement = document.createElement('img');
newImageElement.setAttribute("id", "new-image");
newImageElement.src = imageURI;
document.body.appendChild(newImageElement);
this.myImage.src = imageURI;
funny thing I found.
image/jpg, image/png: saves transparent background
image/jpeg: saves transparent area as black color
Top comments (0)