#include #include int main (int argc, char *argv[]) { cairo_t *first_cr, *second_cr; cairo_surface_t *first, *second; int i; first = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 20, 20); second = cairo_image_surface_create(CAIRO_FORMAT_A8, 10, 10); cairo_surface_set_device_offset(second, -6, -6); first_cr = cairo_create(first); cairo_scale(first_cr, 0.5, 0.5); cairo_set_source_rgb(first_cr, 0, 0, 0.4); cairo_rectangle(first_cr, 6, 6, 10, 10); cairo_fill(first_cr); second_cr = cairo_create(second); cairo_rectangle(second_cr, 6, 6, 10, 10); cairo_fill(second_cr); cairo_set_source_rgb(first_cr, 0.5, 0.5, 0); cairo_mask_surface(first_cr, second, 0, 0); unsigned char* data = cairo_image_surface_get_data(first); int stride = cairo_image_surface_get_stride(first); int size = stride * cairo_image_surface_get_height(first); printf("\"first\" - ARGB32 surface\n----------------------------\n"); for (i = 0; i < size; i++) { if (i!= 0 && i % stride == 0) printf("|\n"); else if (i!=0 && i % 4 == 0) printf(", "); printf("%u ", data[i]); } printf("\n"); cairo_surface_destroy(first); cairo_surface_destroy(second); cairo_destroy(first_cr); cairo_destroy(second_cr); return 0; }