【问题标题】:GIMP scale image cubic interpolation codeGIMP 比例图像三次插值代码
【发布时间】:2020-11-17 00:12:36
【问题描述】:

我想看看GIMP中图像缩放的实现,特别是我对三次插值感兴趣。

我下载了 GIMP 的源代码 (gimp-2.9.8.tar.bz2),并将研究范围缩小到 gimp-2.9.2/app/core/gimpitem.c 中的 gimp_item_scale 函数:

void
gimp_item_scale (GimpItem              *item,
                 gint                   new_width,
                 gint                   new_height,
                 gint                   new_offset_x,
                 gint                   new_offset_y,
                 GimpInterpolationType  interpolation,
                 GimpProgress          *progress)
{
  GimpItemClass *item_class;
  GimpImage     *image;

  g_return_if_fail (GIMP_IS_ITEM (item));
  g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));

  if (new_width < 1 || new_height < 1)
    return;

  item_class = GIMP_ITEM_GET_CLASS (item);
  image = gimp_item_get_image (item);

  if (gimp_item_is_attached (item))
    gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_SCALE,
                                 item_class->scale_desc);

  g_object_freeze_notify (G_OBJECT (item));

  item_class->scale (item, new_width, new_height, new_offset_x, new_offset_y,
                     interpolation, progress);

  g_object_thaw_notify (G_OBJECT (item));

  if (gimp_item_is_attached (item))
    gimp_image_undo_group_end (image);
}

下一步是对item_class-&gt;scale 的调用,希望在其中进行缩放操作,但scale 是结构_GimpItemClass (gimp-2.9.2/app/core/gimpitem.h:75) 的“虚拟”方法。

您知道如何解决该调用或我应该在哪里寻找实际的缩放操作(使用三次插值)?

谢谢!

【问题讨论】:

    标签: c image scale gimp


    【解决方案1】:

    Gimp 的“核心”操作在 GEGL 库中实现。你想看的代码可能在这里:

    https://gitlab.gnome.org/GNOME/gegl/-/blob/master/gegl/buffer/gegl-sampler-cubic.c

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-28
      • 2013-03-29
      • 1970-01-01
      • 2018-09-23
      • 1970-01-01
      • 1970-01-01
      • 2013-02-17
      • 1970-01-01
      相关资源
      最近更新 更多