Why does Gtk::Image::set() not work with a Cairo::Surface?



Hi all,

I'm trying to display a static image in a Gtk::Image widget.  I have
the image as a Cairo::ImageSurface, so I assumed I could call
Gtk::Image::set(surface) however this does not work - the widget
changes from the "missing image" icon to blank (all white.)

If instead I call Gdk::Pixbuf::create(surface, 0, 0, width, height) and
pass the resulting Pixbuf to Gtk::Image::set() then it works.

I am wondering why the set() call works when I pass a Gdk::Pixbuf, but
not when I pass a Cairo::Surface?

Passing the Cairo::Surface is easier for me (don't have to have code to
retrieve image dimensions) so I'd rather do that if I can.

  auto cimg = Cairo::ImageSurface::create(...);
  ...
  Glib::RefPtr<Gtk::Image> ctImage = ...

  // This works
  //ctImage->set(Gdk::Pixbuf::create(cimg, 0, 0, width, height));

  // This doesn't work - why?
  ctImage->set(cimg);

Many thanks,
Adam.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]