SOLVED
Ok so that doesn't seem hard looking back. Naming conventions may be a bit confusing, but after trial and error and lots of careful debugging steps it gets clearer.
Obviously, first of all you drop giflib and lice_gif from WDL folder into your project.
Then you need to load a png file in a usual way, with LoadIBitmap(). This file will be your base layer to where each next gif frame will be copied. Hence you want its width and height to match that of the gif. Its content is ignored. I drew a smiley face to cheer myself up.
There's no convenient function to load gif from the resource as in LICE_LoadPNGFromResource(), so for starters I defined the _full_ name of my animated gif in resource.h.
Then you build your custom control class that handles gifs. In that class you add a member of type lice_gif_read_ctx*. It will hold all the gif data. It can actually be void*, but I stick to the concrete type for debugging purposes.
And another member will be IBitmap that you initiate with the result of that LoadIBitmap(<base png ID> <base png filename>).
So you have something like
private:
IBitmap frame;
lice_gif_read_ctx* gif;
Then somewhere (say, in the constructor) you do
gif = (lice_gif_read_ctx*)_LICE::LICE_GIF_LoadEx(<full filename to your gif>);
In each Draw() you can copy the next gif frame to your Bitmap and draw it:
_LICE::LICE_GIF_UpdateFrame(gif, (LICE_IBitmap*)(frame.mData));
pIGraphics->DrawBitmap(&frame, &mRECT);
And of course in the destructor you must
LICE_GIF_Close(gif);
It looks like you have to manually use LICE_GIF_GetFilePos(gif) and LICE_GIF_Rewind(gif) to loop through.
Also, I did not yet solve the problem of adding the whole gif as an independent resource to work with after compilation.
Last edited by 1eqinfinity; 06-14-2017 at 07:22 AM.
|