我们在克隆HTML5画布元素上看到了这篇文章:Any way to clone HTML5 canvas element with its content?
我们尝试使用jQuery (即$(canvas ) .clone(true) )进行深度克隆,但图像数据似乎没有复制过来。
这在jQuery中是不可能实现的吗?
发布于 2012-10-24 02:28:54
如果您不需要复制任何附加的事件处理程序(一般来说,我怀疑这是可能的),那么我将使用当前被接受的Display canvas image from one canvas to another canvas using base64解决方案
//grab the context from your destination canvas
var destCtx = destinationCanvas.getContext('2d');
//call its drawImage() function passing it the source canvas directly
destCtx.drawImage(sourceCanvas, 0, 0);
当然,您必须首先创建目标画布,因此,在此之前,您必须:
var destinationCanvas = document.createElement('canvas');
destinationCanvas.width = sourceCanvas.width;
destinationCanvas.height = sourceCanvas.height;
https://stackoverflow.com/questions/13041783
复制