GIF animation in htmlviewer over Canvas

I need to play a GIF animation with transparency to play over a Canvas.
So basically I need the HTMLViewer to have a transparent background. This way I can put it on top of a canvas.

Is this possible?

Maybe with plugins (MBS) or declares. I don’t thing the htmlviewer can be transparent otherwise. But i’ve seen it been done before.

Only HTMLViewer supports animated gifs.

It may be possible with declares to set the HTMLViewer background content to transparent, and remove the border. I am pretty sure about the border, setting the background color may simply not be possible.

There is another way, though. If the canvas is transparent, place it over the HTMLViewer.

I suspect you could do it yourself; there’s probably a way to open a GIF file (The usual suspects are NSImage or CGImageSource) and get all the frames, then all you need is to read the GIF meta data (again with either NSImage or CGImageSource) and figure out the parameters.

Yup, CGImageProperties will allow you to read that meta data.

Thank you for the input;

I understand I can do the animation in a Canvas too. But the main issue is that the animation can play chunky when other things are doing heavy calculations in the main thread. An animated GIF inside a HTMLViewer always seems to play smoothly, even when the main thread is busy doing other stuff. HTMLViewer probably runs in the separate thread.
I also tried to use AVFoundation playing a movie, but it doesn’t play smoothly either when the main thread is doing something else.

Basically what I need is a simple loop animation that always plays smoothly. :slight_smile:

So you are looking for a Mac only solution?
In that case, NSImageView would be my personal choice. It can play animated images smoothly, and you could use Xojo’s ImageWell, get rid of the frame via declare and add a handful of other declares to load the animated Gif as an NSImage.

Thanks Ulrich. Yes Mac only.
Will look at this asap.

(set)Framestyle, Animates and …Image are the declares for the image well, and something like initByReferencingFile is ok to turn an animated Gif into an NSImage.
But, sadly, while the animation plays even if you use a menu item or move the window, a tight loop on the main thread stops it …
EDIT: A workable approach seems to be the use of CoreAnimation.

You can use MBS Plugins.
We have class to load and play GIF files.
And also an NSImageViewMBS class.

Then the main issue is that you need to free up your main thread.

GIF classes are listed here:

and example to play animated images is here:

A soulution that may help with HTML-Viewer with different background-colors is here
you can define the background of the html-viewer by css.
Colors are not 100% the same as in xojo and transparency is possible but works not really well.
If that is not enough: maybe mbs.