pouët.net

looking for animated gif library

category: code [glöplog]
 
if anyone has used or know about a lib in c/c++ language with easy access to memory-buffer and saving to file i would like to hear about it

the idea is to generate a html file with the gif-files so that i can watch them running in parallell in for example a webpage. its better to do that than watching them one-by-one (ive done that before and its paaaaaain).
another reason for this is that its easier to notice ca's that shows interesting behaviour. when i waded through these i found some with interesting fluid-behaviour, but now i dont want to go into all this in detail, but to the topic.
added on the 2012-06-09 21:11:04 by rudi rudi
its like 65536 gif files.
added on the 2012-06-09 21:14:11 by rudi rudi
Sounds like a job for ImageMagick.
added on the 2012-06-09 21:40:34 by gasman gasman
cool. gonna check that out!
added on the 2012-06-09 22:42:34 by rudi rudi
try 2gif. proprietary thing
I put together a small library a couple of years ago that takes a 32-bpp image (could be adjusted to 24-bit by changing the PIXEL_SIZE define), reduces it to 8-bit, GIF-encodes it and writes each resulting frame to a GIF anim file with a delay that you specify: http://jiggawatt.org/badc0de/android/index.html#gifflen

I wrote this to be used on Android via JNI, so if you'd want to use it on some other platform you'd have to rename a few function. E.g.

Code:JNIEXPORT jint JNICALL Java_org_jiggawatt_giffle_Giffle_AddFrame(JNIEnv *ioEnv, jobject ioThis, jintArray inArray)


should be changed to

Code:int Giffle_AddFrame(char *inArray)


You'd also have to remove the references to ioEnv and __android_log_write. E.g.

Code:ioEnv->GetIntArrayRegion(inArray, (jint)0, (jint)(inDIB.width * inDIB.height), (jint*)(inDIB.bits));


would become

Code:inDIB.bits = (unsigned char*)inArray;


added on the 2012-06-10 10:07:16 by mic mic
mic: thanks. it worked with a bit of hacking.
Code: j = contest(b, g, r); altersingle(alpha,j,b,g,r);
crashed, but worked after commenting them out. i dont have too much time to debug. i changed optDelay to 1, but the playback is still quite slow.
added on the 2012-06-10 17:00:04 by rudi rudi
ah, it runs faster in firefox rather than internet explorer. juhuu :)
added on the 2012-06-10 17:17:10 by rudi rudi
Your description of the problem isn't 100% clear, but isn't all you want to do taking a list of GIF's and spam them into HTML files? I think even the Windows commandline is powerful enough to do that. It's absolutely trivial.
Quote:
Code: j = contest(b, g, r); altersingle(alpha,j,b,g,r);

crashed, but worked after commenting them out. i dont have too much time to debug. i changed optDelay to 1, but the playback is still quite slow.


Hmm.. removing those lines would break the color quantiser. What kind of image data did you pass to AddFrame? 8-bit? 24-bit? 32-bit?
added on the 2012-06-11 09:40:30 by mic mic
mic: hm, 32bit.
added on the 2012-06-11 12:01:53 by rudi rudi
The most difficult part of GIFs it fyou're rollnig your own file writes is the compression. You can always generate (in effect) uncompressed GIF files (link me beautiful) and then use some form of GIF optimizer to apply actual compression. You still need a color quantizer of course.

Another way if you just want to get things working is to use an image sequence + AVISynth + VirtualDub's export to GIF option.
Step 1: Write your data to a sequence of BMP files. file0.bmp, file1.bmp and so on.
Step 2: AVISynth is a scripting language for processing video data. It can do all sorts of things like resizing and applying other effects in a deterministic way. To import the video, you just need a script with a single line:

Code:ImageSource("c:\path\to\file%05d.bmp", start=1, end=9001, fps=60, pixel_type = "RGB24")

%05d assumes padding the number to five digits. Adjust start, end and fps to taste.

Step 3: Open the script n VirtualDub, which now treats it like any ol' video file. File, export, animated GIF.
added on the 2012-06-11 14:57:52 by nitro2k01 nitro2k01
nitro2k01: mic's avi writer seem to work quite ok, still me managing to get some buggy code out of it. gif, though, takes gigabytes of gif-data, the tests i did where like 2% complete so my hd-wont take big amount of data like this. it will be terabytes in the end, so might have to consider another better compression-encoding option. i need to do render the files the fastest way as possible as well, one file will take about 5 seconds in the simulation before it starts on the next file etc.. writing to file and then doing some kind of batch-scripting would require some timing-issues with my c-code, i can imagine it being pain unless i communicate AVISynth via some message handling code? (i bet they wont encode at the same speed or time). so the point is, if im going to write raw-data i have to delete the raw-still-image files after the movie file is done rendering and continue forward with the rest of the thousands of simulations. best thing is to render the files directly from the code, but thanks for the idea it might be the last option if i dont get the other options to work properly.
added on the 2012-06-11 16:07:13 by rudi rudi
Maybe you should consider writing APNGs instead - In their simplest form they are basically several PNG files packed into one file. PNG usually compressed better than GIF, but for really good compression you might need some additional tools which will remove static parts of the animated PNG, just like it's usually done with GIFs.
SagaMusic: APNG? as long as if its displayable in a browser. static is going to be alot of. so need lossless-data (or very lose to lossless) compression.
added on the 2012-06-11 16:23:22 by rudi rudi
Gargajud: nice, i will check that out as well!
added on the 2012-06-11 16:26:01 by rudi rudi
Depends on the browser of your choice. Most big browsers have APNG support, apart from IE I guess, and Chrome requires a plugin...
An obvious advantage would be that you don't have to dither the colours to 8-Bit but keep the full 24-Bit range.
The problem with MNG is that it's supported by virtually no browsers...
SagaMusix: its enough with 2-bit color. black and white :P (im not kidding) really. its just "particle simulations" for this specific thing.
added on the 2012-06-11 17:15:44 by rudi rudi

login