#include #include #include #include #include #include #include const char filename[] = "clip.png"; #define WIDTH 32 #define HEIGHT WIDTH #define STEPS 10 #define IMAGE_WIDTH ( (WIDTH / 2 * STEPS) + 3 * WIDTH / 2 ) #define IMAGE_HEIGHT IMAGE_WIDTH int main (int argc, char *argv[]) { FILE *fp; cairo_t *cr; cairo_surface_t *stamp, *target; fp = fopen ("pixman-bug.png", "w"); target = cairo_png_surface_create (fp, CAIRO_FORMAT_ARGB32, IMAGE_WIDTH, IMAGE_HEIGHT); cr = cairo_create (); stamp = cairo_surface_create_similar (target, CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT); cairo_set_target_surface (cr, stamp); cairo_new_path (cr); cairo_rectangle (cr, WIDTH / 4, HEIGHT / 4, WIDTH / 2, HEIGHT / 2); cairo_set_rgb_color (cr, 1, 0, 0); cairo_set_alpha (cr, 0.8); cairo_fill (cr); cairo_rectangle (cr, 0, 0, WIDTH, HEIGHT); cairo_set_line_width (cr, 2); cairo_set_rgb_color (cr, 0, 0, 0); cairo_set_alpha (cr, 1); cairo_stroke (cr); cairo_set_target_surface (cr, target); /* Draw a translucent rectangle for reference where the rotated * image should be. */ cairo_new_path (cr); cairo_rectangle (cr, WIDTH, HEIGHT, WIDTH, HEIGHT); cairo_set_rgb_color (cr, 1, 1, 0); cairo_set_alpha (cr, 0.3); cairo_fill (cr); cairo_translate (cr, 2 * WIDTH, 2 * HEIGHT); cairo_rotate (cr, M_PI); cairo_set_alpha (cr, 1); cairo_show_surface (cr, stamp, WIDTH + 2, HEIGHT + 2); cairo_show_page (cr); cairo_surface_destroy (stamp); cairo_surface_destroy (target); cairo_destroy (cr); return 0; }