the right way to draw in a drawingarea



I need to draw stuff (shapes rectangles, ellipses, splines, points,
etc), overlayed on top of an image, and I want to update the display in
real time, as the mouse moves. This is similar to doing a selection in
gimp. The way I do this right now is as follows:

The background image is in a Gdk::Pixbuf. I also have a Gtk::DrawingArea
in which I draw my shapes. The display needs to be repainted upon each
expose event, but upon mouse movement as well. So upon each mouse movement
event I render the pixbuf and the shapes into the Darea->get_window(). 
This works ok, but when the user draws something by dragging the mouse,
the display flickers, even when drawing a simple square.

Now this does not happen in gimp: it does not happen e.g. when a selection
is made, nor when I move the nodes of a path, even though the display must
be re-drawn as the mouse moves, etc. The window is steady and the
drawing smooth. 

So I guess there's a better way of overlaying shapes on top of an image,
than the obvious Pixbuf + Darea method. Does anybody know anything about
this? 

Thanks!





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]