Hello everyone!
I saw some topics about GIF on canvas, but not found what i need.
To “play” a gif on canvas, do i need to split the image frame by frame, or is there another way to do?
Alex
Hello everyone!
I saw some topics about GIF on canvas, but not found what i need.
To “play” a gif on canvas, do i need to split the image frame by frame, or is there another way to do?
Alex
docu said GIF is supported at Android, macOS, Windows.
could be .ImageAt( what you need? and .ImageCount
I’ve looked into this. There’s no built in way to play a gif this way. Someone correct me if I’m wrong, but I believe the built in Picture class will only return the first frame.
You will need to write something to parse the binary, extract and render each frame and its associated timing metadata. Then you’ll need to draw each frame in the correct time intervals. It can get tricky because some gifs do not store the full frame data, they store differential data, only the changes from one frame to the next.
I did some experimentation on this and after about 6 hours I gave up and used an HTMLViewer.
If you’re only targeting Windows you can also try the AniGif Active-X control. I used to use it on VB6 projects and it’s still around via a Google Search.
i confirm. Xojo 2025r2 behave so. i made a test project.
its unexpected we can load a animated file with the Picture class but only the first image is used?
as workaround make a image strip. you can then draw parts of the image into canvas.
it looks like (screenshot from Game-Maker)
a good source for indie games
https://kenney.nl/assets
You’ll have to do it frame-by-frame if you have to use a Canvas for other drawing. However, I wonder if a MoviePlayer might handle a GIF…
Someone created an example using timer:
Here the Zip:
AnimGifRev-canvas.xojo_binary_project.zip (8.5 KB)
Screen capture:

(Canvas on the left)
Original Gif (uploaded elsewhere by Eugene):

Thanks for the example, @AlbertoD.
I tested the program on both Windows and Debian Linux (Raspberry Pi), but unfortunately, it didn’t work as expected on either system. The initial image does appear, and I can click the right viewer to display the image on the left canvas. However, only a single frame is shown—there’s no animation or change between GIF frames. Starting the timer had no effect.
Which operating system did you use when running this example successfully?
macOS
A Xojo issue has been created and can be viewed in the following link:
https://tracker.xojo.com/xojoinc/xojo/-/issues/79558