[cairo] Layering of multiple images

Blagoj Kupev bkupev at gmail.com
Tue Mar 26 23:35:52 PDT 2013


Hello,
I need to layer several images one on top of the others, so I'm using
background image and the others on top of it are with transparency. But
when I need to change the pictures they are flicker, and it is noticeable
that pictures are redrawn.
The sequence that i'm using is:
1. First I"m loading all images from disk using
cairo_image_surface_create_from_png
2. Then i'm layering them:
cr = gdk_cairo_create (widget->window);
  cairo_translate(cr, PIC1_X_ORIGIN, PIC1_Y_ORIGIN); // Background image
  cairo_set_source_surface(cr, pic1_p, 0, 0);
  cairo_paint(cr);

  cairo_translate(cr, PIC2_X_ORIGIN, PIC2_Y_ORIGIN); //Some graphics and
the rest is transparent
  cairo_set_source_surface(cr, pic2_p, 0, 0);
  cairo_paint(cr);
....

I assume that in most of the cases the time between drawing the pic1 and
then pic2 on top of it is more than 30ms so the second image flickers.

Is there a way to paint both images at once so the flicker is avoided? Or
maybe combine them in background and then paint at once?

Best regards,
Blagoj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20130327/d65706f0/attachment.html>


More information about the cairo mailing list