[cairo] Pasting a png image on another

Anisha Kaul anisha.kaul at hitechroboticsystemz.com
Fri Mar 5 21:11:26 PST 2010

Hello all,

I have seen how an image can be drawn and then pasted on another drawn image by using "cairo_t" and "cairo_set_operator".

Now my problem is that I want a png image to be pasted on another png image and I am unable to achieve that 
through "cairo_set_operator" 

See my small code below:

        // SURFACE 1 ****************************************************************
	Cairo :: RefPtr <Cairo :: ImageSurface> surface1;
	surface1  = Cairo :: ImageSurface :: create (Cairo :: FORMAT_ARGB32, m.getWidth(), m.getHeight());

        cairo_renderer<Cairo :: Surface> renderMe0 (m, surface1);
        renderMe0.apply ();
        surface1->write_to_png ("cairo-demo1.png");
        // SURFACE 2 ****************************************************************
       	Cairo :: RefPtr <Cairo :: ImageSurface> surface2;
        surface2 = Cairo :: ImageSurface :: create (Cairo::FORMAT_ARGB32, m.getWidth(), m.getHeight());
        cairo_renderer <Cairo :: Surface> renderMe1 (m, surface2);
        surface2->write_to_png ("cairo-demo2.png");

Problem :
I cannot use the function "cairo_set_operator" here as it takes an argument of type "cairo_t" not of type "Cairo :: RefPtr <Cairo :: 

How should I achieve the above or is there any other way of solving this problem ?

Please help !

P.S I am doing this w.r.t Mapnik

Anisha Kaul

Hi-Tech Gears Limited, Gurgaon, India

More information about the cairo mailing list