tags:

views:

235

answers:

1

I want to draw an image on a window using Cairo. How can I load a bmp or png from disk and create a brush from it?

The code below shows where drawing should be made. The expose signal is attached to the window.

gboolean OnExpose(GtkWidget *widget, GdkEventExpose *event, gpointer data)
{   
    cairo_t *cr; 
    cr = gdk_cairo_create(widget->window);

    //Draw bitmap on cr by
    //loading 'background.png'

    cairo_destroy(cr);  
    return TRUE;
}
+1  A: 

Cairo does not have the brush concept: it is a (relatively) low level graphic library, not a full-fledged image manipulation program. This snippet gives the idea on how to include images.

fetasail