PHP-GTK2 : Problem with draw_pixbuf within a GtkDrawingArea

From: Date: Wed, 11 Jan 2006 09:58:41 +0000
Subject: PHP-GTK2 : Problem with draw_pixbuf within a GtkDrawingArea
Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-6515@lists.php.net to get a copy of this message
I'm currently performing some trials with PHP-GTK2 mainly focusing on image browsing. When I try to load a JPG image within a GtkImage, the thing runs perfectly. My problem is that I need to draw some rectangles on the top of the image. Thus I want to load my original picture in a GtkDrawingArea. To do so, I used some code found on the web but there might be a problem inside because, when launching the script, an empty window is displayed. The window is well sized compared to the image to load but the image is not shown. The thing is that I get no warning message so I've no clue about what happens. Here is the source code I'm using : <?php error_reporting(E_ALL); $image_file = "C:\\images\\pic00041.jpg"; $window = new GtkWindow(); $window->set_border_width(5); $window->set_title('GdkPixbuf example'); $window->set_resizable(false); $window->connect_object('destroy', array('gtk', 'main_quit')); try { $pixbuf = GdkPixbuf::new_from_file($image_file); } catch (PhpGtkGErrorException $e) { die($e->message . "\n"); } $area = new GtkDrawingArea(); $area->set_size_request($pixbuf->get_width(), $pixbuf->get_height()); $frame = new GtkFrame(); $frame->add($area); $frame->set_shadow_type(Gtk::SHADOW_IN); $window->add($frame); $area->connect('expose_event', 'expose_event', $pixbuf); $window->show_all(); gtk::main(); function expose_event($area, $event, $pixbuf) { $area->window->draw_pixbuf($area->style->fg_gc[Gtk::STATE_NORMAL], $pixbuf, $event->area->x, $event->area->y, $event->area->x, $event->area->y); } ?>

« previous php.gtk.general (#6515) next »