0

cairo と x11 api を使用して cairo xlib のサーフェスの GC からイメージを作成したいので、この問題で私を助けてくれませんか??

4

1 に答える 1

2

あなたの質問を本当に理解しているかどうかはまだわかりませんが、試してみましょう:

という名前の cairo X11 サーフェスがx11_surfあり、その内容を という名前の新しいイメージ サーフェスに取得したいと考えていますimg_surf

double x1, y1, x2, y2;
cairo_t *cr;
cairo_surface_t *img_surf;

/* Figure out the size of the x11 surface */
cr = cairo_create(x11_surf);
cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
cairo_destroy(cr);

/* Allocate an image surface of a suitable size */
img_surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, x2, y2);

/* Copy the contents over */
cr = cairo_create(img_surf);
cairo_set_source_surface(cr, x11_surf, 0, 0);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
cairo_paint(cr);
cairo_destroy(cr);

/* Done (Notice that nothing needed a GC here!) */
于 2013-08-17T15:10:09.017 に答える