Hey all,
I’m looking to render a gif using GTK4 (rust bindings). I’m looking at gtk4::MediaFile
and gtk4::Picture
to render the IsA<Paintable>
. My minimum reproducible example is here (full example on github):
const SIZE : i32 = 400;
fn main() {
let application = Application::new(Some("gif.example"), Default::default());
application.connect_activate(move |app: &Application| {
//
build_ui(app);
});
application.run();
}
/// put a MediaFile inside a Picture thats attached directly to the application window
///
/// Behavior: The animation "twitches" through the first few frames without playing the
/// full duration
fn build_ui(application: &Application) {
let window = ApplicationWindow::builder()
.application(application)
.title("gif-display-example")
.build();
let media = MediaFile::for_filename("catJAM.gif");
media.set_loop(true);
media.set_playing(true);
let picture = Picture::builder()
.paintable(&media)
.height_request(SIZE)
.width_request(SIZE)
.build();
window.set_child(Some(&picture));
window.show()
}
I would expect that the gif renders like the original file:
but instead it only renders the first few frames (new users cant embed more than one attachment)
Can anyone point me in the right direction for rendering an animation like this?