[cairo] A surface to draw on another surface

xuzheng_yahoo xz911jp at yahoo.co.jp
Mon May 24 06:18:46 PDT 2010


Hi

How about the method like following?

cairo_surface_t *image_A, *image_B;
cairo_t *image_dc_A, *image_dc_B;

image_A = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 200, 200);
image_B = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 300, 300);
image_dc_A = cairo_create(image_A);
image_dc_B = cairo_create(image_B);

/* paint rectangle to surface A */
cairo_set_source_rgba(image_dc_A, 1.0, 0.0, 0.0, 0.5);
cairo_rectangle(image_dc_A, 0, 0, 200, 200);
cairo_paint(image_dc_A);

cairo_set_source_rgba(image_dc_B, 0.0, 1.0, 0.0, 0.5);
cairo_rectangle(image_dc_B, 0, 0, 300, 300);
cairo_paint(image_dc_B);

/* paint surface A to surface B */
cairo_set_source_surface(image_dc_B, image_A, 0, 0);
cairo_paint(image_dc_B);

/* paint surface B to main draw context */
cairo_set_source_surface(main_dc, image_B, 0, 0);
cairo_paint(main_dc);

cairo_destroy(image_dc_A);
cairo_surface_destroy(image_A);
cairo_destroy(image_dc_B);
cairo_surface_destroy(image_B);

Regards,

Zheng.Xu

Mj Mendoza IV ????????:
> Is there a way to draw the contents of one cairo Surface (surface_A) 
> to "another" cairo Surface (surface_B) before drawing surface_B to 
> main cairo Context?
> It doesn't seem possible. I wonder if there's a way around to doing this?
> Regards.
>
> Mj Mendoza IV,
> Developer, KonsolScript
> http://www.konsolscript.org <http://www.konsolscript.org/>
>
> ------------------------------------------------------------------------
>
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo


--------------------------------------
2010 FIFA World Cup News [Yahoo!Sports/sportsnavi]
http://pr.mail.yahoo.co.jp/southafrica2010/


More information about the cairo mailing list