Re: Display Portions of an Image



I looked into gdk_pixbuf_copy_area, which almost seemed like it might do the
trick, except that it requires an existing pixbuf to put the copy into.

All you do is create a new pixbuf, taking the arguments from the values of the source pixbuf, then you can 
use the copy_area function no problems.

EG:

my $source = Gtk2::Gdk::Pixbuf->new_from_file('wanda.png');

# assume $width and $height are known, or can be calculated

my $dest = Gtk2::Gdk::Pixbuf->new(
        $source->get_colorspace,
        $source->get_has_alpha,
        $source->get_bits_per_sample,
        $width,
        $height
);

# $x_offset is probably some multiple of $width. $y_offset is probably zero.
# $dest_x and $dest_y are also probably zero.

$source->copy_area(
        $x_offset,
        $y_offset,
        $width,
        $height,
        $dest,
        $dest_x,
        $dest_y
);

Doesn't that do the trick?

Gavin.

-- 
Gavin Brown
e: gavin brown uk com
w: http://jodrell.net/
PGP/GPG key ID: 891D8FCA




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