[Solved!] Resizing screenshots so that they don't make my save files 10MB

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

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

Post 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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
Rhinoceros
Prole
Posts: 35
Joined: Mon Jun 11, 2012 2:59 am
Location: Under the Floorboards

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

Post 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!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 191 guests