Page 1 of 1

LÖVE GIF maker

Posted: Mon Feb 24, 2014 7:37 pm
by HugoBDesigner
Hello, guys! My name is Hugo, and I'm new here. I'm not new in LÖVE development, though. I'm from Stabyourself Forums like a few other users here. Well, while "chatting" with some users there, a question appeared: I'm making a mod of a game wrote in LÖVE, and I tried to make an in-game recorder. It works well, but all I can do is export the frames from the recording, but I just haven't figured out how to convert them into GIF. I know it is possible, but not easy. I wonder if some of you guys have something done for it or some kind of "alternative" solution for it.

Oh, and just in case someone already asked it, I'm willing to try making a GIF converter with some help from you guys.

Thanks for the helping!

PS: I'm using LÖVE 0.8.0 for this. The "in-game" recorder is what I used to make my current avatar, but I had to use an external tool to convert the frames into a GIF.

Re: LÖVE GIF maker

Posted: Mon Feb 24, 2014 8:04 pm
by Ranguna259
I think that you'd need the specific gif encoder to do this, which LÖVE doesn't have in it's default decoders/encoders, I might be wrong thought

Re: LÖVE GIF maker

Posted: Mon Feb 24, 2014 9:02 pm
by HugoBDesigner
Yes, I know LÖVE doesn't have this, but, since a lot of people use LÖVE, I thought that perhaps someone managed to make this. If there were a way to "decode" GIFs properly in LÖVE that'd be awesome.

Does somebody here knows how .gif's are wrote? If I managed to learn it, I could make a function for encoding GIFs, like:

encodeGIF(imagesTable, delay(s), loops)

Where "imagesTable" is a table with all the images (imageData), the delay could be a number or a table (to specify the delay to each frame) and loops could be a boolean or number (to specify if it plays once, a number of times or forever).

But thanks for the help, anyway!

Re: LÖVE GIF maker

Posted: Mon Feb 24, 2014 10:59 pm
by Ranguna259
I think you'd have to edit LÖVE's C++ source code and add a gif decode and I don't think anyone has done this already, sorry about that, maybe a dev can help you with this.

Re: LÖVE GIF maker

Posted: Tue Feb 25, 2014 1:37 am
by Xugro
Here is the official GIF specification (33 pages long):

You "just" have to write an encoder. Then you can write the data to a file with love.filesystem.write. Lua-strings can handle the binary data without problems:
Lua is eight-bit clean and so strings may contain characters with any numeric value, including embedded zeros. That means that you can store any binary data into a string.
We can specify a character in a string also by its numeric value through the escape sequence \ddd, where ddd is a sequence of up to three decimal digits. As a somewhat complex example, the two literals "alo\n123\"" and '\97lo\10\04923"' have the same value, in a system using ASCII: 97 is the ASCII code for a, 10 is the code for newline, and 49 (\049 in the example) is the code for the digit 1.

Re: LÖVE GIF maker

Posted: Tue Feb 25, 2014 2:54 am
by HugoBDesigner
I already used the string-to-file thing for a data downloader, but this is FROM FAR much more complicated. I thought: "Perhaps .png files and .gif files are similar, but .gif files are just a kind of 'pack' of .png's." I was horribly wrong.

Anyway, thanks for the help, guys! I think I'll have to check something like this in the future, and IF someone manages to get them to work with LOVE. Again, thanks for the help!