[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-gtk-general
Subject:    Re: [PHP-GTK] strange temp pixbuf
From:       Decapode Azur <blue_prawn () tuxfamily ! org>
Date:       2003-10-26 15:12:56
[Download RAW message or body]

...
> 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?
...

It is because $pixbuf is set twice!
it should be set only once, and in a callback to make it evoluate.

Here is a simple exemple, made from the exemple scribble.php
with GdkPixmap replaced by GdkPixbuf:

==========================
#! /usr/bin/php -q
<?php
dl('php_gtk.so');

if ($argc < 2) die("\tUsage:\n./{$_SERVER['PHP_SELF']} <imagefile>\n");
$image_file = $argv[1];

$handle = imagick_readimage($image_file);
$width  = imagick_getwidth ($handle);
$height = imagick_getheight($handle);
imagick_convert($handle, 'RGB');

$window = &new GtkWindow();
$window->set_name('Test Input');
$window->set_position(GTK_WIN_POS_CENTER);
$window->set_policy(true, false, false); // could also be (true, false, 
true)
$window->connect_object('destroy', array('gtk', 'main_quit'));

$drawing_area = &new GtkDrawingArea();
$drawing_area->size($width, $height);
$drawing_area->connect( 'expose_event',		'expose_');
$drawing_area->connect( 'configure_event',	'configure_');
$drawing_area->set_events(  GDK_EXPOSURE_MASK
			  | GDK_LEAVE_NOTIFY_MASK
			  | GDK_BUTTON_PRESS_MASK
			  | GDK_POINTER_MOTION_MASK
			  | GDK_POINTER_MOTION_HINT_MASK );
$drawing_area->show();

$window->add($drawing_area);
$window->show();
gtk::main();


$pixbuf = null;

function expose_($widget, $event) {
	global	$pixbuf;

	$pixbuf->render_to_drawable($widget->window,
		$widget->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);

	return false;
}
function configure_($widget, $event) {
	global	$pixbuf, $handle, $width, $height;

	$image_data  = imagick_image2blob   ($handle);
	$image_depth = imagick_getimagedepth($handle);

	$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);

	return true;
}
?>

-- 
PHP-GTK General Mailing List (http://gtk.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic