Sometimes it is necessary to make pixmaps/bitmaps out of the gdk-pixbuf images, since GDK only works with pixmaps. There are a couple of ways of doing this. One would be to create a GdkPixmap the size of the GdkPixbuf and then use render_to_drawable() method as we've done before. But there a convenience method that can be used.

<?php
  array render_pixmap_and_mask(int $alpha_threshold)
?>
The returned array will contain the pixmap and the mask for the image. $alpha_threshold specifies a value (0..255); the opacity of each pixel is compared to this value to determine whether the pixel will be transparent or not (bilevel only).

So, if we want to draw a 3/4 circle in the center of an image:

 1: <?php
 2:   $cmap = gdk::colormap_get_system();
 3:   $c = $cmap->alloc('purple');
 4: 
 5:   list($mp, $mm) = $pixbuf->render_pixmap_and_mask(0);
 6:   $window = $area->window;
 7:   $gc = $window->new_gc();
 8:   $gc->foreground = $c;
 9:   $gc->clip_mask = $mm;
10:   gdk::draw_arc($mp, $gc, true, $mp->width/2 - 100, $mp->height/2 - 100,
11:                 200, 200, 90 * 64, 270 * 64);
12:   gdk::draw_pixmap($area->window, $area->style->fg_gc[GTK_STATE_NORMAL],
13:                    $mp, 0, 0, 0, 0, $mp->width, $mp->height);
14: ?>