Re: Cairo, Gtk+, Gdk GdkPixbuf -- making a pixel-based backing store for vector graphics
Just to let folks know that the pointers here have given me the lead in that I needed and I've got a working code. (A bit more elegant in the Gtk3 case than Gtk2 but both work). ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Cairo, Gtk+, Gdk GdkPixbuf -- making a pixel-based backing store for vector graphics
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. Likewise the routine that looks promising gdk_pixbuf_render_to_drawable () is marked as deprecated (since 2.4) and suggests gdk_draw_pixbuf () as an alternative. However that is also marked deprecated (since 2.22) and recommends gdk_cairo_set_source_pixbuf() and cairo_paint() or cairo_rectangle() and cairo_fill() but it is not at all clear how to combine those routines to produce the required effect. I have searched many times for suitable examples and come up empty. So does anybody here have any suggestions, examples or link that provide pointers to the following operations?: 1) Getting cairo to draw to a pixmap or pixbuf, or draw to a window and then copy the resulting window contents to an in-memory storage. 2) Making the expose handler copy that pixbuf (or whatever) to the visible window (while only copying the affected region would be the best option I can live with copying the whole window). 3) (Less important for now) Adding new material to the plot and updating the backing store -- my guess is that once I crack 1 2 then 3 will be fairly obvious. James ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Cairo, Gtk+, Gdk GdkPixbuf -- making a pixel-based backing store for vector graphics
On Tue, 2011-06-14 at 14:30 -0600, James Tappin wrote: I would like to be able to make a code that draws some (possibly very complex) vector graphics, A better place for asking may be the cairo mailing list? At least there was some discussion about such tasks in the past. One recommended way was using cairos create_similar() function for creating the backup surface. I did a small demo in Ruby some time ago, see http://www.ssalewski.de/PetEd-Demo.html.en I found this related thread with some helpful replies: http://lists.freedesktop.org/archives/cairo/2009-March/016756.html But I am still interested in smarter solutions. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Cairo, Gtk+, Gdk GdkPixbuf -- making a pixel-based backing store for vector graphics
On 14 June 2011 15:00, Stefan Salewski m...@ssalewski.de wrote: On Tue, 2011-06-14 at 14:30 -0600, James Tappin wrote: I would like to be able to make a code that draws some (possibly very complex) vector graphics, A better place for asking may be the cairo mailing list? At least there was some discussion about such tasks in the past. One recommended way was using cairos create_similar() function for creating the backup surface. I did a small demo in Ruby some time ago, see http://www.ssalewski.de/PetEd-Demo.html.en I found this related thread with some helpful replies: http://lists.freedesktop.org/archives/cairo/2009-March/016756.html It looks as if this example: http://www.gtkforums.com/viewtopic.php?t=5204, may at least provide part of the answer to (1) in my original posting -- I'm still trying to disentangle the housekeeping and the real logic, to figure exactly what it does. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Cairo, Gtk+, Gdk GdkPixbuf -- making a pixel-based backing store for vector graphics
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 manutm...@gmail.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list