[cairo] retain image among multiple draw events

Stefan Salewski mail at ssalewski.de
Tue Jun 16 09:29:40 PDT 2015


On Tue, 2015-06-16 at 13:53 +0530, Lokesh Chakka wrote:
> hello,
> 
> I am using GtkDrawingArea for drawing images using cairo graphics. I
> connected one call back function for draw event.
> This call back will be executed multiple times. I am observing that, what
> ever drawing happened in the previous call, is disappearing when the same
> call back function is called next time.
> 
> I want to know how to retain the previously drawn image. If it is a sample
> program, it will be more helpful to me.
> Can some body please help me in this ?
> 

Your observation seems to be wrong. When you investigate the GTK3
drawing area example from
https://developer.gnome.org/gtk3/3.0/gtk-getting-started.html

you will see, that motion_notify_event_cb in called when mouse is moved,
and that function calls draw_brush() only for current coordinate --
earlier drawing is conserved. You may investigate your code, maybe there
is a background clear operation involved. Or your logic of processing
events is wrong. Try to follow that example.



More information about the cairo mailing list