Page 2 of 2

Re: Resizing screenshots so that they don't make my save files 10MB

Posted: Sat Oct 22, 2016 8:57 pm
by zorg
Rhinoceros wrote:
s-ol wrote: you use bitser.dumps and bitser.loads to save/load tables into strings you can then store where/however you want.
Ahh, ok. I got it to serialize the save data, but if I try to put filedata in the table, it throws an error. How should I go about writing filedata to a file as part of a table?
zorg wrote:- Get the small canvas' imagedata (Canvas:newImageData), encode that as 'png', receiving a FileData, which you can do :getString on, so you now have a string representation of the PNG image. combine it into your savefile, and it should be small enough.
yourtable.previewimage = canvas:newImageData():encode('png'):getString() -- as a string.

Re: Resizing screenshots so that they don't make my save files 10MB

Posted: Sat Oct 22, 2016 9:15 pm
by Rhinoceros
zorg wrote:
Rhinoceros wrote:
s-ol wrote: you use bitser.dumps and bitser.loads to save/load tables into strings you can then store where/however you want.
Ahh, ok. I got it to serialize the save data, but if I try to put filedata in the table, it throws an error. How should I go about writing filedata to a file as part of a table?
zorg wrote:- Get the small canvas' imagedata (Canvas:newImageData), encode that as 'png', receiving a FileData, which you can do :getString on, so you now have a string representation of the PNG image. combine it into your savefile, and it should be small enough.
yourtable.previewimage = canvas:newImageData():encode('png'):getString() -- as a string.
Oh. Yeah. That would make sense. I probably should've figured that out :X

Well, it works now! Thanks everyone!