title: GTK+ Replace gdk_draw_pixbuf with Cairo
body: <p>I'm working on a GtkDrawingArea which, in the expose event, is drawing a section of a pixbuf in a tiled manner. The tiling type varies - depending on the source image; it can be orthogonal, isometric or hexagonal. Drawing this with gdk_draw_pixmap is simple enough; here is an example on how it looks for isometric tiling:</p>
  
  <pre><code>for(y=0,row=0; y+tile_height&lt;height; y+=tile_half_height,++row)
    for(x=((row&amp;1)? tile_half_width : 0); x+tile_width&lt;width; x+=tile_width)
      gdk_draw_pixbuf(widget-&gt;window,NULL,
                      pixbuf,src_x,src_y,
                      x,y,tile_width,tile_height,
                      GDK_RGB_DITHER_NONE,0,0);
  </code></pre>
  
  <p>Result:</p>
  
  <p><a href="https://i.stack.imgur.com/Vrbtu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vrbtu.png" alt="Isometric tiling with gdk_draw_pixbuf"></a></p>
  
  <p>However, drawing the same with Cairo proved to be quite not the same. This is what I have so far, which isn't working:</p>
  
  <pre><code>cairo_t *cr = gdk_cairo_create(widget-&gt;window);
  gdk_cairo_set_source_pixbuf(cr,pixbuf,src_x,src_y);
  for(y=0,row=0; y+tile_height&lt;height; y+=tile_half_height,++row)
    for(x=((row&amp;1)? tile_half_width : 0); x+tile_width&lt;width; x+=tile_width) {
      cairo_rectangle(cr,x,y,tile_width,tile_height);
      cairo_paint(cr);
    }
  }
  cairo_destroy(cr);
  </code></pre>
  
  <p>Result:</p>
  
  <p><a href="https://i.stack.imgur.com/ghLXG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ghLXG.png" alt="Isometric tiling with Cairo"></a></p>
  
  <p>Cairo simply refuses to draw the image as a normal raster image would be drawn. What am I doing wrong, how is this solved?</p>