I'd like to copy ALL contents of one canvas and transfer them to another all on the client-side. I would think that I would use the canvas.toDataURL()
and context.drawImage()
method to implement this but I am running into a few issues.
My solution would be to get Canvas.toDataURL()
and store this in an Image object in Javascript, and then use the context.drawImage()
method to place it back.
However, I believe the toDataURL
method returns a 64 bit encoded tag with "data:image/png;base64,"
prepended to it. This does not seem to be a valid tag, (I could always use some RegEx to remove this), but is that 64 bit encoded string AFTER the "data:image/png;base64,"
substring a valid image? Can I say image.src=iVBORw...ASASDAS
, and draw this back on the canvas?
I've looked at some related issues: Display canvas image from one canvas to another canvas using base64
But the solutions don't appear to be correct.