Re: Resizing xpm data?

On Feb 19, 2007, at 10:52 PM, Matthew Braid wrote:

Is there anything I can do from there to make a resized version, or do
I have to follow a different path there?


my $xpm_path = "/path/to/image.xpm";

# load directly
my $img = Gtk2::Image->new_from_file ($xpm_path);

# equivalent to Gtk2::Image::new_from_file()
my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file ($xpm_path);
$img->set_from_pixbuf ($pixbuf);

# load then scale (e.g. if you need both regular and small)
my $small_pixbuf = $pixbuf->scale_simple ($dest_width, $dest_height, 'bilinear');
$img->set_from_pixbuf ($small_pixbuf);

# scale on load
my $other_small_pixbuf =
Gtk2::Gdk::Pixbuf->new_from_file_at_size ($xpm_path, $dest_width, $dest_height);
$img->set_from_pixbuf ($other_small_pixbuf);

I hate to break it to you, but magic data pixies don't exist.
  -- Simon Cozens

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