[cairo] A surface to draw on another surface

Mj Mendoza IV mjmendoza at konsolscript.org
Mon May 24 20:52:19 PDT 2010


Just as I thought. Thanks, Zheng Xu.
 Regards.

Mj Mendoza IV,
Developer, KonsolScript
http://www.konsolscript.org 




________________________________
From: xuzheng_yahoo <xz911jp at yahoo.co.jp>
To: Mj Mendoza IV <mjmendoza at konsolscript.org>
Cc: cairo at cairographics.org
Sent: Monday, May 24, 2010 9:18:46 PM
Subject: Re: [cairo] A surface to draw on another surface

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/


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20100525/4a229dad/attachment.html>


More information about the cairo mailing list