缩放表面而不使其模糊

发布于 2024-11-24 12:23:47 字数 982 浏览 2 评论 0原文

我尝试将从文件派生的图像缩放到任何(合理的)比例。

问题是,开罗不知如何自动模糊它。我该如何修复/删除它?目的是查看各个像素。

感谢您的任何回复。

编辑:一些代码,在 "draw" 事件上触发,父级是 GtkDrawingArea

static gboolean
cb_event_draw (GtkWidget *obj, cairo_t *cr, gpointer data)
{
    guint width, height;

    width = gtk_widget_get_allocated_width (obj);
    height = gtk_widget_get_allocated_height (obj);
    _priv = ...; //some struct


//  cairo_save (cr);
    cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
    cairo_scale (cr, _priv->zoom, _priv->zoom);


    cairo_set_source_surface (cr, _priv->image, 0., 0.);
    cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
    cairo_pattern_set_filter (cr, CAIRO_FILTER_FAST); // no matter if this is there or not
    // it does actually, matter, works with this:
    // cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_FAST);
    cairo_paint (cr);

// print some markers at defined locations


    return FALSE;
}

I try to scale an image derivedfrom a file, to any (sensible) scale.

The problem is, cairo somhow autoblurrs it. How can I fix/remove it? The aim is to see the individual pixels.

Thanks for any reply.

Edit: Some code, triggering on "draw" event, parent is a GtkDrawingArea

static gboolean
cb_event_draw (GtkWidget *obj, cairo_t *cr, gpointer data)
{
    guint width, height;

    width = gtk_widget_get_allocated_width (obj);
    height = gtk_widget_get_allocated_height (obj);
    _priv = ...; //some struct


//  cairo_save (cr);
    cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
    cairo_scale (cr, _priv->zoom, _priv->zoom);


    cairo_set_source_surface (cr, _priv->image, 0., 0.);
    cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
    cairo_pattern_set_filter (cr, CAIRO_FILTER_FAST); // no matter if this is there or not
    // it does actually, matter, works with this:
    // cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_FAST);
    cairo_paint (cr);

// print some markers at defined locations


    return FALSE;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅笑依然 2024-12-01 12:23:47

我怀疑你需要:

cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_FAST);

I suspect that you need:

cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_FAST);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文