2009-10-12: SDL_image with APNG support
The changes made so far are based on SDL_image-1.2.7 - download changes.

Taking the original SDL_image::IMG_PNG.c code, I've added APNG support. My intention was to create a patch to submit to the SDL_image project, but it dawned onto me that the changes I've made doesn't fit the SDL_image architecture. Currently, the image needs to be pumped every frame to update the animation.

Also, normally, a surface is returned from the image loader and no further action is necessary from SDL_image. But since APNG is an animation, any subsequent access to the returned surface needs to be handled carefully - it may be deleted at anytime by the user:


Future Implimentation
It is very likely this will have to be separated out from SDL_image and designed like SMPEG or SDL_mixer. A handle would be returned for safer implimentation and usage (as it is currently done). The next step would be to thread off the update and remove the need to pump the APNG handle every frame.

NOTE: not all A/PNG specs are properly handled. There seems to be a pile of options and they are spread out all over the place. While, the current version I have will handle a bunch of APNG files, the notable one it does NOT support is:

Inside the download
I have packed up my files with some example images to test with into the tar ball listed at the top of this page. Inside the archive contains the patch file to IMG_PNG.c (if you need it). But I would recommend just looking at and trying out the apng_test.c file. It contains all of IMG_PNG.c with my changes along with a simple test function to execute.

To compile and run apng_test.c:

What I really want...
I was hoping to use APNG with frame jumping access - but they way libpng is currently writen, I do not see an easy way to target a particular frame. If any one has any info on that, I would love to hear it. I would hate to have to keep re-scanning the whole image file everytime until a reach the frame by constantly calling:

	png_read_image(png_ptr, row_pointers);
Yes, I know that there may be issues with the DISPOSE OPs - but that's something I will worry about later. =)

Copyright © 2009 by Nick Shin. All Rights Reserved.
These pages are designed by ESTSS.