如何在vala中调整Gtk.Image的大小 [英] How to resize a Gtk.Image in vala
本文介绍了如何在vala中调整Gtk.Image的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试调整vala中的图片大小.
所以我读了valadoc并最终编写了这段代码
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);
但是没有效果.
如果有一种方法可以动态缩放图像以使其充满他的容器,那就太棒了,但是仅缩放它就可以了.
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.
推荐答案
Image.from_pixbuf
创建新图像并添加到您的窗口.
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.
这篇关于如何在vala中调整Gtk.Image的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文