开发者

scale surface without blurring it

开发者 https://www.devze.com 2023-03-21 12:25 出处:网络
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.

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


I suspect that you need:

cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_FAST);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号