Re: Cairo, Gtk+, Gdk & GdkPixbuf -- making a pixel-based backing store for vector graphics
- From: Emmanuel Thomas-Maurin <manutm007 gmail com>
- To: James Tappin <jtappin gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Cairo, Gtk+, Gdk & GdkPixbuf -- making a pixel-based backing store for vector graphics
- Date: Tue, 14 Jun 2011 23:38:14 +0200
On 06/14/2011 10:30 PM, James Tappin wrote:
I would like to be able to make a code that draws some (possibly very
complex) vector graphics, copies it to an off-screen backing store and
then when an expose-event (Gtk2) or draw signal (Gtk3) is received,
the backing store is copied to the screen rather than doing a complete
redraw of all the vectors which could potentially take several
seconds. Unfortunately all the potential model codes I've been able to
find use the obsolete Gdk Pixmap as backing store.
You may draw to a cairo image surface (instead of a GDK pixmap) then
draw that image to a cairo surface (instead of a GTK drawing area.)
surface = cairo_image_surface_create();
(vector graphics drawing)
cr = gdk_cairo_create(GDK_DRAWABLE(drawing_area->window));
cairo_set_source_surface(cr, surface, dest_x - src_x, dest_y - src_y);
cairo_rectangle(cr, dest_x, dest_y, drawing_area_width,
drawing_area_height);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
cairo_fill(cr);
cairo_destroy(cr);
--
Emmanuel Thomas-Maurin <manutm007 gmail com>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]