缩放表面而不模糊它

时间:2011-07-19 07:25:25

标签: scale gtk blur cairo gtk3

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

问题是,cairo somhow autoblurrs它。我该如何修复/删除它?目的是查看单个像素。

感谢您的回复。

修改:部分代码触发"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;
}

1 个答案:

答案 0 :(得分:3)

我怀疑你需要:

cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_FAST);