set_image_modifier



Hi all,

I am trying out the set_image_modifier to change the gamma value of an
ImlibImage.

I created and adjuster for that, that has a callback to "sub gamma".
This doesn't do what I expect (change the gamma value).

Any pointers are greatly appreciated.

Also I would like some pointers on how to save the image, once the gamma
has changed.

Thanks.

AvA

###########code follows

#!/usr/bin/perl -w

use Gtk;
use Gtk::Gdk::ImlibImage; 
use Gnome;
use strict;

init Gnome "test12.pl";

my $file = shift;

my $window = new Gtk::Window("toplevel");
$window->set_title("Adjuster test");
$window->border_width(10);
$window->signal_connect( "delete_event", sub { Gtk->exit( 0 ); } );
$window->set_default_size(300,200);

my $vbox = new Gtk::VBox(0,0);
$vbox->set_usize(300,200);

$window->add($vbox);

my $canvas = Gnome::Canvas->new() ;
$canvas->set_usize(140,140);

my $croot = $canvas->root;

my $cgroup = $croot->new($croot, "Gnome::CanvasGroup");
my $img = Gtk::Gdk::ImlibImage->load_image($file);

my $a = $img->rgb_width / 140;   
my $b = $img->rgb_height / 140;

my $c;
($a > $b) ? $c = $a : $c = $b;

my $imgitem = $cgroup->new($cgroup, "Gnome::CanvasImage",
        'image' => $img,
        'x' => 50,  
        'y' => 50,
        width => $img->rgb_width / $c,
        height => $img->rgb_height / $c,
        );


$vbox->pack_start($canvas,0,0,0);

my $adj = new Gtk::Adjustment( 256, 0.0, 512.0, 0.0, 2.0, 0.0 );
my $scale = new Gtk::HScale( $adj );
$adj->signal_connect( "value_changed", \&gamma);

$vbox->pack_start($scale,0,0,0);
        
$window->show_all();

main Gtk; 
          
exit(0);
sub gamma{
my ($widget) = @_;

my $gamma = sprintf("%.0f", $widget->value);

print "$gamma\n";
$img->set_image_modifier(
        {'gamma' => $gamma,
         'contrast' => 256,
         'brightness'=> 256}
        );

}






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]