[Gtk-sharp-list] How can I save a cairo imagesurface as a pixbuf

Andy Selvig ajselvig at gmail.com
Sun Dec 28 17:02:46 EST 2008

On Thu, Dec 25, 2008 at 12:09 PM, Christian Hoff <christian_hoff at gmx.net> wrote:
> You're right the effect only shows up if you have a large number of rows. But not storing the images as a pixbuf leads to a considerable performance improvement. I used my EAN13 class in a treeview that had about 10.000 rows. In earlier versions it was derived from CellRendererPixbuf and the load was awfully slow(about 30 seconds!) because Gtk+ renders not just the visible cells, but instead all of them.

But how many unique icons are there? If 5000 of the cells share the
same icon, shouldn't it only need to be generated once then stored as
a pixbuf and displayed for the rest of them?

> That's why I tested the approach to subclass directly from CellRenderer and create the image in the render method using Cairo. And suddenly everything was 10 times faster(yes it was really that much a difference). BTW the CellRendererPixbuf uses cairo as well:
>  cr = gdk_cairo_create (window);
>  gdk_cairo_set_source_pixbuf (cr, pixbuf, pix_rect.x, pix_rect.y);
>  gdk_cairo_rectangle (cr, &draw_rect);
>  cairo_fill (cr);
>  cairo_destroy (cr);

That's interesting. Good to know.

More information about the Gtk-sharp-list mailing list