These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:10 pm Advanced search

Sanving and Restoring Canvas

Here you can discuss things related to HTML and the Web in general that do not fit in to other categories.

Sanving and Restoring Canvas

Postby emurillo » Fri Jan 14, 2011 6:08 pm

I need to save my canvas and then restore it, so i can continue with my previous work. I'm working on a software for a Dentist, and doing an odontogram (I's like a graphicall representation of every tooth in your mouth, and each tooth is divided in 5 parts), the idea is to paint the parts that are damage or need treatment. The bottom line is that I need to save a patient status and be able to load it every time.

I've done some research and I haven't found a solution

any help would be appreciated
emurillo
<h6>
 
Posts: 1
Joined: Fri Jan 14, 2011 5:39 pm

Re: Sanving and Restoring Canvas

Postby zcorpan » Wed Mar 30, 2011 4:48 pm

You can get a PNG (or JPEG) image from a canvas with canvas.toDataURL(). You can then upload that to your server with XHR to save it on the server, and next time pull it with XHR and put it in an <img src> which you then draw on the canvas with drawImage(). If you don't want to involve the server but save it locally, you can use localStorage. If you want to save more state than just the pixels, you need to implement the logic for that yourself.
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest