如何使用canvas.toDataURL()将画布保存为图像?
canvas.toDataURL()
function putImage(){ var canvas1 = document.getElementById("canvasSignature"); if (canvas1.getContext) { var ctx = canvas1.getContext("2d"); var myImage = canvas1.toDataURL("image/png"); } var imageElement = document.getElementById("MyPix"); imageElement.src = myImage; }
<div id="createPNGButton"> <button onclick="putImage()">Save as Image</button> </div>
慕勒3428872
相关分类