Re: PHP-GTK2 : Problem with draw_pixbuf within a GtkDrawingArea
| From: | cyril dot cottet at toyota-tiee dot com | Date: | Wed, 11 Jan 2006 19:26:15 +0000 |
| Subject: | Re: PHP-GTK2 : Problem with draw_pixbuf within a GtkDrawingArea | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-6518@lists.php.net to get a copy of this message | ||
Hi Scott,
Thanks for your support. However, the problem was not there. When I
removed the set_size_request instruction, I had also changed another line
before which I forgot to mention in the mailing list which was causing my
PHP interpreter to crash. This line was within the pixbuf drawing
instruction. In fact, when giving the Graphical context,
"$area->style->fg_gc[Gtk::STATE_NORMAL]" does not seem to work. "new
GdkGC($area->window)" works better. And When I put back the
set_size_request instruction, the image kept displaying. So now the script
is running correctly as follows :
<?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(new GdkGC($area->window),
$pixbuf,
$event->area->x, $event->area->y,
$event->area->x, $event->area->y);
}
?>