Hello everyone,
Is there a way to save a canvas element's content to data such as binary? I'm looking to be able to redraw this data when needed.
Not really sure on how to go about it..
Thanks so much!!
Hello everyone,
Is there a way to save a canvas element's content to data such as binary? I'm looking to be able to redraw this data when needed.
Not really sure on how to go about it..
Thanks so much!!
I suppose you can send the innerHTML of whatever element contains the canvas element back to the server using AJAX and then zip it up server side.
However, this would be grossly inefficient to an alternate method of creating a data-based representation of of the content, and just storing that without all the unnecessary overhead of actual HTML markup.
You should be able to save the image into a variable like so:
var imageVar = canvasObject.toDataURL();
, and restore it again by calling canvasObject.drawImage(imageVar);
I haven't tested it yet, but the spec says it should work.