I'm trying to make a Gtk::Image
widget display a picture from a file, but prevent the widget from expanding in size, so I'm loading it from a Gdk::Pixbuf
and then scaling the picture. I'm using Gdk::Pixbuf
instead of GdkPixBuf
because the latter one works on regular pointers, but Gtk::Image
requires a Glib::RefPtr<Gdk::Pixbuf>
. (Just mentioning all this in case there's a better way to achieve what I'm doing that I'm unaware of.)
auto pixbuf = Gdk::Pixbuf::create_from_file("/home/raitis/Music/WRLD/Awake EP/cover.jpg");
auto scaled = pixbuf->scale_simple(48, 48, Gdk::InterpType::NEAREST);
image->set(scaled);
Anyway, problem is that although I'm following the documentation for Gdk::Pixbuf
, line 2 in my code generate the error:
error: ‘NEAREST’ is not a member of ‘Gdk::InterpType’
auto scaled = pixbuf->scale_simple(48, 48, Gdk::InterpType::NEAREST);
^~~~~~~
Trying GDK_INTERP_NEAREST
instead also leads to an error. :(
no known conversion for argument 3 from ‘GdkInterpType’ to ‘Gdk::InterpType’
From the stable gtkmm gdkmm documentation, Gdk::InterpType members are:
And from the documentation of the Gdk::Pixbuf, in the
scale_simple
method you'll find a reference to the interpolation type: