#include #include #include void on_destroy(GtkWidget *widget, gpointer data) { gtk_main_quit(); } gboolean expose_event_callback(GtkWidget *widget, GdkEventExpose *event, gpointer data) { cairo_t* cr = gdk_cairo_create(widget->window); cairo_surface_t* image_surface; image_surface = cairo_image_surface_create_from_png("test-1.png"); cairo_pattern_t* pattern; pattern = cairo_pattern_create_for_surface(image_surface); cairo_matrix_t m; cairo_matrix_init_scale(&m, 1.25, 1.25); // cairo_matrix_init_rotate(&m, 5 * M_PI / 180); cairo_pattern_set_matrix(pattern, &m); cairo_set_source(cr, pattern); cairo_paint(cr); cairo_destroy(cr); return TRUE; } int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *drawing_area; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(on_destroy), NULL); drawing_area = gtk_drawing_area_new(); gtk_widget_set_size_request(GTK_WIDGET(drawing_area), 600, 600); gtk_container_add(GTK_CONTAINER(window), drawing_area); g_signal_connect (G_OBJECT (drawing_area), "expose_event", G_CALLBACK (expose_event_callback), NULL); gtk_widget_show_all(window); gtk_main(); return 0; }