Reputation: 11635
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.
Upvotes: 6
Views: 4448
Reputation: 21
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.
Upvotes: 2
Reputation: 7369
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.
Upvotes: 8