6

Is there a way to speed how fast kivy will load an animated gif? Does kivy have any methods built in such as compression or other options? What I'm doing is using the animated gif as a background for the home screen of my app. It is the matrix, which has about 30 different frames to create the desired affect.. With 30 frames I'm not expecting this to be super fast, but 5-10 seconds for a single aniamted gif to load seems a bit much.

2
  • Kivy supports animating a series of images in a .zip file - I think partly because this is better supported (and maybe faster) across different platforms. You could try this instead.
    – inclement
    Nov 19, 2015 at 11:38
  • I think there's an example of using zip files in the Kivy examples folder. See here and, for the kv file, here. Nov 19, 2015 at 12:35

2 Answers 2

8

I believe this may help you, I had a series of png files that I wanted to animate into an explosion, and this was a game where the explosions were constant. Initially, every time the animation took place, the game stalled and stuttered horribly. This is what I did to get my game to run smoothly. I zipped the png files, and used the following code to preload them, which I placed in the __init__ method of the Screen widget that the images appeared on.

load_zipped_png_files = Image(
    source = 'explosion.zip', 
    anim_delay = 0,
    allow_stretch = True, 
    keep_ratio = False,
    keep_data = True)

I believe the keep_data option allows for the preloading of the images( into a cache I imagine ), which saves the program from having to reload them every time they are used.

Now it could be that I am mistaken about the role keep_data is playing here ( and if someone reading this knows better, please do correct me ), but zipping the files and using them in this way definitely made the animations acceptably smooth. You could test it with and without keep_data = True and figure it out yourself.

0
2

For me it simply worked as i needed to gifs extension images:

Image(
source= 'image.gif', 
anim_delay= 0,
mipmap= True,
allow_stretch= True)

It was added mipmap, so that enhances the textures using OpenGL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.