strange temp pixbuf

From: Date: Fri, 24 Oct 2003 15:18:01 +0000
Subject: strange temp pixbuf
Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-3999@lists.php.net to get a copy of this message
hi all, The main thing to write my utility will be to connect php-imagick to the pixbuf. So here is below a little test to make it with a blur. The connection from the blur to the pixbuf works but in a strange temporary way. When I clic on 'blur', the blur is processed on the image, but when the window is reduced and then raised back, it is the original image that is displayed and not the blured one. Why!? Howto make it stay? ========================== #! /usr/bin/php -q <?php dl('php_gtk.so'); // switch .so to .dll for windows if ($argc < 2) die("\tUsage:\n./{$_SERVER['PHP_SELF']} <path/imagefile>\n"); $image_file = $argv[1]; $size = getimagesize($image_file); list($width, $height) = array($size[0], $size[1]); $handle = imagick_readimage($image_file); imagick_convert($handle, 'RGB'); $image_data = imagick_image2blob($handle); $image_depth = imagick_getimagedepth($handle); if ($image_depth != 8) die("Error: The image depth of the image must be 8 bits\n". "Other depth are not supported by GdkPixbuf::new_from_data() yet\n"); $window = &new GtkWindow(); $window->set_border_width(1); $window->set_position(GTK_WIN_POS_CENTER); $window->set_title('GdkPixbuf'); $window->set_policy(false, false, true); $window->connect_object('destroy', array('gtk', 'main_quit')); //make pixbuf $colorspace = GDK_COLORSPACE_RGB; $has_alpha = FALSE; $bits_per_sample = 8; $rowstride = $width * 3; $pixbuf = GdkPixbuf::new_from_data($image_data, $colorspace, $has_alpha, $bits_per_sample, $width, $height, $rowstride); if (!$pixbuf) die("Couldn't load $image_file\n"); // add pixbuf into widget $area = &new GtkDrawingArea(); $area->size($pixbuf->get_width(), $pixbuf->get_height()); $area->connect('expose_event', 'expose_event', $pixbuf); // right clic $menu = &new GtkMenu(); $blur = &new GtkMenuItem('Blur'); $blur->connect('activate', 'blur', $handle, $pixbuf, $area); $menu->append($blur); $exit = &new GtkMenuItem('Exit'); $exit->connect_object('activate', array('gtk', 'main_quit')); $menu->append($exit); $menu->show_all(); $window->add_events(GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); $window->connect_object('button-press-event', 'show_popup', $menu); function show_popup($event, $menu) { if($event->button == 3) $menu->popup(null, null, null, $event->button, $event->time); } function blur($blur, $handle, $pixbuf, $area) { global $colorspace, $has_alpha, $bits_per_sample, $width, $height, $rowstride; imagick_blur($handle, 8, 8); $image_data = imagick_image2blob($handle); $pixbuf = GdkPixbuf::new_from_data($image_data, $colorspace, $has_alpha, $bits_per_sample, $width, $height, $rowstride); $pixbuf->render_to_drawable($area->window, $area->style->fg_gc[GTK_STATE_NORMAL], 0, 0, 0, 0, $width, $height, GDK_RGB_DITHER_NORMAL, 0, 0); } //end right clic $frame = &new GtkFrame(); $frame->add($area); $frame->set_shadow_type(GTK_SHADOW_OUT); $window->add($frame); $window->show_all(); gtk::main(); function expose_event($area, $event, $pixbuf) { $pixbuf->render_to_drawable($area->window, $area->style->fg_gc[GTK_STATE_NORMAL], $event->area->x, $event->area->y, $event->area->x, $event->area->y, $event->area->width, $event->area->height, GDK_RGB_DITHER_NORMAL, 0, 0); } ?>

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