在 gtkmm 中找不到 GDK::InterpType 个成员

Can't find GDK::InterpType members in gtkmm

我正在尝试让 Gtk::Image 小部件显示文件中的图片,但阻止小部件扩大尺寸,所以我从 Gdk::Pixbuf 加载它然后缩放图片。我使用 Gdk::Pixbuf 而不是 GdkPixBuf,因为后者适用于常规指针,但 Gtk::Image 需要 Glib::RefPtr<Gdk::Pixbuf>。 (只是提一下所有这些,以防有更好的方法来实现我不知道的我正在做的事情。)

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);

无论如何,问题是虽然我遵循 documentation for Gdk::Pixbuf,但我的代码中的第 2 行生成了错误:

error: ‘NEAREST’ is not a member of ‘Gdk::InterpType’
auto scaled = pixbuf->scale_simple(48, 48, Gdk::InterpType::NEAREST);
                                                            ^~~~~~~

尝试 GDK_INTERP_NEAREST 也会导致错误。 :(

no known conversion for argument 3 from ‘GdkInterpType’ to ‘Gdk::InterpType’

稳定的 gtkmm gdkmm documentation, Gdk::InterpType 成员是:

INTERP_NEAREST

Nearest neighbor sampling; this is the fastest and lowest quality mode. Quality is normally unacceptable when scaling down, but may be OK when scaling up.

INTERP_TILES

This is an accurate simulation of the PostScript image operator without any interpolation enabled.

Each pixel is rendered as a tiny parallelogram of solid color, the edges of which are implemented with antialiasing. It resembles nearest neighbor for enlargement, and bilinear for reduction.

INTERP_BILINEAR

Best quality/speed balance; use this mode by default.

Bilinear interpolation. For enlargement, it is equivalent to point-sampling the ideal bilinear-interpolated image. For reduction, it is equivalent to laying down small tiles and integrating over the coverage area.

INTERP_HYPER

This is the slowest and highest quality reconstruction function.

It is derived from the hyperbolic filters in Wolberg's "Digital Image Warping", and is formally defined as the hyperbolic-filter sampling the ideal hyperbolic-filter interpolated image (the filter is designed to be idempotent for 1:1 pixel mapping).

并且从 Gdk::Pixbuf 的文档中,在 scale_simple 方法中,您将找到对插值类型的引用:

Leaves src unaffected. interp_type should be Gdk::INTERP_NEAREST if you want maximum speed (but when scaling down Gdk::INTERP_NEAREST is usually unusably ugly). The default interp_type should be Gdk::INTERP_BILINEAR which offers reasonable quality and speed.