Re: dynamic mixing of primitives and background picture - semi-gui cropping utility

On Nov 11, 2009, at 1:47 AM, postdoc38 yahoo fr wrote:

Thanks for the input.

Any pointer on how to do the "in app" drawing?

Get the pixels from the pixbuf, treat them as a string of binary data and use pack() and unpack() to manipulate it. There's an example in the Gtk2 source tarball, if i recall correctly. You can also check the list archives.

Also, is there a way to make the window scroll automatically to the
appropriate corner of the image when the keys 1-4 are pressed.
It'd be nice to have that when viewing the full-size picture.

Set the adjustments' values, something like this (completely untested):

sub set_adj_to_max {
    my $adj = shift;
    my ($upper, $page_size) = $adj->get ('upper', 'page-size');
    $adj->set_value ($upper - $page_size);

sub set_adj_to_min {
    my $adj = shift;
    $adj->set_value ($adj->get ('lower'));

sub scroll_to_corner {
    my $which = shift;

    my $hadj = $scrolled_window->get_hadjustment ();
    my $vadj = $scrolled_window->get_vadjustment ();

    if ($which eq 'northwest') {
        set_adj_to_min ($hadj)
        set_adj_to_min ($vadj);

    } elsif ($which eq 'northeast') {
        set_adj_to_max ($hadj);
        set_adj_to_min ($vadj);

    } elsif ($which eq 'southeast') {
        set_adj_to_max ($hadj);
        set_adj_to_max ($vadj);

    } elsif ($which eq 'southwest') {
        set_adj_to_min ($hadj);
        set_adj_to_max ($vadj);

I can't believe i'm having to arbitrate who gets to have what dress on whose monkey.
  -- Me, exasperated at the ridiculousness of parenthood.

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