#include #include #include #include static void dump_data(unsigned char* data, int width, int height) { int x, y; for (y = 0; y < height; ++y) { for (x = 0; x < width; ++x) { unsigned char* d = data + (y*width + x)*4; printf("%02x%02x%02x%02x ", d[0], d[1], d[2], d[3]); } putchar('\n'); } } int main(int argc, char** argv) { cairo_surface_t* src; cairo_surface_t* dest; cairo_t* cr; cairo_pattern_t* pat; cairo_matrix_t matrix = { 1.0, 0.0, 0.0, 1.0, 0.5, 0.0 }; src = cairo_image_surface_create(CAIRO_FORMAT_RGB24, 10, 10); memset(cairo_image_surface_get_data(src), 255, 10*10*4); dest = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 10, 10); memset(cairo_image_surface_get_data(dest), 0, 10*10*4); pat = cairo_pattern_create_for_surface(src); cairo_pattern_set_matrix(pat, &matrix); cairo_pattern_set_filter(pat, CAIRO_FILTER_BILINEAR); cr = cairo_create(dest); cairo_set_source(cr, pat); cairo_rectangle(cr, 0.0, 0.0, 8.0, 8.0); cairo_fill(cr); dump_data(cairo_image_surface_get_data(dest), 10, 10); return 0; }