How to get pixbuf from image in GTK4?

Recently I started to port my app from GTK 3 to GTK 4 and I found that


not longer exists.
I searched for pixbuf in docs, but found nothing.
What is alternative for such code?

Calling gtk::Image::set_from_pixbuf ends up creating a gdk::Texture from the pixbuf and then calls gtk::Image::set_paintable for you. In other words, you could get the paintable using gtk::Image::paintable() and downcast it to a gdk::Texture with

let texture = image.paintable().unwrap().downcast::<gdk::Texture>().unwrap();

Then it depends on whatever you were using the pixbuf for.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.