Is it possible to display animated .gif in libgdx?

Anything libgdx related goes here!

Is it possible to display animated .gif in libgdx?

Postby aljosa » Sat Mar 02, 2013 5:50 pm

As title says, is this possible and if it is I would like to see some code example if possible.
Currently, I have animated gif for company logo. Animation packed in gif is small and what is more important, all timings are correct.
If i try to make animation frame by frame it would be MUCH bigger (file size) and it would be extremely hard for me to match exact animation timing.

My current code is something like:
Constructor:
Texture logo = new Texture(Gdx.files.internal("data/logos/MyLogo.gif"));
render() method:
guiCam.update();
batch.begin();
batch.setProjectionMatrix(guiCam.combined);
batch.draw(logo , 200, 200);
batch.end();

This code draws gif on the screen but it is just first frame of the animation. :(
aljosa
 
Posts: 52
Joined: Fri Nov 18, 2011 8:23 am
Location: Novi Sad, Serbia

Re: Is it possible to display animated .gif in libgdx?

Postby Pinkie Swirl » Sat Mar 02, 2013 11:39 pm

aljosa wrote:If i try to make animation frame by frame it would be MUCH bigger (file size) and it would be extremely hard for me to match exact animation timing.

Why would it be hard to time correct?
Just use the different layers of the gif, pack them on one texture and wait for the time to change the texture region.

As far as I know, libgdx doesn't support animated gifs.
Pinkie Swirl
 
Posts: 814
Joined: Thu Sep 20, 2012 8:55 pm


Return to Libgdx

Who is online

Users browsing this forum: No registered users and 1 guest