Full example
 1: <?php
 2
:   dl('php_gtk.so');
 
3
 
4:   if ($argc 2)
 
5:       die("\nUsage: php gdk_pixbuf.php <imagefile>\n\n");
 
6
 
7:   $image_file $argv[1];
 
8
 
9:   $window = &new GtkWindow();
10:   $window->set_border_width(5);
11:   $window->set_title('GdkPixbuf example');
12:   $window->set_policy(falsefalsetrue);
13:   $window->connect_object('destroy', array('gtk''main_quit'));
14
15:   $pixbuf GdkPixbuf::new_from_file($image_file);
16:   if (!$pixbuf) {
17:       die("\nCouldn't load $image_file\n\n");
18:   }
19
20:   $area = &new GtkDrawingArea();
21:   $area->size($pixbuf->get_width(), $pixbuf->get_height());
22:   $area->connect('expose_event''expose_event'$pixbuf);
23:   $frame = &new GtkFrame();
24:   $frame->add($area);
25:   $frame->set_shadow_type(GTK_SHADOW_IN);
26:   $window->add($frame);
27
28:   $window->show_all();
29
30:   gtk::main();
31
32:   function expose_event($area$event$pixbuf)
33:   {
34:       $pixbuf->render_to_drawable($area->window,
35:                                   $area->style->fg_gc[GTK_STATE_NORMAL],
36:                                   $event->area->x$event->area->y,
37:                                   $event->area->x$event->area->y,
38:                                   $event->area->width$event->area->height,
39:                                   GDK_RGB_DITHER_NORMAL00);
40:   }
41?>