Re: Resizing xpm data?

Matthew Braid wrote:

Hi all,

I'm using xpm's for the images for a bunch of action buttons. This
works quite nicely.

These action buttons also have corresponding entries in a menu (in
case the action buttons have been hidden) and I'd like to put the same
images in next to their corresponding menu entry. Unfortunately, other
than actually making an XPM file that defines a smaller image, I can't
figure out how to 'resize' the images.

The images are created like so:

$img = Gtk2::Image->new;

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

Firstly, I don't do a lot of work with images, so this mightn't be the best way to do it:)
Gtk2::Gdk::Pixbuf has image scaling support, eg:

$pixbuf = $pixbuf->scale_simple(

I don't know if you can make a Gtk2::Gdk::Pixbuf directly from an xpm - never tried, probably works, but I'm sure there's a way. Once you've got your scaled image, you can go:

$img = Gtk2::Image->new_from_pixbuf ( $pixbuf );

Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: dkasak nusconsulting com au

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