How to resize a Gtk.Image in vala

╄→гoц情女王★ 提交于 2020-01-14 19:30:27

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!