Re: image viewing, geometry...



I'm closer now...  load the image file with:

        $newimage = load_image Gtk::Gdk::ImlibImage($test_filename);

Look for expose_events on the Gtk::Pixmap so we know when it has a
size:
        $w = $g->get_widget('image_edit_pixmap'); # GTK-Interface/widget/name
        $w->signal_connect(expose_event => \&on_test_expose_event);

Then, on expose event (function below), draw the picture [only if the
size changes, of course.]  Two questions:
        1) when I do the Gtk::Pixmap::set, the container recalculates
size, and things shuffle until it converges.  Why?  Shouldn't I be
getting the "size it got" or is there some other value I should be
using?
        2) Is there a *symbolic* way, instead of ->[2] and ->[3], to
get the width/height out of an allocation?  Even for perl code, that's
ugly :-)

        sub on_test_expose_event {
            my($widget) = @_;
        
            $w = $g->get_widget('image_edit_pixmap'); #
            GTK-Interface/widget/name
            $widget_x = $w->allocation->[2];
            $widget_y = $w->allocation->[3];
            print "x: $widget_x  y: $widget_y\n";
            if ($old_x == $widget_x && $old_y == $widget_y) {
                return;
            }
            $newimage->render($widget_x/2, $widget_y/2);
            my $my_image = $newimage->copy_image();
            my $my_mask  = $newimage->copy_mask();
            $w->set($my_image, $my_mask);
        
            $old_x = $widget_x;
            $old_y = $widget_y;
        }



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