Finally, apng support is done! (ignoring any bugs which may still be present in the code ofc

)
Builds*** See the nightlies for current builds ***Here are builds including FRED (because, why not now that I can compile it, hurrah for 2015 community edition
)
http://www.mediafire.com/download/dpyiizm5ncnityg/fso_apng.7z
The code is now in a PR if there's anyone else interested in looking at it:
https://github.com/scp-fs2open/fs2open.github.com/pull/537Simple APNG creationHere's steps on how to create simple APNGs.
1) Create your animation in your favourite animation application and save it as a PNG file stream. It'll be easiest if the frames are named in ascending order; e.g. anim_0000.png, anim_0001.png, etc (not strictly needed but
much easier). Remember you have 24 bit colour & 8 bit alpha available, there's no need for any custom palette's or special transparency colours.
2) Get an apng assembler. There's a
bunch available on the internet, online only versions, local installs, command line and GUI. I've personally used the
apngasm command line version so that's what I'll use in my example.
Latest apngasm source (3.1.6)
Latest Windows 64bit executable (3.1.3)
For OSX they say use homebrew; I have no idea how to do this, sorry!
Note that the
Japng Editor allows you to open up apngs and see exactly what each frame is doing, e.g. when the assembler has chosen to use delta frames vs complete frames, etc.
3) Use the assembler to create your apng
You need to know what frame delay you want between all frames... and that's it for a simple animation.
Here's an example using frames exported from the mediavps_2014 intelligence ANI file for "Earth" (I used aniview32 to export the frames to BMPs, then imagemagick to convert them to 24bit PNGs). The FPS for the ani is 15.
apngasm -d 67 -o 2_intel_earth.png 2_intel_earth_0*.png
-d specifies the default frame delay for each frame
-o specifies the output name, for FSO we'll use the .png extension
The last set of arguments is all the frames in animation order
4) Configure the apng within FSO
In my example, copy 2_intel_earth.png to FSO/mod/data/intelanims
And that's it!
Using APNGs in FSOThe places in FSO where I think APNGs make most sense are:
- Command Brief Anims
- Intel Anims (techroom)
- Loading Screen Anim
- HUD Anims (e.g. headz, lock, etc)
- Mainhall animations
You CAN use apngs for any other animation if you wish, e.g. animated glows, weapon impact effects, explosions, shield anims, etc. However, EFF with DDS would generally be a better choice because they're compressed in a format your video card can use, and thus they use much less video RAM.
Having said that, in many cases the apng files on disk (only) will be smaller than other animation formats which can mean reduced modpack sizes. e.g. the 2_intel_earth.png file is 7.5MB, compared with 15MB for the mediavps_2014 ANI file. Likewise a certain EFF+PNG headani was 3.8MB as png frames, the apng was 2.1MB. Note that this reduction heavily depends on the content of the apng. From some rough tests done by Axem & myself it seems that apngs with a transparent background, and an object moving through said background will probably fair poorly. One such example was only reduced from 11MB to 9.9MB. This is because the best compression method is diff/delta frames composed over the previous frame, and it can't draw a transparent pixel over top a non-transparent one. Therefore with a transparent background the frame needs to get completely redrawn, making the filesize larger.
Lastly, FSO uses the .png extension for apngs, not .apng (
see here for more info on why if you're curious)
Advanced APNG creationThere are some more advanced options for creating apngs which may be of use in certain circumstances.
1) Per Frame Delays
You can give each frame in the animation it's own delay, different to every other frame in the animation. To do this, just put the individual frame delay after the frames source image.
i.e.
apngasm -d 67 -s -o 2_intel_earth.png 2_intel_earth_renamed_0000.png 500 2_intel_earth_0*.png
This makes the 1st frame play for 500 ms, and all the other frames have a 67ms delay.
Note that the most recent versions of apngasm
will do this for you if you include duplicated frames in your sequence. i.e. if you have 50 frames and two sequential frames are the same, then apngasm will create an apng with 49 frames, where one frame has double the frame delay of the rest.
2) Loading APNGs as PNGs
FSO will happily load an apng as a static image if you load it as an image rather than an animation. This is a bit hard to control for stuff internal to FSO, but you've got full control over this in LUA. Anyway, this could save you putting extra files in your mod, by default the 1st frame of the animation will be loaded as the static image. Or you can put any frame you like as the "1st frame" and tell apngasm to skip than frame when playing back as an animation.
i.e.
apngasm -d 67 -s -o 2_intel_earth.png special_1st_frame.png 2_intel_earth_0*.png
-s is the option to skip the 1st frame
special_1st_frame.png is the 1st argument without a preceeding option and thus is the 1st frame processed by apngasm
Maybe this could be of use if you wanted to (e.g.) have a selectable pilot image that's also the 1st frame in that pilots head ani (I dunno, I'm not sure if there's any real use cases for this or not, but as long as everyone knows about the option then people could think up tricky uses for it).
3) Looping
APNG's can set the number of times that they will loop. However, FSO ignores this in favour of the code controlling how any given animation will loop (e.g. cbanims always loop, headanis never loop, etc). So don't worry about the loop value as FSO will ignore it.
So, I think that's enough words from me; please post if you have any questions, or if you have used any other apng assembers with good results.
edit: updated formatting & merged in useful info from Axem