Hi Zentara, The following example shows you how to do it through gdk-pixbufs.
Test it through: gtk-image-example myimage.png or any other format that may be read by gdk-pixbufs. Regards, Dov #!/usr/bin/perl ###################################################################### # An example of how to get rgb value in a motion callback of # the image shown in Gtk2::Image. # # Dov Grobgeld <[EMAIL PROTECTED]> # 2005-08-28 # # This code is in the public domain. ###################################################################### use strict; use Gtk2 '-init'; sub get_rgb { my($img, $x,$y) = @_; return unpack("C3", $img->new_subpixbuf($x,$y,1,1)->get_pixels()); } sub cb_image_motion { my ($this, $event, $user_data) = @_; my ($label, $pb) = @$user_data; my $x = $event->x; my $y = $event->y; my $info = sprintf("Coord: (%3d,%3d) rgb: (%3d,%3d,%3d)", $x,$y, get_rgb($pb, $x,$y)); $label->set(label=>$info); return 1; } sub create_widgets { my $filename = shift || "test.ppm"; my $mw = Gtk2::Window->new(); # create a vbox for the image and a label my $vbox = Gtk2::VBox->new(); $mw->add($vbox); # Create an eventbox and put the image inside it my $event_box = Gtk2::EventBox->new(); my $image = Gtk2::Image->new(); $vbox->pack_start($event_box, 1,1,0); $event_box->add($image); # Load an image into a pixbuf. This gives more flexibility in # manipulating the image than using an Gdk::Pixmap. my $pb = new_from_file Gtk2::Gdk::Pixbuf($filename); die "Failed loading test image!\n" unless $pb; # create info label my $label = Gtk2::Label->new($filename); $vbox->pack_start($label, 0,0,0); # Load the image into the image widget and resize it so that # it fits the image $image->set_from_pixbuf($pb); $image->set_size_request($pb->get_width, $pb->get_height); # Make event box accept motion events $event_box->set_events(["pointer-motion-mask"]); # setup motion callback for the image widget $event_box->signal_connect("motion-notify-event"=>\&cb_image_motion, [$label,$pb]); $mw->show_all(); } create_widgets(@ARGV); Gtk2->main(); On Sun, Aug 28, 2005 at 06:43:31AM -0400, zentara wrote: > On Sat, 27 Aug 2005 21:26:13 -0400 (EDT) > [EMAIL PROTECTED] wrote: > > >Re: imagmap > > Does anyone have a code snippet to load an image > and as the mouse moves over it, display the rgb values > of the pixel beneath the mouse pointer? > > Is this possible? > > Thanks. > > -- > I'm not really a human, but I play one on earth. > http://zentara.net/japh.html > _______________________________________________ > gtk-perl-list mailing list > gtk-perl-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-perl-list _______________________________________________ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list