问题
I'm trying to resize a Image in vala.
So I read valadoc and end up writing this code
var img = new Gtk.Image.from_file ("fire.png");
var pix_buf = img.get_pixbuf ();
pix_buf.scale_simple (50, 50, InterpType.BILINEAR);
window.add (img);
But it has no effect.
If there is a way to dynamically scale the image so that it fill his container it would be awesome, but just scaling it would be fine.
回答1:
Pixbuf.scale_simple does not modify the image. It returns a new Pixbuf
that has been scaled. Use Image.from_pixbuf to create a new image and add that to your window.
来源:https://stackoverflow.com/questions/29099740/how-to-resize-a-gtk-image-in-vala