<Canvas> contents as data?
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!!
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.
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.
精彩评论