Re: PHP-GTK2 : Problem with draw_pixbuf within a GtkDrawingArea
| From: | cyril dot cottet at toyota-tiee dot com | Date: | Wed, 11 Jan 2006 18:41:44 +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-6516@lists.php.net to get a copy of this message | ||
I just noticed than when removing the following line from my code, the
image is displayed but I cannot figure out why :
$area->set_size_request($pixbuf->get_width(), $pixbuf->get_height());
cyril.cottet@toyota-tiee.com
11/01/2006 10:58
To
<php-gtk-general@lists.php.net>
cc
Subject
[PHP-GTK] PHP-GTK2 : Problem with draw_pixbuf within a GtkDrawingArea
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);
}
?>