Saving and restoring a canvas content

Game Editor comments and discussion.

Saving and restoring a canvas content

Postby elfdav » Tue Sep 18, 2012 1:13 pm

Hi guys,

I'm writing a little paint-like software.

Is there a simple way to save and restore a canvas content to a given file format like .png or jpg ?

I saw methods called "savecanvas" and "restorecanvas" but i got some difficulties to use that.

The goal is pretty simple: i would like to draw something into my canvas actor, then save it. After that the user will be free to restore it to continue its draw.

Thanks for your answers and suggestions

David
elfdav
 
Posts: 14
Joined: Sat Feb 14, 2009 4:18 pm
Score: 0 Give a positive score

Re: Saving and restoring a canvas content

Postby skydereign » Tue Sep 18, 2012 8:20 pm

As you mentioned in your pm, savecanvas doesn't create an actual file. Because of this it can only be used for undo type functionality. Also canvas doesn't have a built in way of accessing individual pixels in the canvas (which you need to be able to write it). So you need to create a large array to represent the drawable surface of the canvas. And when you would change a pixel on the canvas, you change a pixel in the array. You won't be able to make a png from this, as png files are really complex, and we don't have access to the proper library, but bmp is very simple. If you search the forums there are plenty of good examples.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest