<canvas id="canvas1" ...> <!--源//-->
<canvas id="canvas2" ...> <!--目的//-->
<img id="testImg" src=""> <!--测试//-->
场景:
2个canvas;1个img
canvas1显示内容,接着将内容复制到canvas2里面。
实现:
var img = canvas1Context.toDataURL('image/jpeg');
img.replace(/^data:image\/(png|jpg);base64,/, "");
myTestImg.src = img;//显示成功!
var imggg = new Image();
imggg.src = img;
//img.length //7259
canvas2Context.drawImage(imggg, 0, 0, 320, 480);
//黑底,无图像,无报错
//png格式是白底,同样无图像